Commit 09400cc7 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Merge branch 'feature_pre_sql' into release-1.3.4

parents 1d3a072c d311dd92
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
<?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' => [
+91 −88
Original line number Diff line number Diff line
@@ -6,17 +6,20 @@
-- 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
create materialized view UCBN_SODOCT.SYGAL_MV_EMAIL
    refresh complete on demand using trusted constraints
as
select sysdate as last_update, tmp.*
from (
         select
@@ -33,7 +36,7 @@ START WITH SYSDATE NEXT SYSDATE + 1/24/6 as
           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 ind.cod_etu is not null         -- oui, oui, ça arrive
         union
         select *
         from (
+19 −3
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -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;
    }