Skip to content
Snippets Groups Projects
Commit b720a365 authored by Thibaut Vallee's avatar Thibaut Vallee
Browse files

création d'un branche compatible Laminas, PHP-7.4 (et probablement 8 mais non...

création d'un branche compatible Laminas, PHP-7.4 (et probablement 8 mais non vérifié). Dependance avec Boostrap5 et UnicaenPrivilege (a la place de UnicaenAuth
parent fe9305e2
No related branches found
No related tags found
No related merge requests found
Pipeline #15287 passed
Showing
with 93 additions and 29 deletions
...@@ -399,13 +399,14 @@ return [ ...@@ -399,13 +399,14 @@ return [
[ [
'name' => "IMPORT_SIMPLE", 'name' => "IMPORT_SIMPLE",
'source' => [ 'source' => [
'code' => 'UTILISATEUR_OCTOPUS', 'name' => 'UTILISATEUR_OCTOPUS',
'table' => 'UTILISATEUR', 'table' => 'UTILISATEUR',
'connection' => 'orm_B', 'connection' => 'orm_B',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
'code' => 'CODE_SOURCE',
], ],
'destination' => [ 'destination' => [
'code' => 'TABLE UTILISATEUR LOCALE', 'name' => 'TABLE UTILISATEUR LOCALE',
'table' => 'UTILISATEUR', 'table' => 'UTILISATEUR',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
...@@ -433,13 +434,13 @@ return [ ...@@ -433,13 +434,13 @@ return [
[ [
'name' => "IMPORT_REGIONS_API", 'name' => "IMPORT_REGIONS_API",
'source' => [ 'source' => [
'code' => 'geo_api', // DOIT correspondre à un `CODE` de la table `SOURCE` 'name' => 'geo_api', // DOIT correspondre à un `CODE` de la table `SOURCE`
'select' => '/regions?fields=nom,code', 'select' => '/regions?fields=nom,code',
'connection' => 'geo', 'connection' => 'geo',
'source_code_column' => 'code', 'source_code_column' => 'code',
], ],
'destination' => [ 'destination' => [
'code' => 'Table REGION', 'name' => 'Table REGION',
'table' => 'REGION', 'table' => 'REGION',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
...@@ -471,13 +472,13 @@ return [ ...@@ -471,13 +472,13 @@ return [
[ [
'name' => "SYNCHRO_LOCALE_ROLE", 'name' => "SYNCHRO_LOCALE_ROLE",
'source' => [ 'source' => [
'code' => 'app', 'name' => 'app',
'select' => 'SELECT CODE, LIBELLE, DESCRIPTION FROM SRC_ROLE', 'select' => 'SELECT CODE, LIBELLE, DESCRIPTION FROM SRC_ROLE',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
], ],
'destination' => [ 'destination' => [
'code' => 'Table ROLE', 'name' => 'Table ROLE',
'table' => 'ROLE', 'table' => 'ROLE',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
...@@ -515,13 +516,13 @@ return [ ...@@ -515,13 +516,13 @@ return [
[ [
'name' => "SYNCHRO_BDD_EXTERNE", 'name' => "SYNCHRO_BDD_EXTERNE",
'source' => [ 'source' => [
'code' => 'UTILISATEUR_OCTOPUS', 'name' => 'UTILISATEUR_OCTOPUS',
'select' => 'SELECT CODE, NOM, PRENOM, NAISSANCE FROM UTILISATEUR', 'select' => 'SELECT CODE, NOM, PRENOM, NAISSANCE FROM UTILISATEUR',
'connection' => 'orm_B', 'connection' => 'orm_B',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
], ],
'destination' => [ 'destination' => [
'code' => 'Table UTILISATEUR', 'name' => 'Table UTILISATEUR',
'table' => 'UTILISATEUR', 'table' => 'UTILISATEUR',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
...@@ -558,13 +559,13 @@ return [ ...@@ -558,13 +559,13 @@ return [
[ [
'name' => "SYNCHRO_COMMUNES", 'name' => "SYNCHRO_COMMUNES",
'source' => [ 'source' => [
'code' => 'geo_api', // DOIT correspondre à un `CODE` de la table `SOURCE` 'name' => 'geo_api', // DOIT correspondre à un `CODE` de la table `SOURCE`
'select' => '/departements/63/communes?fields=nom,code', 'select' => '/departements/63/communes?fields=nom,code',
'connection' => 'geo', 'connection' => 'geo',
'source_code_column' => 'code', 'source_code_column' => 'code',
], ],
'destination' => [ 'destination' => [
'code' => 'Table locale', 'name' => 'Table locale',
'table' => 'REGION', 'table' => 'REGION',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'CODE', 'source_code_column' => 'CODE',
...@@ -619,13 +620,13 @@ return [ ...@@ -619,13 +620,13 @@ return [
[ [
'name' => "IMPORT_PRÉALABLE", // Importation des données externes dans une table intermédiaire 'name' => "IMPORT_PRÉALABLE", // Importation des données externes dans une table intermédiaire
'source' => [ 'source' => [
'code' => 'FORMATION_FCA', 'name' => 'FORMATION_FCA',
'select' => 'SELECT ID, CODE, NOM, COMPOSANTE_CODE FROM FORMATION', 'select' => 'SELECT ID, CODE, NOM, COMPOSANTE_CODE FROM FORMATION',
'connection' => 'orm_B', 'connection' => 'orm_B',
'source_code_column' => 'ID', 'source_code_column' => 'ID',
], ],
'destination' => [ 'destination' => [
'code' => 'Table TMP_FORMATION locale', 'name' => 'Table TMP_FORMATION locale',
'table' => 'TMP_FORMATION', 'table' => 'TMP_FORMATION',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'ID', 'source_code_column' => 'ID',
...@@ -636,13 +637,13 @@ return [ ...@@ -636,13 +637,13 @@ return [
[ [
'name' => "SYNCHRO_FINALE", // Synchro des données mise en forme vers la table finale 'name' => "SYNCHRO_FINALE", // Synchro des données mise en forme vers la table finale
'source' => [ 'source' => [
'code' => 'TABLE SRC_FORMATION DE MA BASE A UTILISANT TMP_FORMATION', 'name' => 'TABLE SRC_FORMATION DE MA BASE A UTILISANT TMP_FORMATION',
'select' => 'SELECT * FROM SRC_FORMATION', 'select' => 'SELECT * FROM SRC_FORMATION',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'ID', 'source_code_column' => 'ID',
], ],
'destination' => [ 'destination' => [
'code' => 'TABLE FORMATION DE MA BASE A', 'name' => 'TABLE FORMATION DE MA BASE A',
'table' => 'FORMATION', 'table' => 'FORMATION',
'connection' => 'orm_A', 'connection' => 'orm_A',
'source_code_column' => 'ID', 'source_code_column' => 'ID',
......
...@@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Driver\XmlDriver; ...@@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
use Laminas\Router\Http\Literal; use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment; use Laminas\Router\Http\Segment;
use UnicaenAuth\Guard\PrivilegeController; use UnicaenPrivilege\Guard\PrivilegeController;
use UnicaenDbImport\CodeGenerator\HelperAbstractFactory; use UnicaenDbImport\CodeGenerator\HelperAbstractFactory;
use UnicaenDbImport\Config\Config; use UnicaenDbImport\Config\Config;
use UnicaenDbImport\Config\ConfigFactory; use UnicaenDbImport\Config\ConfigFactory;
......
...@@ -58,6 +58,7 @@ function installLancementMultiple() ...@@ -58,6 +58,7 @@ function installLancementMultiple()
} else { } else {
btn.addClass('disabled'); btn.addClass('disabled');
} }
if(urlPattern === undefined){return;}
btn.prop("href", urlPattern.replace('__names__', generateNames($checkboxes))); btn.prop("href", urlPattern.replace('__names__', generateNames($checkboxes)));
} }
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace UnicaenDbImport\Controller; namespace UnicaenDbImport\Controller;
use Exception;
use Laminas\Http\PhpEnvironment\Response; use Laminas\Http\PhpEnvironment\Response;
use Laminas\Mvc\Controller\AbstractActionController; use Laminas\Mvc\Controller\AbstractActionController;
use Laminas\View\Model\JsonModel; use Laminas\View\Model\JsonModel;
...@@ -37,13 +38,17 @@ class SynchroController extends AbstractActionController ...@@ -37,13 +38,17 @@ class SynchroController extends AbstractActionController
} else { } else {
$synchros = $this->synchroService->getSynchros(); $synchros = $this->synchroService->getSynchros();
} }
$importLogs = $diffCounts = []; $importLogs = $diffCounts = [];
foreach ($synchros as $synchro) { foreach ($synchros as $synchro) {
$importLog = $this->importLogService->findLastLogForSynchro($synchro); $importLog = $this->importLogService->findLastLogForSynchro($synchro);
$importLogs[$synchro->getName()] = $importLog; $importLogs[$synchro->getName()] = $importLog;
try{
$diffCounts[$synchro->getName()] = $this->synchroService->fetchSynchroDiffCount($synchro); $diffCounts[$synchro->getName()] = $this->synchroService->fetchSynchroDiffCount($synchro);
} }
catch (Exception $e){
$this->flashMessenger()->addErrorMessage(sprintf("Erreur rencontrée lors du calcul des différences pour la syncho %s", $synchro));
}
}
return [ return [
'synchros' => $synchros, 'synchros' => $synchros,
...@@ -62,7 +67,12 @@ class SynchroController extends AbstractActionController ...@@ -62,7 +67,12 @@ class SynchroController extends AbstractActionController
{ {
$name = $this->params('name'); $name = $this->params('name');
$synchro = $this->synchroService->getSynchroByName($name); $synchro = $this->synchroService->getSynchroByName($name);
try{
$diffCount = $this->synchroService->fetchSynchroDiffCount($synchro); $diffCount = $this->synchroService->fetchSynchroDiffCount($synchro);
}
catch (Exception $e){
$this->flashMessenger()->addErrorMessage(sprintf("Erreur rencontrée lors du calcul des différences pour la syncho %s", $synchro));
}
$importLog = $this->importLogService->findLastLogForSynchro($synchro); $importLog = $this->importLogService->findLastLogForSynchro($synchro);
return [ return [
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace UnicaenDbImport\Privilege; namespace UnicaenDbImport\Privilege;
use UnicaenAuth\Provider\Privilege\Privileges; use UnicaenPrivilege\Provider\Privilege\Privileges;
class ImportPrivilege extends Privileges class ImportPrivilege extends Privileges
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace UnicaenDbImport\Privilege; namespace UnicaenDbImport\Privilege;
use UnicaenAuth\Provider\Privilege\Privileges; use UnicaenPrivilege\Provider\Privilege\Privileges;
class LogPrivilege extends Privileges class LogPrivilege extends Privileges
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace UnicaenDbImport\Privilege; namespace UnicaenDbImport\Privilege;
use UnicaenAuth\Provider\Privilege\Privileges; use UnicaenPrivilege\Provider\Privilege\Privileges;
class ObservationPrivilege extends Privileges class ObservationPrivilege extends Privileges
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace UnicaenDbImport\Privilege; namespace UnicaenDbImport\Privilege;
use UnicaenAuth\Provider\Privilege\Privileges; use UnicaenPrivilege\Provider\Privilege\Privileges;
class SynchroPrivilege extends Privileges class SynchroPrivilege extends Privileges
{ {
......
...@@ -468,6 +468,9 @@ class DatabaseService ...@@ -468,6 +468,9 @@ class DatabaseService
"les données doivent contenir une colonne SOURCE_ID ou source_id"); "les données doivent contenir une colonne SOURCE_ID ou source_id");
} }
} }
else{
$row['SOURCE_ID'] = $sourceCode;
}
return $row; return $row;
} }
......
...@@ -64,9 +64,33 @@ class SynchroFacadeService extends AbstractFacadeService ...@@ -64,9 +64,33 @@ class SynchroFacadeService extends AbstractFacadeService
*/ */
public function fetchSynchroDiff(): array public function fetchSynchroDiff(): array
{ {
$intermediateTable = null;
if ($this->requiresIntermediateTable) {
$this->fetchSource();
$intermediateTable = $this->destination->getIntermediateTable();
if ($this->destination->getIntermediateTableAutoDrop()) {
$this->logger->info("Suppression de la table intermédiaire $intermediateTable");
$this->databaseService->dropIntermediateTable($intermediateTable);
} else {
$this->databaseService->checkIntermediateTableNotExists($intermediateTable);
}
$this->logger->info("Création de la table intermédiaire $intermediateTable");
$this->databaseService->createIntermediateTable($intermediateTable);
$this->logger->info("Peuplement de la table intermédiaire $intermediateTable");
$this->databaseService->populateTableFromSource($intermediateTable, false);
}
$this->recreateDiffView(); $this->recreateDiffView();
$result = $this->databaseService->fetchDiffView();
if ($this->requiresIntermediateTable) {
$this->logger->info("Suppression de la table intermédiaire");
$this->databaseService->dropIntermediateTable($intermediateTable);
}
return $this->databaseService->fetchDiffView(); return $result;
} }
/** /**
...@@ -75,9 +99,32 @@ class SynchroFacadeService extends AbstractFacadeService ...@@ -75,9 +99,32 @@ class SynchroFacadeService extends AbstractFacadeService
*/ */
public function fetchSynchroDiffCount(): int public function fetchSynchroDiffCount(): int
{ {
$intermediateTable = null;
if ($this->requiresIntermediateTable) {
$this->fetchSource();
$intermediateTable = $this->destination->getIntermediateTable();
if ($this->destination->getIntermediateTableAutoDrop()) {
$this->logger->info("Suppression de la table intermédiaire $intermediateTable");
$this->databaseService->dropIntermediateTable($intermediateTable);
} else {
$this->databaseService->checkIntermediateTableNotExists($intermediateTable);
}
$this->logger->info("Création de la table intermédiaire $intermediateTable");
$this->databaseService->createIntermediateTable($intermediateTable);
$this->logger->info("Peuplement de la table intermédiaire $intermediateTable");
$this->databaseService->populateTableFromSource($intermediateTable, false);
}
$this->recreateDiffView(); $this->recreateDiffView();
$result = $this->databaseService->fetchDiffViewCount();
return $this->databaseService->fetchDiffViewCount(); if ($this->requiresIntermediateTable) {
$this->logger->info("Suppression de la table intermédiaire");
$this->databaseService->dropIntermediateTable($intermediateTable);
}
return $result;
} }
/** /**
...@@ -91,7 +138,6 @@ class SynchroFacadeService extends AbstractFacadeService ...@@ -91,7 +138,6 @@ class SynchroFacadeService extends AbstractFacadeService
if ($this->requiresIntermediateTable) { if ($this->requiresIntermediateTable) {
$this->fetchSource(); $this->fetchSource();
$intermediateTable = $this->destination->getIntermediateTable(); $intermediateTable = $this->destination->getIntermediateTable();
if ($this->destination->getIntermediateTableAutoDrop()) { if ($this->destination->getIntermediateTableAutoDrop()) {
$this->logger->info("Suppression de la table intermédiaire $intermediateTable"); $this->logger->info("Suppression de la table intermédiaire $intermediateTable");
...@@ -105,7 +151,6 @@ class SynchroFacadeService extends AbstractFacadeService ...@@ -105,7 +151,6 @@ class SynchroFacadeService extends AbstractFacadeService
$this->logger->info("Peuplement de la table intermédiaire $intermediateTable"); $this->logger->info("Peuplement de la table intermédiaire $intermediateTable");
$this->databaseService->populateTableFromSource($intermediateTable, false); $this->databaseService->populateTableFromSource($intermediateTable, false);
} }
$this->recreateDiffView(); $this->recreateDiffView();
if ($this->useImportObserv) { if ($this->useImportObserv) {
......
...@@ -162,6 +162,7 @@ $lancable = $this->isAllowed(ImportPrivilege::getResourceId(ImportPrivilege::LAN ...@@ -162,6 +162,7 @@ $lancable = $this->isAllowed(ImportPrivilege::getResourceId(ImportPrivilege::LAN
$(function() { $(function() {
// `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket) // `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket)
let conn = $("#livelog-div").data('conn'); let conn = $("#livelog-div").data('conn');
if(conn === undefined){return;}
conn.addEventListener('open', function(e) { conn.addEventListener('open', function(e) {
$("#a-lancer-multiple").on('click', function(event) { $("#a-lancer-multiple").on('click', function(event) {
let trigger = $(this).addClass('disabled'); let trigger = $(this).addClass('disabled');
......
...@@ -72,6 +72,7 @@ $lancable = $this->isAllowed(ImportPrivilege::getResourceId(ImportPrivilege::LAN ...@@ -72,6 +72,7 @@ $lancable = $this->isAllowed(ImportPrivilege::getResourceId(ImportPrivilege::LAN
$(function() { $(function() {
// `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket) // `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket)
let conn = $("#livelog-div").data('conn'); let conn = $("#livelog-div").data('conn');
if(conn === undefined){return;}
conn.addEventListener('open', function(e) { conn.addEventListener('open', function(e) {
$("#lancer").on('click', function(event) { $("#lancer").on('click', function(event) {
let trigger = $(this).addClass('disabled'); let trigger = $(this).addClass('disabled');
......
...@@ -121,7 +121,7 @@ $synchroConsultable = $this->isAllowed(SynchroPrivilege::getResourceId(SynchroPr ...@@ -121,7 +121,7 @@ $synchroConsultable = $this->isAllowed(SynchroPrivilege::getResourceId(SynchroPr
<?php endif ?> <?php endif ?>
<?php echo $paginationControl = $this->paginationControl($importLogs, 'sliding', 'paginator.phtml', ['route' => 'unicaen-db-import/log']) ?> <?php echo $paginationControl = $this->paginationControl($importLogs, 'sliding', 'unicaen-db-import/paginator', ['route' => 'unicaen-db-import/log']) ?>
<?php echo $this->partial('unicaen-db-import/paginator'); ?> <?php echo $this->partial('unicaen-db-import/paginator'); ?>
......
...@@ -188,6 +188,7 @@ $lancable = $this->isAllowed(SynchroPrivilege::getResourceId(SynchroPrivilege::L ...@@ -188,6 +188,7 @@ $lancable = $this->isAllowed(SynchroPrivilege::getResourceId(SynchroPrivilege::L
$(function() { $(function() {
// `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket) // `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket)
let conn = $("#livelog-div").data('conn'); let conn = $("#livelog-div").data('conn');
if(conn === undefined){return;}
conn.addEventListener('open', function(e) { conn.addEventListener('open', function(e) {
$("#a-lancer-multiple").on('click', function(event) { $("#a-lancer-multiple").on('click', function(event) {
let trigger = $(this).addClass('disabled'); let trigger = $(this).addClass('disabled');
......
...@@ -86,6 +86,7 @@ $lancable = $this->isAllowed(SynchroPrivilege::getResourceId(SynchroPrivilege::L ...@@ -86,6 +86,7 @@ $lancable = $this->isAllowed(SynchroPrivilege::getResourceId(SynchroPrivilege::L
$(function() { $(function() {
// `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket) // `conn` est de type `WebSocket` (cf. https://developer.mozilla.org/fr/docs/Web/API/WebSocket)
let conn = $("#livelog-div").data('conn'); let conn = $("#livelog-div").data('conn');
if(conn === undefined){return;}
conn.addEventListener('open', function(e) { conn.addEventListener('open', function(e) {
$("#lancer").on('click', function(event) { $("#lancer").on('click', function(event) {
let trigger = $(this).addClass('disabled'); let trigger = $(this).addClass('disabled');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment