Commit 97e68b55 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Déplacement des classes communes (disparition du répertoire Common); renommage...

Déplacement des classes communes (disparition du répertoire Common); renommage des classes abstraites.
parent 7b5a8b99
Loading
Loading
Loading
Loading
+18 −10
Changes for src/UnicaenDbImport/CodeGenerator/CodeGenerator.php: 18 added lines, 10 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenDbImport\CodeGenerator\Common;
namespace UnicaenDbImport\CodeGenerator;

use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Interop\Container\ContainerInterface;
use UnicaenApp\Exception\RuntimeException;
use UnicaenApp\Util;
use UnicaenDbImport\CodeGenerator\Common\Helper\AbstractHelper;
use UnicaenDbImport\CodeGenerator\Common\Helper\DiffViewHelper;
use UnicaenDbImport\CodeGenerator\Common\Helper\SynchroLogHelper;
use UnicaenDbImport\CodeGenerator\Common\Helper\TableValidationHelper;
use UnicaenDbImport\CodeGenerator\PostgreSQL\CodeGenerator;
use UnicaenDbImport\CodeGenerator\Helper\DiffViewHelper;
use UnicaenDbImport\CodeGenerator\Helper\SynchroLogHelper;
use UnicaenDbImport\CodeGenerator\Helper\TableValidationHelper;
use UnicaenDbImport\Domain\DestinationInterface;
use UnicaenDbImport\Domain\Operation;
use UnicaenDbImport\Domain\SourceInterface;
@@ -22,7 +19,7 @@ use UnicaenDbImport\Domain\Synchro;
 *
 * @author Unicaen
 */
abstract class AbstractCodeGenerator implements CodeGeneratorInterface
abstract class CodeGenerator implements CodeGeneratorInterface
{
    /**
     * @var AbstractPlatform
@@ -172,6 +169,7 @@ EOT;
            if ($value === null) {
                return 'NULL';
            }

            return $platform->quoteStringLiteral($value);
        }, $columnsValues));

@@ -183,6 +181,10 @@ EOT;
        return $sql;
    }

    /**
     * @param string $tableName
     * @return string
     */
    public function generateSQLForTruncateTable($tableName)
    {
        $platform = $this->platform;
@@ -193,13 +195,19 @@ EOT;
    /**
     * @return string
     */
    abstract public function generateSQLForSynchroLogTableCreation();
    public function generateSQLForSynchroLogTableCreation()
    {
        throw CodeGeneratorException::methodToImplement(__METHOD__, get_called_class(), $this->platform);
    }

    /**
     * @param string $tableName
     * @return string
     */
    abstract public function generateSQLForIntermmediateTableDrop($tableName);
    public function generateSQLForIntermmediateTableDrop($tableName)
    {
        throw CodeGeneratorException::methodToImplement(__METHOD__, get_called_class(), $this->platform);
    }

    /**
     * @param SourceInterface      $source
+22 −1
Changes for src/UnicaenDbImport/CodeGenerator/CodeGeneratorException.php: 22 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2,12 +2,33 @@

namespace UnicaenDbImport\CodeGenerator;

use BadMethodCallException;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use UnicaenApp\Exception\RuntimeException;

class CodeGeneratorException extends RuntimeException
{
    public static function codeGeneratorServiceNotFound($name)
    /**
     * @param string $name
     * @return CodeGeneratorException
     */
    public static function codeGeneratorServiceNotFound(string $name)
    {
        return new static("CodeGenerator introuvable avec l'identifiant de service suivant : " . $name);
    }

    /**
     * @param string           $method
     * @param string           $calledClass
     * @param AbstractPlatform $platform
     * @return BadMethodCallException
     */
    public static function methodToImplement(string $method, string $calledClass, AbstractPlatform $platform = null)
    {
        return new BadMethodCallException(sprintf(
            "Vous devez implémenter la méthode '%s::%s' sur mesure pour la pateforme '%s'",
            $method, $calledClass, $platform->getName()
        ));

    }
}
 No newline at end of file
+38 −1
Changes for src/UnicaenDbImport/CodeGenerator/CodeGeneratorInterface.php: 38 added lines, 1 removed line.
Original line number Diff line number Diff line
<?php

namespace UnicaenDbImport\CodeGenerator\Common;
namespace UnicaenDbImport\CodeGenerator;

use Doctrine\DBAL\DBALException;
use UnicaenApp\Exception\RuntimeException;
use UnicaenDbImport\Domain\DestinationInterface;
use UnicaenDbImport\Domain\SourceInterface;
@@ -92,4 +93,40 @@ interface CodeGeneratorInterface
     * @return string
     */
    public function generateSQLForFetchingSynchroLogTable($hash);

    /**
     * @param string $tableName
     * @return string
     */
    public function generateSQLForTruncateTable($tableName);

    /**
     * @param SourceInterface      $source
     * @param DestinationInterface $destination
     * @param string               $intermediateTable
     * @return string
     * @throws DBALException
     */
    public function generateSQLForDiffViewCreation(SourceInterface $source, DestinationInterface $destination, $intermediateTable);

    /**
     * @param SourceInterface      $source
     * @param DestinationInterface $destination
     * @return string
     */
    public function generateSQLForDiffViewSelect(SourceInterface $source, DestinationInterface $destination);

    /**
     * @param array                $rows
     * @param SourceInterface      $source
     * @param DestinationInterface $destination
     * @param string               $hash
     * @return string
     */
    public function generateSQLForDestinationUpdateFromDiffViewRequestResult(
        array $rows,
        SourceInterface $source,
        DestinationInterface $destination,
        $hash);

}
 No newline at end of file
+6 −3
Changes for src/UnicaenDbImport/CodeGenerator/Helper.php: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenDbImport\CodeGenerator\Common\Helper;
namespace UnicaenDbImport\CodeGenerator;

use Doctrine\DBAL\Platforms\AbstractPlatform;

@@ -9,7 +9,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
 *
 * @author Unicaen
 */
abstract class AbstractHelper
abstract class Helper
{
    /**
     * @return AbstractPlatform
@@ -20,7 +20,10 @@ abstract class AbstractHelper
     * @param string $argument
     * @return string
     */
    abstract protected function getQuoteLiteralFunctionCallSQLSnippet($argument);
    protected function getQuoteLiteralFunctionCallSQLSnippet($argument)
    {
        throw CodeGeneratorException::methodToImplement(__METHOD__, get_called_class(), $this->getPlatform());
    }

    /**
     * @param int    $length
+3 −2
Changes for src/UnicaenDbImport/CodeGenerator/Helper/DiffViewHelper.php: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
<?php

namespace UnicaenDbImport\CodeGenerator\Common\Helper;
namespace UnicaenDbImport\CodeGenerator\Helper;

use Doctrine\DBAL\DBALException;
use UnicaenDbImport\CodeGenerator\Helper;
use UnicaenDbImport\Domain\Operation;

/**
@@ -12,7 +13,7 @@ use UnicaenDbImport\Domain\Operation;
 *
 * @author Unicaen
 */
abstract class DiffViewHelper extends AbstractHelper
abstract class DiffViewHelper extends Helper
{
    /**
     * @param string $diffSourceTableName
Loading