Skip to content
Snippets Groups Projects
Commit d311dd92 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Possibilité d'exécuter du SQL avant la mise à jour d'une table associée à un service.

parent 1d3a072c
Branches
Tags
No related merge requests found
<?php <?php
return [ return [
/**
* Eventuelles instructions SQL à exécuter avant la mise à jour d'une table de service.
*/
'services_pre_sql' => [
//'individu' => "begin DBMS_MVIEW.REFRESH('SYGAL_MV_EMAIL', 'C'); end;",
],
/**
* Connexion à la base de données.
*/
'doctrine' => [ 'doctrine' => [
'connection' => [ 'connection' => [
'orm_default' => [ 'orm_default' => [
...@@ -15,6 +24,9 @@ return [ ...@@ -15,6 +24,9 @@ return [
], ],
], ],
], ],
/**
* Config du mode d'authentification.
*/
'zf-mvc-auth' => [ 'zf-mvc-auth' => [
'authentication' => [ 'authentication' => [
'adapters' => [ 'adapters' => [
......
...@@ -6,17 +6,20 @@ ...@@ -6,17 +6,20 @@
-- Web Service d'import de données -- Web Service d'import de données
-- ------------------------------- -- -------------------------------
-- --
-- Vue matérialisée interrogeant Apogée et l'annuaire LDAP (grâce au package UCBN_LDAP) pour obtenir -- Vue matérialisée interrogeant Apogée et l'annuaire LDAP pour obtenir
-- les adresses électroniques. -- les adresses électroniques (grâce au package UCBN_LDAP).
--
-- NB : cette vue matérialisée est de type "refresh complete on demand", autrement dit est mise à jour manuellement
-- à l'aide de l'instruction PL/SQL `DBMS_MVIEW.REFRESH('SYGAL_MV_EMAIL', 'C')`.
-- --
-- drop materialized view SYGAL_MV_EMAIL -- drop materialized view SYGAL_MV_EMAIL
--/ --/
CREATE MATERIALIZED VIEW SYGAL_MV_EMAIL create materialized view UCBN_SODOCT.SYGAL_MV_EMAIL
refresh complete USING TRUSTED CONSTRAINTS refresh complete on demand using trusted constraints
START WITH SYSDATE NEXT SYSDATE + 1/24/6 as as
select sysdate as last_update, tmp.* select sysdate as last_update, tmp.*
from ( from (
select select
...@@ -33,7 +36,7 @@ START WITH SYSDATE NEXT SYSDATE + 1/24/6 as ...@@ -33,7 +36,7 @@ START WITH SYSDATE NEXT SYSDATE + 1/24/6 as
and dip.cod_tpd_etb in ('39', '40') and dip.cod_tpd_etb in ('39', '40')
and tpd.eta_ths_hdr_drt = 'T' -- Inscription en these and tpd.eta_ths_hdr_drt = 'T' -- Inscription en these
and tpd.tem_sante = 'N' -- Exclusion des theses d exercice and tpd.tem_sante = 'N' -- Exclusion des theses d exercice
and ind.cod_etu is not null -- oui, oui, ça arrive and ind.cod_etu is not null -- oui, oui, ça arrive
union union
select * select *
from ( from (
......
...@@ -22,6 +22,11 @@ class TableService ...@@ -22,6 +22,11 @@ class TableService
*/ */
private $servicesToEntityClassesConfig; private $servicesToEntityClassesConfig;
/**
* @var array
*/
private $servicesPreSql = [];
/** /**
* Liste des colonnes à exclure lors de la mise à jour des tables sources. * Liste des colonnes à exclure lors de la mise à jour des tables sources.
* *
...@@ -47,6 +52,14 @@ class TableService ...@@ -47,6 +52,14 @@ class TableService
$this->servicesToEntityClassesConfig = $servicesToEntityClassesConfig; $this->servicesToEntityClassesConfig = $servicesToEntityClassesConfig;
} }
/**
* @param array $servicesPreSql
*/
public function setServicesPreSql(array $servicesPreSql)
{
$this->servicesPreSql = $servicesPreSql;
}
/** /**
* Lance la mise à jour des tables sources. * Lance la mise à jour des tables sources.
* *
...@@ -122,14 +135,17 @@ class TableService ...@@ -122,14 +135,17 @@ class TableService
// exclusion éventuelle de certaines colonnes // exclusion éventuelle de certaines colonnes
$columnNames = array_diff($columnNames, $this->excludedColumnNames); $columnNames = array_diff($columnNames, $this->excludedColumnNames);
// SQL à exécuter au préalable ?
if (isset($this->servicesPreSql[$service])) {
$sqlParts[] = $this->servicesPreSql[$service];
}
$sqlParts[] = sprintf($deleteTemplate, $tableName); $sqlParts[] = sprintf($deleteTemplate, $tableName);
$sqlParts[] = sprintf($updateTemplate, $tableName, $cols = implode(', ', $columnNames), $cols, $tableName); $sqlParts[] = sprintf($updateTemplate, $tableName, $cols = implode(', ', $columnNames), $cols, $tableName);
} }
$sqlParts[] = 'end;'; $sqlParts[] = 'end;';
$sql = implode(PHP_EOL, $sqlParts); return implode(PHP_EOL, $sqlParts);
return $sql;
} }
/** /**
......
...@@ -15,10 +15,12 @@ class TableServiceFactory ...@@ -15,10 +15,12 @@ class TableServiceFactory
/** @var array $config */ /** @var array $config */
$config = $container->get('config'); $config = $container->get('config');
$servicesToEntityClassesConfig = $config['services_to_entity_classes']; $servicesToEntityClassesConfig = $config['services_to_entity_classes'];
$servicesPreSql = $config['services_pre_sql'] ?? [];
$service = new TableService(); $service = new TableService();
$service->setEntityManager($entityManager); $service->setEntityManager($entityManager);
$service->setServicesToEntityClassesConfig($servicesToEntityClassesConfig); $service->setServicesToEntityClassesConfig($servicesToEntityClassesConfig);
$service->setServicesPreSql($servicesPreSql);
return $service; return $service;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment