Commit ea5f0e63 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Merge branch 'actul' of https://git.unicaen.fr/open-source/OSE

 Conflicts:
	composer.lock
parents 69246678 5e3b008e
......@@ -4,10 +4,10 @@ $dirname = $oa->getOseDir() . 'data/ddl';
$colPosFile = $oa->getOseDir() . 'data/ddl_columns_pos.php';
$filters = [
'table' => ['excludes' => ['UNICAEN_%', 'SYS_EXPORT_SCHEMA_%']],
'sequence' => ['excludes' => 'UNICAEN_%'],
'primary-constraint' => ['excludes' => 'UNICAEN_%'],
'index' => ['excludes' => 'UNICAEN_%'],
'table' => ['excludes' => ['UNICAEN_%', 'SYS_EXPORT_SCHEMA_%', 'ACT_%']],
'sequence' => ['excludes' => ['UNICAEN_%']],
'primary-constraint' => ['excludes' => ['UNICAEN_%', 'ACT_%']],
'index' => ['excludes' => ['UNICAEN_%', 'ACT_%']],
'view' => ['excludes' => ['SRC_%', 'V_DIFF_%', 'V_SYMPA_%', 'V_UNICAEN_%']],
'materialized-view' => ['includes' => [
'MV_EXT_SERVICE',
......@@ -15,7 +15,7 @@ $filters = [
'MV_EXT_ETAT_PAIEMENT',
'TBL_NOEUD',
]],
'package' => ['excludes' => ['UCBN_LDAP', 'UNICAEN_IMPORT_AUTOGEN_PROCS__']],
'package' => ['excludes' => ['UCBN_LDAP', 'UNICAEN_IMPORT_AUTOGEN_PROCS__', 'OSE_ACTUL']],
];
......
<?php
use BddAdmin\Ddl\Ddl;
$c->begin("\nInstallation ou mise à jour du connecteur ACTUL+");
$c->println('Création de la source de données Actul+ si besoin');
$sql = "BEGIN
unicaen_import.add_source('Actul', 'Actul +');
commit;
END;";
$oa->getBdd()->exec($sql);
// Récupération du schéma de référence
$c->println('Mise en place des structures de données');
$ca = new ConnecteurActul();
$ca->init();
$ddl = $ca->getDdl();
// On ne touche pas à autre chose que la partie ACTUL!!
$filters = $ddl->filterOnlyDdl();
// Mise à jour de la BDD (structures)
$oa->getBdd()->alter($ddl, $filters);
$c->end('Connecteur installé');
$c->println('Le connecteur Actul+ vers OSE est installé. Il vous reste à mettre en place par vous-même les vues sources et à les activer.');
\ No newline at end of file
<?php
$ca = new ConnecteurActul;
$ca->init();
$c->begin('Mise à jour de OSE à partir des données d\'Actul +');
$at = $ca->getActTables();
$c->println('');
$c->begin('Transfert des données depuis Actul');
foreach ($at as $table) {
$c->print('Table ' . $table . '... ');
$ca->majActTable($table);
$c->println('OK');
}
$c->end('Transfert terminé');
$st = $ca->getSyncTables();
$c->println('');
$c->begin('Synchronisation des données vers OSE');
foreach ($st as $table) {
$c->print('Table ' . $table . '... ');
$ca->syncTable($table);
$c->println('OK');
}
$c->end('Synchronisation terminée');
$c->begin('Mise à jour des caches de données');
$c->print('Vue matérialisée TBL_NOEUD ... ');
$ca->ose->exec('BEGIN UNICAEN_IMPORT.REFRESH_MV(\'TBL_NOEUD\'); END;');
$c->println('OK');
$c->print('Calcul de tous les effectifs ... ');
$ca->ose->exec('BEGIN OSE_CHARGENS.CALC_ALL_EFFECTIFS(); END;');
$c->println('OK');
$c->print('Tableau de bord des charges ... ');
$ca->ose->exec('BEGIN UNICAEN_TBL.CALCULER(\'chargens\'); END;');
$c->println('OK');
$c->end('Caches à jour');
$c->end('Ose est maintenant à jour');
\ No newline at end of file
<?php
$ca = new ConnecteurActul();
$filters = [
'explicit' => true,
'table' => ['includes' => $ca->getActTables()],
'primary-constraint' => ['includes' => '%'],
'package' => ['includes' => 'OSE_ACTUL'],
];
$c->begin('Génération de la DDL du connecteur ACTUL+ à partir de la base de données');
$ddl = $oa->getBdd()->getDdl($filters);
/* On retire toutes les clés étrangères qui n'ont rien à voir avec ACTUL+ */
$pc = $ddl->get('primary-constraint');
foreach ($pc as $n => $d) {
if (!in_array($d['table'], $tables)) {
unset($pc[$n]);
}
}
$ddl->set('primary-constraint', $pc);
$ddl->saveToDir($ca->getDdlDir());
$c->end('DDL ACTUL+ mise à jour');
\ No newline at end of file
CREATE OR REPLACE PACKAGE BODY OSE_ACTUL AS
FUNCTION z_to_code ( z_periode_id_semestre VARCHAR2, z_periode_id_ordre NUMERIC ) RETURN VARCHAR2 IS
pcode VARCHAR2(2);
BEGIN
pcode := CASE
WHEN z_periode_id_semestre = '1' AND z_periode_id_ordre < 2 THEN 'S1'
WHEN z_periode_id_semestre = '1' AND z_periode_id_ordre = 2 THEN 'S2'
WHEN z_periode_id_semestre = '3' AND z_periode_id_ordre < 2 THEN 'S1'
WHEN z_periode_id_semestre = '3' AND z_periode_id_ordre = 2 THEN 'S2'
WHEN z_periode_id_semestre = '5' AND z_periode_id_ordre < 2 THEN 'S1'
WHEN z_periode_id_semestre = '5' AND z_periode_id_ordre = 2 THEN 'S2'
WHEN z_periode_id_semestre = '2' THEN 'S2'
WHEN z_periode_id_semestre = '4' THEN 'S2'
WHEN z_periode_id_semestre = '6' THEN 'S2'
ELSE NULL
END;
RETURN pcode;
END;
FUNCTION CALC_SEMESTRE( NOEUD_SOURCE_CODE VARCHAR2, z_periode_id_semestre VARCHAR2, z_periode_id_ordre NUMERIC ) RETURN VARCHAR2 IS
pcode VARCHAR2(2);
p_sup VARCHAR2(2);
is_s1_sup BOOLEAN DEFAULT FALSE;
is_s2_sup BOOLEAN DEFAULT FALSE;
is_an_sup BOOLEAN DEFAULT FALSE;
BEGIN
IF z_periode_id_semestre IS NOT NULL THEN
-- si il est fourni, alors on le convertir en code de période et on le retourne
RETURN z_to_code(z_periode_id_semestre, z_periode_id_ordre);
END IF;
-- sinon on recherche un éventuel semestre dans ses noeuds parents
FOR t IN (
SELECT
n.source_code, n.z_periode_id_semestre, n.z_periode_id_ordre
FROM
act_lien l
JOIN act_noeud n ON n.source_code = l.z_noeud_sup_id
WHERE
l.z_noeud_inf_id = NOEUD_SOURCE_CODE
) LOOP
p_sup := CALC_SEMESTRE(t.source_code, t.z_periode_id_semestre, t.z_periode_id_ordre);
IF p_sup = 'S1' THEN
is_s1_sup := TRUE;
END IF;
IF p_sup = 'S2' THEN
is_s2_sup := TRUE;
END IF;
IF p_sup IS NULL THEN
is_an_sup := TRUE;
END IF;
END LOOP;
IF is_s1_sup AND NOT is_s2_sup AND NOT is_an_sup THEN
RETURN 'S1';
END IF;
IF NOT is_s1_sup AND is_s2_sup AND NOT is_an_sup THEN
RETURN 'S2';
END IF;
RETURN NULL;
END;
END OSE_ACTUL;
\ No newline at end of file
CREATE OR REPLACE PACKAGE OSE_ACTUL AS
FUNCTION CALC_SEMESTRE( NOEUD_SOURCE_CODE VARCHAR2, z_periode_id_semestre VARCHAR2, z_periode_id_ordre NUMERIC ) RETURN VARCHAR2;
END OSE_ACTUL;
\ No newline at end of file
<?php
//@formatter:off
return [
'name' => 'ACT_ETAPE_PK',
'table' => 'ACT_ETAPE',
'index' => 'ACT_ETAPE_PK',
'columns' => [
'ANNEE_ID',
'SOURCE_CODE',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_LIEN_PK',
'table' => 'ACT_LIEN',
'index' => 'ACT_LIEN_PK',
'columns' => [
'Z_NOEUD_SUP_ID',
'Z_NOEUD_INF_ID',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_NOEUD_PK',
'table' => 'ACT_NOEUD',
'index' => 'ACT_NOEUD_PK',
'columns' => [
'SOURCE_CODE',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_VHENS_GROUPES_PK',
'table' => 'ACT_VHENS_GROUPES',
'index' => 'ACT_VHENS_GROUPES_PK',
'columns' => [
'Z_ELEMENT_PEDAGOGIQUE_ID',
'Z_TYPE_INTERVENTION_ID',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_VHENS_HEURES_PK',
'table' => 'ACT_VHENS_HEURES',
'index' => 'ACT_VHENS_HEURES_PK',
'columns' => [
'Z_ELEMENT_PEDAGOGIQUE_ID',
'Z_TYPE_INTERVENTION_ID',
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_ETAPE',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'ANNEE_ID' => [
'name' => 'ANNEE_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 9,
'commentaire' => NULL,
],
'CODE' => [
'name' => 'CODE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 50,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 10,
'commentaire' => NULL,
],
'EFFECTIF' => [
'name' => 'EFFECTIF',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 14,
'commentaire' => NULL,
],
'FA' => [
'name' => 'FA',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 12,
'commentaire' => NULL,
],
'FC' => [
'name' => 'FC',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 13,
'commentaire' => NULL,
],
'FI' => [
'name' => 'FI',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 11,
'commentaire' => NULL,
],
'LIBELLE' => [
'name' => 'LIBELLE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 200,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
'NIVEAU' => [
'name' => 'NIVEAU',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'SOURCE_CODE' => [
'name' => 'SOURCE_CODE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 7,
'commentaire' => NULL,
],
'SPECIFIQUE_ECHANGES' => [
'name' => 'SPECIFIQUE_ECHANGES',
'type' => 'bool',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => 1,
'nullable' => FALSE,
'default' => '0',
'position' => 4,
'commentaire' => NULL,
],
'Z_DOMAINE_FONCTIONNEL_ID' => [
'name' => 'Z_DOMAINE_FONCTIONNEL_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 8,
'commentaire' => NULL,
],
'Z_SOURCE_ID' => [
'name' => 'Z_SOURCE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 6,
'commentaire' => NULL,
],
'Z_STRUCTURE_ID' => [
'name' => 'Z_STRUCTURE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 5,
'commentaire' => NULL,
],
'Z_TYPE_FORMATION_ID' => [
'name' => 'Z_TYPE_FORMATION_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_LIEN',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'CHOIX_MAXIMUM' => [
'name' => 'CHOIX_MAXIMUM',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 4,
'commentaire' => NULL,
],
'CHOIX_MINIMUM' => [
'name' => 'CHOIX_MINIMUM',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => NULL,
'precision' => NULL,
'nullable' => TRUE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'Z_NOEUD_INF_ID' => [
'name' => 'Z_NOEUD_INF_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
'Z_NOEUD_SUP_ID' => [
'name' => 'Z_NOEUD_SUP_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
'Z_SOURCE_ID' => [
'name' => 'Z_SOURCE_ID',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 100,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 5,
'commentaire' => NULL,
],
],
];
//@formatter:on
<?php
//@formatter:off
return [
'name' => 'ACT_NOEUD',
'temporary' => FALSE,
'logging' => TRUE,
'commentaire' => NULL,
'sequence' => NULL,
'columns' => [
'ANNEE_ID' => [
'name' => 'ANNEE_ID',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => '0',
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 3,
'commentaire' => NULL,
],
'CODE' => [
'name' => 'CODE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 50,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 1,
'commentaire' => NULL,
],
'LIBELLE' => [
'name' => 'LIBELLE',
'type' => 'string',
'bdd-type' => 'VARCHAR2',
'length' => 200,
'scale' => NULL,
'precision' => NULL,
'nullable' => FALSE,
'default' => NULL,
'position' => 2,
'commentaire' => NULL,
],
'ORDRE' => [
'name' => 'ORDRE',
'type' => 'int',
'bdd-type' => 'NUMBER',
'length' => 0,
'scale' => NULL,
'precision' => NULL,