Commit 836ac58a authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

- L'opération de synchro peut maintenant gérer le changement de source d'une...

- L'opération de synchro peut maintenant gérer le changement de source d'une donnée (SOURCE_ID qui change).
- Si la colonne ID est fournie dans la vue source, alors cette dernière est utilisée pour faire la jointure avec la table
dans la vue différentielle. Le SOURCE_CODE est alors inexploité, même s'il doit être fourni tout de même.
parent 3ec9a878
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
CHANGELOG
=========

3.1 (en cours...)
------------------
- L'opération de synchro peut maintenant gérer le changement de source d'une donnée (SOURCE_ID qui change).
- Si la colonne ID est fournie dans la vue source, alors cette dernière est utilisée pour faire la jointure avec la table 
dans la vue différentielle. Le SOURCE_CODE est alors inexploité, même s'il doit être fourni tout de même.
- (TODO) Possibilité de préciser si les données non importables (CAD saisies directement dans l'application) peuvent devenir synchronisables si elles sont par la suite remontées par la vue source.

3.0.2 (16/06/2020)
------------------
Prise en compte des associations (clés étrangères) pour pouvoir retrouver le nom de la colonne
+7 −4
Original line number Diff line number Diff line
@@ -468,6 +468,10 @@ class QueryGeneratorService extends AbstractService
            }
        }

        if ($this->getServiceSchema()->hasColumn('SRC_'.$tableName, 'ID')){
            $joinCond = 'S.ID = D.ID';
        }

        // on génère ensuite la bonne requête !!!
        $cols = $this->getCols($tableName);
        foreach ($cols as $id => $col) {
@@ -476,7 +480,6 @@ class QueryGeneratorService extends AbstractService
        $sql = "CREATE OR REPLACE FORCE VIEW V_DIFF_$tableName AS
select diff.* from (SELECT
  D.id id,
  COALESCE( S.source_id, D.source_id ) source_id,
  COALESCE( S.source_code, D.source_code ) source_code,
CASE
    WHEN S.source_code IS NOT NULL AND D.source_code IS NULL THEN 'insert'
@@ -499,7 +502,7 @@ CASE
            }, ",\n  ") . "
FROM
  $tableName D$depJoin
  FULL JOIN SRC_$tableName S ON S.source_id = D.source_id AND $joinCond
  FULL JOIN SRC_$tableName S ON $joinCond
WHERE
       (S.source_code IS NOT NULL AND D.source_code IS NOT NULL AND D.histo_destruction IS NOT NULL AND D.histo_destruction <= SYSDATE)
    OR (S.source_code IS NULL AND D.source_code IS NOT NULL AND (D.histo_destruction IS NULL OR D.histo_destruction > SYSDATE))
@@ -567,9 +570,9 @@ WHERE
        CASE diff_row.import_action
          WHEN 'insert' THEN
            INSERT INTO $tableName
              ( id, " . $this->formatColQuery($cols) . ", source_id, source_code, histo_createur_id, histo_modificateur_id )
              ( id, " . $this->formatColQuery($cols) . ", source_code, histo_createur_id, histo_modificateur_id )
            VALUES
              ( COALESCE(diff_row.id,$tableName" . "_ID_SEQ.NEXTVAL), " . $this->formatColQuery($cols, 'diff_row.:column') . ", diff_row.source_id, diff_row.source_code, unicaen_import.get_current_user, unicaen_import.get_current_user );
              ( COALESCE(diff_row.id,$tableName" . "_ID_SEQ.NEXTVAL), " . $this->formatColQuery($cols, 'diff_row.:column') . ", diff_row.source_code, unicaen_import.get_current_user, unicaen_import.get_current_user );

          WHEN 'update' THEN
            " . $this->formatColQuery(
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ class SchemaService extends AbstractService
    /**
     * @return Column[][]
     */
    public function makeSchema()
    private function makeSchema()
    {
        $sql = 'SELECT * FROM V_IMPORT_TAB_COLS';
        $d   = $this->query($sql, []);
@@ -200,7 +200,7 @@ class SchemaService extends AbstractService
            WHERE
              utc.COLUMN_NAME NOT IN ('ID')
              AND utc.COLUMN_NAME NOT LIKE 'HISTO_%'
              AND utc.COLUMN_NAME NOT LIKE 'SOURCE_%'
              AND utc.COLUMN_NAME <> 'SOURCE_CODE'
              AND utc.table_name = :tableName
            ORDER BY
              utc.COLUMN_NAME";