Commit 1839a362 authored by Florentin L'Homme's avatar Florentin L'Homme
Browse files

Merge branch 'new-diff-strategy' of...

Merge branch 'new-diff-strategy' of ssh://git.unicaen.fr:/lib/unicaen/db-import into new-diff-strategy
parents 07bdd83f 97e68b55
Loading
Loading
Loading
Loading
+1 −0
Changes for .gitignore: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
.idea/
vendor/
+3 −3
Changes for composer.json: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -5,18 +5,18 @@
  "repositories": [
    {
      "type": "composer",
      "url": "https://dev.unicaen.fr/packagist"
      "url": "https://gest.unicaen.fr/packagist"
    }
  ],
  "require": {
    "php": ">=5.6",
    "php": ">=7.2",
    "doctrine/doctrine-orm-module": ">=0.7",
    "beberlei/assert": "^2.7",
    "ramsey/uuid": "^3.6"
  },
  "require-dev": {
    "phpunit/phpunit": "~5.4",
    "unicaen/test": "^1.0"
    "unicaen/test": "dev-zf-3.x"
  },
  "autoload": {
    "psr-0": {
+2288 −697

File changed.

Preview size limit exceeded, changes collapsed.

+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
Loading