From 079d89aee3d60086a7798ab4e14e5b098b6b5546 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laurent=20L=C3=A9cluse?= <laurent.lecluse@unicaen.fr>
Date: Thu, 11 Feb 2021 17:31:50 +0100
Subject: [PATCH] =?UTF-8?q?Possibilit=C3=A9=20d'afficher=20un=20diff=20d'i?=
 =?UTF-8?q?mport=20sans=20tenir=20compte=20du=20filtre=20global=20Ajout=20?=
 =?UTF-8?q?d'un=20filtre=20pour=20ne=20pas=20supprimer=20des=20donn=C3=A9e?=
 =?UTF-8?q?s=20saisies=20dans=20OSE=20m=C3=AAme=20si=20les=20donn=C3=A9es?=
 =?UTF-8?q?=20locales=20sont=20synchronisables?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 CHANGELOG.md                                        | 7 ++++++-
 src/UnicaenImport/Service/DifferentielService.php   | 6 ++++--
 src/UnicaenImport/Service/QueryGeneratorService.php | 2 ++
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1eb7d64..6611bba 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,12 @@
 CHANGELOG
 =========
 
-3.1.0 (29/01/2020)
+3.1.1 (11/02/2021)
+------------------
+- Possibilité d'afficher un diff d'import sans tenir compte du filtre global
+- Ajout d'un filtre pour ne pas supprimer des données saisies dans OSE même si les données locales sont synchronisables
+
+3.1.0 (29/01/2021)
 ------------------
 - 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 
diff --git a/src/UnicaenImport/Service/DifferentielService.php b/src/UnicaenImport/Service/DifferentielService.php
index a68369b..4c08b14 100644
--- a/src/UnicaenImport/Service/DifferentielService.php
+++ b/src/UnicaenImport/Service/DifferentielService.php
@@ -40,10 +40,12 @@ class DifferentielService extends AbstractService
      *
      * @return self
      */
-    public function make(Query $query, $mode = Query::SQL_PARTIAL)
+    public function make(Query $query, $mode = Query::SQL_PARTIAL, bool $noDefaultSyncFiltre=false)
     {
         $this->tableName = $query->getTableName();
-        $query->addDefaultSyncFiltre($this->getServiceQueryGenerator());
+        if (!$noDefaultSyncFiltre) {
+            $query->addDefaultSyncFiltre($this->getServiceQueryGenerator());
+        }
         $this->stmt = $this->getEntityManager()->getConnection()->executeQuery($query->toSql($mode), []);
 
         return $this;
diff --git a/src/UnicaenImport/Service/QueryGeneratorService.php b/src/UnicaenImport/Service/QueryGeneratorService.php
index 91ffd3c..f2f5c76 100644
--- a/src/UnicaenImport/Service/QueryGeneratorService.php
+++ b/src/UnicaenImport/Service/QueryGeneratorService.php
@@ -527,6 +527,8 @@ WHERE
 ) diff JOIN source on source.id = diff.source_id WHERE import_action IS NOT NULL";
         if (!$table->getSyncNonImportables()) {
             $sql .= " AND source.importable = 1";
+        }else{
+            $sql .= " AND NOT (source.importable = 0 AND import_action='delete')";
         }
 
         return $sql;
-- 
GitLab