Commit 0fd6f0a8 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Dans la table SOURCE, un nouveau flag indique si dans le cadre d'une synchro...

Dans la table SOURCE, un nouveau flag indique si dans le cadre d'une synchro l'opération 'delete' est interdite. L'interdire est utile lorsque les données sources sont obtenues de façon incrémentale au fil du temps (et non pas de façon exhaustive en une seule fois).
parent 00067f0c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ create table SOURCE
	ID NUMBER not null constraint SOURCE_PK primary key,
	CODE VARCHAR2(64 char) not null constraint SOURCE_CODE_UN unique,
	LIBELLE VARCHAR2(128 char) not null,
	IMPORTABLE NUMBER(1) not null
	IMPORTABLE NUMBER(1) not null,
    SYNCHRO_DELETE_INTERDIT int(1) default 0 not null
);

INSERT INTO SOURCE (ID, CODE, LIBELLE, IMPORTABLE) VALUES (1, 'app', 'Application', 0);
+3 −1
Original line number Diff line number Diff line
@@ -6,9 +6,11 @@ create table source
    id bigint not null constraint source_pkey primary key,
    code varchar(64) not null constraint source_code_key unique,
    libelle varchar(128) not null,
    importable boolean not null
    importable boolean not null,
    synchro_delete_interdit boolean default false not null
);
comment on table source is 'Sources de données, importables ou non, ex: Apogée, Physalis.';
comment on column source.synchro_delete_interdit is 'Indique si dans le cadre d''une synchro l''opération ''delete'' est interdite. L''interdire est utile lorsque les données sources sont obtenues de façon incrémentale au fil du temps et non pas de façon exhaustive en une seule fois.';

INSERT INTO SOURCE (ID, CODE, LIBELLE, IMPORTABLE) VALUES (1, 'app', 'Application', false);
--INSERT INTO SOURCE (ID, CODE, LIBELLE, IMPORTABLE) VALUES (2, 'octopus', 'Référentiel Octopus', true);
+6 −1
Original line number Diff line number Diff line
@@ -219,6 +219,11 @@ EOT;

        $requiredValueForImportable = $this->platformSupportsBooleanType() ? 'true' : 1;

        // Dans la table SOURCE, un flag indique si dans le cadre d'une synchro l'opération 'delete' est interdite.
        // L'interdire est utile lorsque les données sources sont obtenues de façon incrémentale au fil du temps
        // (et non pas de façon exhaustive en une seule fois).
        $requiredValueForSynchroDeleteInterdit = $this->platformSupportsBooleanType() ? 'false' : 0;

        return <<<EOT
with diff as (
    SELECT
@@ -229,7 +234,7 @@ with diff as (
        when (s.$sourceCodeColumn IS NOT NULL AND d.$sourceCodeColumn IS NULL) then '$insert'
        when (s.$sourceCodeColumn IS NOT NULL AND d.$sourceCodeColumn IS NOT NULL and (d.$deletedOnColumn IS NULL or d.$deletedOnColumn > $now)) then '$update'
        when (s.$sourceCodeColumn IS NOT NULL AND d.$sourceCodeColumn IS NOT NULL and (d.$deletedOnColumn IS NOT NULL and d.$deletedOnColumn <= $now)) then '$undelete'
        when (s.$sourceCodeColumn IS NULL AND d.$sourceCodeColumn IS NOT NULL and (d.$deletedOnColumn IS NULL or d.$deletedOnColumn > $now)) then '$delete' end as operation,
        when (s.$sourceCodeColumn IS NULL AND d.$sourceCodeColumn IS NOT NULL and (d.$deletedOnColumn IS NULL or d.$deletedOnColumn > $now)) and src.synchro_delete_interdit = $requiredValueForSynchroDeleteInterdit then '$delete' end as operation,

        $updatedColumsSql,

+21 −0
Original line number Diff line number Diff line
@@ -24,6 +24,11 @@ abstract class AbstractSource implements SourceInterface
     */
    protected $importable;

    /**
     * @var boolean
     */
    protected bool $synchroDeleteInterdit = false;

    /**
     * @var string
     */
@@ -79,6 +84,22 @@ abstract class AbstractSource implements SourceInterface
        return $this->importable;
    }

    /**
     * @return bool
     */
    public function getSynchroDeleteInterdit(): bool
    {
        return $this->synchroDeleteInterdit;
    }

    /**
     * @param bool $synchroDeleteInterdit
     */
    public function setSynchroDeleteInterdit(bool $synchroDeleteInterdit = true): void
    {
        $this->synchroDeleteInterdit = $synchroDeleteInterdit;
    }

    /**
     * Set libelle
     *
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

        <field name="code" column="CODE"/>
        <field name="importable" type="boolean" column="IMPORTABLE"/>
        <field name="synchroDeleteInterdit" type="boolean" column="SYNCHRO_DELETE_INTERDIT"/>
        <field name="libelle" column="LIBELLE"/>

    </mapped-superclass>
Loading