Commit 0ad603f2 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Flux autorisation d'inscription / de diplomation : envoi vers le bon Pégase,...

Flux autorisation d'inscription / de diplomation : envoi vers le bon Pégase, i.e. celui de l'établissement d'inscription.
parent 325251b9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@
        "unicaen/api": "dev-master",
        "unicaen/app": "^6.4",
        "unicaen/auth-token": "^7.1",
        "unicaen/authentification": "^6.4",
        "unicaen/authentification": "dev-release_6.5.0 as 6.4.8",
        "unicaen/privilege": "^6.4",
        "unicaen/console": "^6.0",
        "unicaen/db-anonym": "^4.0",
+19 −9
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
        "This file is @generated automatically"
    ],
    "content-hash": "4ee2abbe11d89f502ef6231c6ac8f9fc",
    "content-hash": "573f5323c45ceb6b6ff07173ff8ceabc",
    "packages": [
        {
            "name": "apereo/phpcas",
@@ -12445,7 +12445,7 @@
            "source": {
                "type": "git",
                "url": "https://git.unicaen.fr/lib/unicaen/api.git",
                "reference": "c6de84367846fd5d44cecb521673a96b8f03d1e8"
                "reference": "f931ff756e99fa1303a5907b9a2ce1a6d2724141"
            },
            "require": {
                "eljam/guzzle-jwt-middleware": "dev-main",
@@ -12463,6 +12463,7 @@
                "psr/container": "^1.0",
                "webmozart/assert": "^1.3"
            },
            "default-branch": true,
            "type": "library",
            "autoload": {
                "psr-4": {
@@ -12473,7 +12474,7 @@
                ]
            },
            "description": "Module Unicaen regroupant des choses utiles pour l'appel d'API Rest ou Soap",
            "time": "2025-10-30T16:23:18+00:00"
            "time": "2026-06-04T07:16:39+00:00"
        },
        {
            "name": "unicaen/app",
@@ -12565,11 +12566,11 @@
        },
        {
            "name": "unicaen/authentification",
            "version": "6.4.8",
            "version": "dev-release_6.5.0",
            "source": {
                "type": "git",
                "url": "https://git.unicaen.fr/lib/unicaen/authentification.git",
                "reference": "e2c4a50a20911e5e9e7b967e508dff64afdf19ea"
                "reference": "901dc97991813f09ffbf8902e42a70fc6e825359"
            },
            "require": {
                "apereo/phpcas": "1.6.*",
@@ -12592,7 +12593,7 @@
                ]
            },
            "description": "Module d'authentification pour les applications Unicaen - Version Laminas",
            "time": "2025-12-05T16:18:53+00:00"
            "time": "2026-06-01T15:52:15+00:00"
        },
        {
            "name": "unicaen/avis",
@@ -13162,12 +13163,13 @@
            "source": {
                "type": "git",
                "url": "https://git.unicaen.fr/lib/unicaen/pegase-coc-ext-api.git",
                "reference": "2e933d92d67e69c45108db3772cece5d1a1b6bb8"
                "reference": "dadb40009c187be74961ea57f7769b21098c3ef1"
            },
            "require": {
                "php": "^8.0",
                "unicaen/api": "dev-master"
            },
            "default-branch": true,
            "type": "library",
            "autoload": {
                "psr-4": {
@@ -13181,7 +13183,7 @@
                ]
            },
            "description": "Appel d'API Pégase",
            "time": "2025-10-30T08:09:34+00:00"
            "time": "2026-06-04T07:15:53+00:00"
        },
        {
            "name": "unicaen/privilege",
@@ -16351,11 +16353,19 @@
            "time": "2025-03-24T14:11:06+00:00"
        }
    ],
    "aliases": [],
    "aliases": [
        {
            "package": "unicaen/authentification",
            "version": "dev-release_6.5.0",
            "alias": "6.4.8",
            "alias_normalized": "6.4.8.0"
        }
    ],
    "minimum-stability": "dev",
    "stability-flags": {
        "eljam/guzzle-jwt-middleware": 20,
        "unicaen/api": 20,
        "unicaen/authentification": 20,
        "unicaen/db-import": 20,
        "unicaen/pegase-coc-ext-api": 20,
        "unicaen/sygal-api": 20,
+11 −1
Original line number Diff line number Diff line
Connecteur Pégase-SyGAL
=======================

<!-- TOC -->
* [Connecteur Pégase-SyGAL](#connecteur-pégase-sygal)
  * [Flux Autorisation de diplomation (SyGAL => Pégase)](#flux-autorisation-de-diplomation-sygal--pégase)
    * [Configuration](#configuration)
    * [Envoi d'une Autorisation de diplomation de test vers Pégase en ligne de commande](#envoi-dune-autorisation-de-diplomation-de-test-vers-pégase-en-ligne-de-commande)
    * [Envoi d'une Autorisation de diplomation vers Pégase](#envoi-dune-autorisation-de-diplomation-vers-pégase)
<!-- TOC -->


Flux Autorisation de diplomation (SyGAL => Pégase)
--------------------------------------------------

@@ -8,7 +17,8 @@ Flux Autorisation de diplomation (SyGAL => Pégase)

- SyGAL

Idem "Flux Autorisation d'inscription (SyGAL => Pégase)".
Idem "Flux Autorisation d'inscription (SyGAL => Pégase)", 
cf. ([flux_autorisation_inscription.md](../../AutorisationInscriptionThese/doc/flux_autorisation_inscription.md)).

- Pégase

+24 −24
Original line number Diff line number Diff line
@@ -11,26 +11,26 @@ where autorisation_diplomation_these_tx_data_id in (select id
                                                    from autorisation_diplomation_these_tx_data
                                                    where autorisation_diplomation_these_id in (select id
                                                                                                from autorisation_diplomation_these
                                                                                                where these_id = (select id from these where source_code like 'DIPLOMC::%')));
                                                                                                where these_id = (select id from these where source_code like 'DIPLOMD::%')));
delete
from autorisation_diplomation_these_tx_data
where autorisation_diplomation_these_id in (select id
                                            from autorisation_diplomation_these
                                            where these_id = (select id from these where source_code like 'DIPLOMC::%'));
                                            where these_id = (select id from these where source_code like 'DIPLOMD::%'));
delete
from autorisation_diplomation_these
where these_id = (select id from these where source_code like 'DIPLOMC::%');
where these_id = (select id from these where source_code like 'DIPLOMD::%');

delete from rapport where these_id in (select id from these where source_code like 'DIPLOMC::%');
delete from fichier where uuid like 'DIPLOMC::%';
delete from rapport where these_id in (select id from these where source_code like 'DIPLOMD::%');
delete from fichier where uuid like 'DIPLOMD::%';

delete from acteur_these where source_code like 'DIPLOMC::%';
delete from acteur_these where source_code like 'DIPLOMD::%';

delete from these_annee_univ where source_code like 'DIPLOMC::%';
delete from these where source_code like 'DIPLOMC::%';
delete from doctorant where source_code like 'DIPLOMC::%';
delete from these_annee_univ where source_code like 'DIPLOMD::%';
delete from these where source_code like 'DIPLOMD::%';
delete from doctorant where source_code like 'DIPLOMD::%';

delete from individu where source_code like 'DIPLOMC::%';
delete from individu where source_code like 'DIPLOMD::%';
*/

INSERT INTO individu (id, type, civilite, nom_usuel, nom_patronymique, prenom1, prenom2, prenom3, email,
@@ -38,9 +38,9 @@ INSERT INTO individu (id, type, civilite, nom_usuel, nom_patronymique, prenom1,
                      supann_id, pays_id_nationalite, id_ref, npd_force, est_substituant_modifiable,
                      synchro_undelete_enabled, synchro_update_on_deleted_enabled, apatride, pays_naissance_id,
                      orcid, id_hal)
VALUES (nextval('individu_id_seq'), 'doctorant', 'Mme', 'DIPLOMC', 'DIPLOMC', 'Paule', 'Bernadette', null,
VALUES (nextval('individu_id_seq'), 'doctorant', 'Mme', 'DIPLOMD', 'DIPLOMD', 'Paule', 'Bernadette', null,
        'paule.hochon@mail.fr',
        '1988-03-04 00:00:00.000000', 'FRANCAIS(E)', 'DIPLOMC::053386367CC', 1, 1, current_timestamp,
        '1988-03-04 00:00:00.000000', 'FRANCAIS(E)', 'DIPLOMD::053386367CC', 1, 1, current_timestamp,
        '22313702', 79, null, null, true, true, false,
        false, null, null, null);

@@ -48,7 +48,7 @@ INSERT INTO doctorant (id, etablissement_id, individu_id, source_code, source_id
                       histo_creation, ine, source_code_sav,
                       code_apprenant_in_source, npd_force,
                       est_substituant_modifiable, synchro_undelete_enabled, synchro_update_on_deleted_enabled)
VALUES (nextval('doctorant_id_seq'), 2, currval('individu_id_seq'), 'DIPLOMC::053386367CC', 1, 1, current_timestamp,
VALUES (nextval('doctorant_id_seq'), 2, currval('individu_id_seq'), 'DIPLOMD::053386367CC', 1, 1, current_timestamp,
        '053386367CC', null, null, null, true, true, false);

INSERT INTO these (id, etablissement_id, doctorant_id, ecole_doct_id, unite_rech_id, correc_autorisee,
@@ -61,8 +61,8 @@ INSERT INTO these (id, etablissement_id, doctorant_id, ecole_doct_id, unite_rech
                   resaisir_attestations_depot_version_corrigee)
select nextval('these_id_seq'), 2, currval('doctorant_id_seq'), 86, 841, null, null, null, '2025-05-24', 'E', null, null, 1,
        null, 'N',
        'THESE DIPLOMC',
        'DIPLOMC::053386367CC', 1, 1, current_timestamp, null, null, null,
        'THESE DIPLOMD',
        'DIPLOMD::053386367CC', 1, 1, current_timestamp, null, null, null,
        'N', null, '4200031', null, null, 31, null, null
returning id;

@@ -70,10 +70,10 @@ returning id;

insert into these_annee_univ(id, source_code, source_id, these_id, annee_univ, histo_createur_id,
                             est_1ere_annee_inscription)
values (nextval('these_annee_univ_id_seq'), 'DIPLOMC::053386367CC::2024', 1, currval('these_id_seq'), 2024, 1, false);
values (nextval('these_annee_univ_id_seq'), 'DIPLOMD::053386367CC::2024', 1, currval('these_id_seq'), 2024, 1, false);
insert into these_annee_univ(id, source_code, source_id, these_id, annee_univ, histo_createur_id,
                             est_1ere_annee_inscription)
values (nextval('these_annee_univ_id_seq'), 'DIPLOMC::053386367CC::2025', 1, currval('these_id_seq'), 2025, 1, false);
values (nextval('these_annee_univ_id_seq'), 'DIPLOMD::053386367CC::2025', 1, currval('these_id_seq'), 2025, 1, false);

------------

@@ -84,7 +84,7 @@ INSERT INTO individu (id, type, civilite, nom_usuel, nom_patronymique, prenom1,
                             synchro_undelete_enabled, synchro_update_on_deleted_enabled, apatride, pays_naissance_id,
                             orcid, id_hal)
select nextval('individu_id_seq'), null, null, 'DIRECTEURA', 'DIRECTEURA', 'Jean', null, null, 'direcetru@mail.fr', null, 'Française',
        'DIPLOMC::053386367CC::DIRECTEURA', 1, 1, current_timestamp, 1, current_timestamp, null, null, '111111', null,
        'DIPLOMD::053386367CC::DIRECTEURA', 1, 1, current_timestamp, 1, current_timestamp, null, null, '111111', null,
        null, null, true, true, false, false, null, null, null;

INSERT INTO acteur_these (id, individu_id, these_id, role_id, qualite, source_code, source_id, histo_createur_id,
@@ -94,7 +94,7 @@ INSERT INTO acteur_these (id, individu_id, these_id, role_id, qualite, source_co
                                 soutenance_membre_id)
select nextval('acteur_these_id_seq'), currval('individu_id_seq'), currval('these_id_seq'),
       (select id from role where source_code = 'UCN::D'),
       null, 'DIPLOMC::053386367CC::DIRECTEURA', 1, 1, current_timestamp,
       null, 'DIPLOMD::053386367CC::DIRECTEURA', 1, 1, current_timestamp,
       1, current_timestamp, null, null, 2, 408, null, false, 85, false, false, 1, 16, null;

INSERT INTO acteur_these (id, individu_id, these_id, role_id, qualite, source_code, source_id, histo_createur_id,
@@ -104,7 +104,7 @@ INSERT INTO acteur_these (id, individu_id, these_id, role_id, qualite, source_co
                                 soutenance_membre_id)
select nextval('acteur_these_id_seq'), currval('individu_id_seq'), currval('these_id_seq'),
       (select id from role where source_code = 'UCN::P'),
       null, 'DIPLOMC::053386367CC::PRESIDENTA', 1, 1, current_timestamp,
       null, 'DIPLOMD::053386367CC::PRESIDENTA', 1, 1, current_timestamp,
       1, current_timestamp, null, null, 2, 408, null, false, 85, false, false, 1, 16, null;

INSERT INTO individu (id, type, civilite, nom_usuel, nom_patronymique, prenom1, prenom2, prenom3, email,
@@ -114,7 +114,7 @@ INSERT INTO individu (id, type, civilite, nom_usuel, nom_patronymique, prenom1,
                             synchro_undelete_enabled, synchro_update_on_deleted_enabled, apatride, pays_naissance_id,
                             orcid, id_hal)
select nextval('individu_id_seq'), null, null, 'MEMBREA', 'MEMBREA', 'Jean', null, null, 'membrea@mail.fr', null, 'Française',
        'DIPLOMC::053386367CC::MEMBREA', 1, 1, current_timestamp, 1, current_timestamp, null, null, '222222', null,
        'DIPLOMD::053386367CC::MEMBREA', 1, 1, current_timestamp, 1, current_timestamp, null, null, '222222', null,
        null, null, true, true, false, false, null, null, null;

INSERT INTO acteur_these (id, individu_id, these_id, role_id, qualite, source_code, source_id, histo_createur_id,
@@ -124,14 +124,14 @@ INSERT INTO acteur_these (id, individu_id, these_id, role_id, qualite, source_co
                                 soutenance_membre_id)
select nextval('acteur_these_id_seq'), currval('individu_id_seq'), currval('these_id_seq'),
       (select id from role where source_code = 'UCN::M'),
       null, 'DIPLOMC::053386367CC::MEMBREA', 1, 1, current_timestamp,
       null, 'DIPLOMD::053386367CC::MEMBREA', 1, 1, current_timestamp,
       1, current_timestamp, null, null, 2, 408, null, false, 85, false, false, 1, 16, null;

-----------------

INSERT INTO fichier (id, uuid, nature_id, nom, nom_original, type_mime, taille, description, version_fichier_id,
                            histo_creation, histo_createur_id, histo_modification, histo_modificateur_id)
select nextval('fichier_id_seq'), 'DIPLOMC::053386367CC::1', 121, 'RAPPORT-CSI-ED558-DIPLOMC-Paule-2024-2025-953e0e55.pdf',
select nextval('fichier_id_seq'), 'DIPLOMD::053386367CC::1', 121, 'RAPPORT-CSI-ED558-DIPLOMD-Paule-2024-2025-953e0e55.pdf',
        'rapport1.pdf', 'application/pdf', 42338, null, 3, current_timestamp, 1, current_timestamp, 1;
INSERT INTO rapport (id, these_id, fichier_id, annee_univ, est_final, histo_createur_id, histo_modificateur_id,
                            histo_creation, type_rapport_id)
@@ -140,7 +140,7 @@ select nextval('rapport_id_seq'), currval('these_id_seq'), currval('fichier_id_s

INSERT INTO fichier (id, uuid, nature_id, nom, nom_original, type_mime, taille, description, version_fichier_id,
                            histo_creation, histo_createur_id, histo_modification, histo_modificateur_id)
select nextval('fichier_id_seq'), 'DIPLOMC::053386367CC::2', 121, 'RAPPORT-CSI-ED558-DIPLOMC-Paule-2025-2026-d060dbd7.pdf',
select nextval('fichier_id_seq'), 'DIPLOMD::053386367CC::2', 121, 'RAPPORT-CSI-ED558-DIPLOMD-Paule-2025-2026-d060dbd7.pdf',
       'rapport2.pdf', 'application/pdf', 3153, null, 3, current_timestamp, 1, current_timestamp, 1;
INSERT INTO rapport (id, these_id, fichier_id, annee_univ, est_final, histo_createur_id, histo_modificateur_id,
                            histo_creation, type_rapport_id)
+57 −16
Original line number Diff line number Diff line
@@ -5,35 +5,68 @@ namespace AutorisationDiplomationThese\Tx\Entity\Db\Service;
use Application\Attribute\DependsOn;
use Application\Attribute\InjectConfig;
use Application\Entity\Db\Role;
use Tx\Entity\Db\Service\AbstractTxDataService;
use AutorisationDiplomationThese\Entity\Db\AutorisationDiplomationThese;
use AutorisationDiplomationThese\Service\Entity\AutorisationDiplomationTheseService;
use AutorisationDiplomationThese\Service\Entity\AutorisationDiplomationTheseServiceAwareTrait;
use AutorisationDiplomationThese\Tx\Entity\Db\TxData;
use AutorisationDiplomationThese\Tx\Entity\Db\Repository\TxDataRepository;
use AutorisationDiplomationThese\Tx\Entity\Db\TxData;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use InvalidArgumentException;
use RuntimeException;
use These\Entity\Db\These;
use These\Service\These\TheseService;
use These\Service\These\TheseServiceAwareTrait;
use Tx\Entity\Db\Service\AbstractTxDataService;
use UnicaenPegaseCocExtApi\Model\DiplomationTroisiemeCycle;
use Webmozart\Assert\Assert;

#[DependsOn(EntityManager::class)]
#[DependsOn(TheseService::class)]
#[DependsOn(AutorisationDiplomationTheseService::class)]
#[InjectConfig('unicaen-pegase-coc-ext-api > codes_types_resultats')] /** @see setCodesTypesResultats() */
#[InjectConfig('unicaen_pegase > codes_structures_etablissements')] /** @see setCodesStructuresEtablissements() */
#[InjectConfig('unicaen_pegase > codes_types_resultats')] /** @see setCodesTypesResultats() */
class TxDataService extends AbstractTxDataService
{
    public const VALIDE = 'VALIDE';
    public const NON_VALIDE = 'NON_VALIDE';

    use TheseServiceAwareTrait;
    use AutorisationDiplomationTheseServiceAwareTrait;

    /**
     * Codes des établissements Pégase selon le contexte (ex : selon l'établissement concerné)
     *
     * Exemple :
     *
     *      [
     *           'UCN' => 'ETAB00',
     *           'INSA' => 'ETAB00',
     *      ],
     *
     * @var array<string, string>
     */
    private array $codesStructuresEtablissements;

    public function setCodesStructuresEtablissements(array $codesStructuresEtablissements): void
    {
        $this->codesStructuresEtablissements = $codesStructuresEtablissements;
    }

    /**
     * Codes des types de résultats Pégase selon le contexte (ex : selon l'établissement concerné)
     *
     * Exemple :
     *
     *      [
     *          'UCN' => [
     *              'VALIDE' => 'TRE009',
     *              'NON_VALIDE' => 'TRE010',
     *          ],
     *          'INSA' => [
     *              'VALIDE' => 'XXXX',
     *              'NON_VALIDE' => 'YYYY',
     *          ],
     *      ],
     *
     * @var array<string, array<string>>
     */
    private array $codesTypesResultats;

    public function setCodesTypesResultats(array $codesTypesResultats): void
@@ -48,20 +81,19 @@ class TxDataService extends AbstractTxDataService
        return $repo;
    }

    public function createQueryBuilder(): QueryBuilder
    {
        return $this->getRepository()->createQueryBuilder('autorisationDiplomationThese');
    }

    /**
     * Retourne simplement une nouvelle instance de la classe d'entité gérée par ce service.
     */
    public function createEntity(array $params): TxData
    {
        /** @var AutorisationDiplomationThese $autorisation */
        $autorisation = $params['autorisation'];

        $instance = new TxData();
        $instance->setAutorisationDiplomationThese($autorisation);
        $instance->setCodeStructureEtablissement(
            $this->codesStructuresEtablissements[$autorisation->getThese()->getEtablissement()->getSourceCode()] ?? null
        );

        // Génération du payload (qui peut échouer à cause de données manquantes) qui sera utilisé pour l'appel à
        // l'API du logiciel de scolarité :
@@ -168,18 +200,27 @@ class TxDataService extends AbstractTxDataService
        $valeur = $autorisation->getAutorisation();
        Assert::notNull($valeur, "La valeur de l'autorisation n°{$autorisation->getId()}) est null !");

        $etablissement = $autorisation->getThese()->getEtablissement();
        $codeEtablissement = $etablissement->getSourceCode();

        Assert::keyExists(
            $this->codesTypesResultats,
            $codeEtablissement,
            "La clé %s n'existe pas dans la config des codes de types de résultats."
        );

        if ($valeur === true) {
            $key = self::VALIDE;
        } else {
            $key = self::NON_VALIDE;
        }
        Assert::keyExists(
            $this->codesTypesResultats,
            $this->codesTypesResultats[$codeEtablissement],
            $key,
            "La clé '$key' n'existe pas dans la config des codes de types de résultats."
            "La clé %s n'existe pas dans la config des codes de types de résultats."
        );

        return $this->codesTypesResultats[$key];
        return $this->codesTypesResultats[$codeEtablissement][$key];
    }

    private function extractDirecteurThese(array $acteurs): array
Loading