diff --git a/CHANGELOG.md b/CHANGELOG.md index 75c900bc5068eea11de984169584314b6561ced2..b889f133478bf7fec7be2de996e52ab7c931a22d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,13 @@ Journal des modifications ========================= +1.3.4 (06/07/2020) +------------------ + +- Possibilité d'exécuter du SQL avant la mise à jour d'une table associée à un service. + Exemple : mise à jour de la vue matérialisée SYGAL_MV_EMAIL interrogée par la vue V_SYGAL_INDIVIDU avant que la table + SYGAL_INDIVIDU soit peuplée à partir de V_SYGAL_INDIVIDU. + 1.3.3 (11/03/2020) ------------------ diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist index b6f8ab6d4a1dd82741d53322f59b72825a4b1619..f1f9b327638faa882f3ade716ce115378cdf8809 100644 --- a/config/autoload/local.php.dist +++ b/config/autoload/local.php.dist @@ -1,5 +1,14 @@ <?php 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' => [ 'connection' => [ 'orm_default' => [ @@ -15,6 +24,9 @@ return [ ], ], ], + /** + * Config du mode d'authentification. + */ 'zf-mvc-auth' => [ 'authentication' => [ 'adapters' => [ diff --git a/config/autoload/version.global.php b/config/autoload/version.global.php index 522dddc4d9b849b0474ba6ebdce6437a6413d2c5..48879d244a52cead3cc0326c94876dcc218523c4 100644 --- a/config/autoload/version.global.php +++ b/config/autoload/version.global.php @@ -2,9 +2,9 @@ return [ 'unicaen-app' => [ 'app_infos' => [ - 'version' => '1.3.3', - 'date' => '11/03/2020', + 'version' => '1.3.4', + 'date' => '06/07/2020', ], ], - 'comment' => 'Fichier généré le 11/03/2020 à 14:05:58 avec /home/gauthierb/workspace/sygal-import-ws/bump-version', + 'comment' => 'Fichier généré le 06/07/2020 à 14:42:53 avec /app/bump-version', ]; diff --git a/dist/SQL/apogee/annexe-emails.sql b/dist/SQL/apogee/annexe-emails.sql index 7874e9552fd84a3b67212ea6260795e2ba91afa9..a54c29c5e01311291731dc6baed0b937e22d0c35 100644 --- a/dist/SQL/apogee/annexe-emails.sql +++ b/dist/SQL/apogee/annexe-emails.sql @@ -6,104 +6,107 @@ -- 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 --- les adresses électroniques. +-- Vue matérialisée interrogeant Apogée et l'annuaire LDAP pour obtenir +-- 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 --/ -CREATE MATERIALIZED VIEW SYGAL_MV_EMAIL -refresh complete USING TRUSTED CONSTRAINTS -START WITH SYSDATE NEXT SYSDATE + 1/24/6 as - select sysdate as last_update, tmp.* - from ( +create materialized view UCBN_SODOCT.SYGAL_MV_EMAIL + refresh complete on demand using trusted constraints +as +select sysdate as last_update, tmp.* +from ( select - -- doctorants - to_char(ind.cod_etu) as id, - -- Numero etudiant - ucbn_ldap.etu2mail(ind.cod_etu) as email -- Mail etudiant + -- doctorants + to_char(ind.cod_etu) as id, + -- Numero etudiant + ucbn_ldap.etu2mail(ind.cod_etu) as email -- Mail etudiant from these_hdr_sout ths - join diplome dip on dip.cod_dip = ths.cod_dip - join typ_diplome tpd on tpd.cod_tpd_etb = dip.cod_tpd_etb - join individu ind - on ind.cod_ind = ths.cod_ind --and ind.cod_etu != 21009539 -- Exclusion du compte de test Aaron AAABA + join diplome dip on dip.cod_dip = ths.cod_dip + join typ_diplome tpd on tpd.cod_tpd_etb = dip.cod_tpd_etb + join individu ind + on ind.cod_ind = ths.cod_ind --and ind.cod_etu != 21009539 -- Exclusion du compte de test Aaron AAABA where ths.cod_ths_trv = '1' -- Exclusion des travaux - and dip.cod_tpd_etb in ('39', '40') - and tpd.eta_ths_hdr_drt = 'T' -- Inscription en these - and tpd.tem_sante = 'N' -- Exclusion des theses d exercice - and ind.cod_etu is not null -- oui, oui, ça arrive + and dip.cod_tpd_etb in ('39', '40') + and tpd.eta_ths_hdr_drt = 'T' -- Inscription en these + and tpd.tem_sante = 'N' -- Exclusion des theses d exercice + and ind.cod_etu is not null -- oui, oui, ça arrive union select * from ( - -- acteurs - with acteur as ( - select - ths.cod_ths, - 'D' as cod_roj, - ths.cod_per_dir as cod_per, - ths.cod_etb_dir as cod_etb, - ths.cod_cps_dir as cod_cps, - null as tem_rap_recu, - null as cod_roj_compl - from these_hdr_sout ths - where ths.cod_ths_trv = '1' and ths.cod_per_dir is not null - union - select - ths.cod_ths, - 'D' as cod_roj, - ths.cod_per_cdr as cod_per, - ths.cod_etb_cdr as cod_etb, - ths.cod_cps_cdr as cod_cps, - null as tem_rap_recu, - null as cod_roj_compl - from these_hdr_sout ths - where ths.cod_ths_trv = '1' and ths.cod_per_cdr is not null - union - select - ths.cod_ths, - 'D' as cod_roj, - ths.cod_per_cdr2 as cod_per, - ths.cod_etb_cdr2 as cod_etb, - ths.cod_cps_cdr2 as cod_cps, - null as tem_rap_recu, - null as cod_roj_compl - from these_hdr_sout ths - where ths.cod_ths_trv = '1' and ths.cod_per_cdr2 is not null - union - select - trs.cod_ths, - 'R' as cod_roj, - trs.cod_per, - null as cod_etb, - null as cod_cps, - trs.tem_rap_recu, - null as cod_roj_compl - from ths_rap_sou trs - union - select - tjp.cod_ths, - 'M' as cod_roj, - tjp.cod_per, - tjp.cod_etb, - tjp.cod_cps, - null as tem_rap_recu, - case when tjp.cod_roj in ('P', 'B', 'A') - then tjp.cod_roj - else null end as cod_roj_compl - from ths_jur_per tjp - ) - select distinct - coalesce(regexp_replace(per.num_dos_har_per, '[^0-9]', ''), 'COD_PER_' || act.cod_per) as id, - -- Code Harpege ou Apogee de l acteur - case when per.num_dos_har_per is null - then null - else ucbn_ldap.uid2mail('p' || per.num_dos_har_per) end as email -- Mail acteur - from acteur act - join role_jury roj on roj.cod_roj = act.cod_roj - join personnel per on per.cod_per = act.cod_per - ) - ) tmp - where email is not null + -- acteurs + with acteur as ( + select + ths.cod_ths, + 'D' as cod_roj, + ths.cod_per_dir as cod_per, + ths.cod_etb_dir as cod_etb, + ths.cod_cps_dir as cod_cps, + null as tem_rap_recu, + null as cod_roj_compl + from these_hdr_sout ths + where ths.cod_ths_trv = '1' and ths.cod_per_dir is not null + union + select + ths.cod_ths, + 'D' as cod_roj, + ths.cod_per_cdr as cod_per, + ths.cod_etb_cdr as cod_etb, + ths.cod_cps_cdr as cod_cps, + null as tem_rap_recu, + null as cod_roj_compl + from these_hdr_sout ths + where ths.cod_ths_trv = '1' and ths.cod_per_cdr is not null + union + select + ths.cod_ths, + 'D' as cod_roj, + ths.cod_per_cdr2 as cod_per, + ths.cod_etb_cdr2 as cod_etb, + ths.cod_cps_cdr2 as cod_cps, + null as tem_rap_recu, + null as cod_roj_compl + from these_hdr_sout ths + where ths.cod_ths_trv = '1' and ths.cod_per_cdr2 is not null + union + select + trs.cod_ths, + 'R' as cod_roj, + trs.cod_per, + null as cod_etb, + null as cod_cps, + trs.tem_rap_recu, + null as cod_roj_compl + from ths_rap_sou trs + union + select + tjp.cod_ths, + 'M' as cod_roj, + tjp.cod_per, + tjp.cod_etb, + tjp.cod_cps, + null as tem_rap_recu, + case when tjp.cod_roj in ('P', 'B', 'A') + then tjp.cod_roj + else null end as cod_roj_compl + from ths_jur_per tjp + ) + select distinct + coalesce(regexp_replace(per.num_dos_har_per, '[^0-9]', ''), 'COD_PER_' || act.cod_per) as id, + -- Code Harpege ou Apogee de l acteur + case when per.num_dos_har_per is null + then null + else ucbn_ldap.uid2mail('p' || per.num_dos_har_per) end as email -- Mail acteur + from acteur act + join role_jury roj on roj.cod_roj = act.cod_roj + join personnel per on per.cod_per = act.cod_per + ) + ) tmp +where email is not null / \ No newline at end of file diff --git a/doc/release-notes/v1.3.4.md b/doc/release-notes/v1.3.4.md new file mode 100644 index 0000000000000000000000000000000000000000..f35ee163195fb648f8bd38599a704ec922a9a9b9 --- /dev/null +++ b/doc/release-notes/v1.3.4.md @@ -0,0 +1,21 @@ +Version 1.3.4 +============= + +Sources PHP +----------- + +Sur le serveur, placez-vous dans le répertoire du web service (sans doute `/var/www/sygal-import-ws`) +puis lancez les commandes suivantes pour installer la nouvelle version : +```bash +git fetch && git fetch --tags && git checkout --force 1.3.4 && bash install.sh +``` + +Selon le moteur PHP que vous avez installé, rechargez le service, exemple : + - php7.0-fpm : `service php7.0-fpm reload` + - apache2-mod-php7.0 : `service apache2 reload` + + +Base de données +--------------- + +Nada. diff --git a/module/Application/src/Service/TableService.php b/module/Application/src/Service/TableService.php index 65d9cf273eda82919a1bd3627b1731b41c7139c5..1d96432460046103181cf1d46386dad71fd91d80 100644 --- a/module/Application/src/Service/TableService.php +++ b/module/Application/src/Service/TableService.php @@ -22,6 +22,11 @@ class TableService */ private $servicesToEntityClassesConfig; + /** + * @var array + */ + private $servicesPreSql = []; + /** * Liste des colonnes à exclure lors de la mise à jour des tables sources. * @@ -47,6 +52,14 @@ class TableService $this->servicesToEntityClassesConfig = $servicesToEntityClassesConfig; } + /** + * @param array $servicesPreSql + */ + public function setServicesPreSql(array $servicesPreSql) + { + $this->servicesPreSql = $servicesPreSql; + } + /** * Lance la mise à jour des tables sources. * @@ -122,14 +135,17 @@ class TableService // exclusion éventuelle de certaines colonnes $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($updateTemplate, $tableName, $cols = implode(', ', $columnNames), $cols, $tableName); } $sqlParts[] = 'end;'; - $sql = implode(PHP_EOL, $sqlParts); - - return $sql; + return implode(PHP_EOL, $sqlParts); } /** diff --git a/module/Application/src/Service/TableServiceFactory.php b/module/Application/src/Service/TableServiceFactory.php index e06a24f77cc7e1300e23455e2f9e74461068c446..8a48a6c1e194202c3eb674abad503ed39b3aaa46 100644 --- a/module/Application/src/Service/TableServiceFactory.php +++ b/module/Application/src/Service/TableServiceFactory.php @@ -15,10 +15,12 @@ class TableServiceFactory /** @var array $config */ $config = $container->get('config'); $servicesToEntityClassesConfig = $config['services_to_entity_classes']; + $servicesPreSql = $config['services_pre_sql'] ?? []; $service = new TableService(); $service->setEntityManager($entityManager); $service->setServicesToEntityClassesConfig($servicesToEntityClassesConfig); + $service->setServicesPreSql($servicesPreSql); return $service; }