Commit 613cf7b8 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

WIP API

parent 2a55c0bb
Loading
Loading
Loading
Loading
+2 −2
Changes for composer.lock: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -11763,7 +11763,7 @@
            "source": {
                "type": "git",
                "url": "https://git.unicaen.fr/open-source/sygal-api.git",
                "reference": "38707831f6c4455db5b5e1ea90a9df813cc59740"
                "reference": "310190d015fa1e5dcaa7f674e2fcfd4cfe67ec8a"
            },
            "require": {
                "guzzlehttp/guzzle": "^7.0",
@@ -11788,7 +11788,7 @@
                ]
            },
            "description": "API SyGAL",
            "time": "2023-06-06T07:54:32+00:00"
            "time": "2023-06-06T09:30:26+00:00"
        },
        {
            "name": "unicaen/zfc-user",
+1 −14
Changes for module/SygalApiImpl/config/versions/v1.config.php: 1 added line, 14 removed lines.
Original line number Diff line number Diff line
@@ -16,17 +16,11 @@ return [
        'SygalApi\\V1\\Rest\\InscriptionAdministrative\\Controller' => [
            'listener' => \SygalApiImpl\V1\Rest\InscriptionAdministrative\InscriptionAdministrativeResource::class,
        ],
        'SygalApi\\V1\\Rest\\Doctorant\\Controller' => [
            'listener' => \SygalApiImpl\V1\Rest\Doctorant\DoctorantResource::class,
        ],
    ],
    'service_manager' => [
        'factories' => [
            \SygalApiImpl\V1\Rest\InscriptionAdministrative\InscriptionAdministrativeResource::class => \SygalApiImpl\V1\Rest\InscriptionAdministrative\InscriptionAdministrativeResourceFactory::class,
            \SygalApiImpl\V1\Rest\InscriptionAdministrative\Facade\ImportFacade::class => \SygalApiImpl\V1\Rest\InscriptionAdministrative\Facade\ImportFacadeFactory::class,

            \SygalApiImpl\V1\Rest\Doctorant\DoctorantResource::class => \SygalApiImpl\V1\Rest\Doctorant\DoctorantResourceFactory::class,
            \SygalApiImpl\V1\Rest\Doctorant\Facade\ImportFacade::class => \SygalApiImpl\V1\Rest\Doctorant\Facade\ImportFacadeFactory::class,
            \SygalApiImpl\V1\Rest\InscriptionAdministrative\Service\ImportFacade::class => \SygalApiImpl\V1\Rest\InscriptionAdministrative\Service\ImportFacadeFactory::class
        ],
    ],
    'bjyauthorize'    => [
@@ -50,13 +44,6 @@ return [
                    'controller' => 'SygalApi\\V1\\Rest\\InscriptionAdministrative\\Controller',
//                    'action'     => [
//                        'index',
//                    ],
                    'roles' => [],
                ],
                [
                    'controller' => 'SygalApi\\V1\\Rest\\Doctorant\\Controller',
//                    'action'     => [
//                        'index',
//                    ],
                    'roles' => [],
                ],
+3 −53
Changes for module/SygalApiImpl/doc/pegase_sygal.md: 3 added lines, 53 removed lines.
Original line number Diff line number Diff line
Communication Pégase - SyGAL
============================


Flux "inscription_administrative" Pégase => SyGAL
-------------------------------------------------

Extrait exemple du JSON envoyé :

```json
{
  "id": "APPREN65497_ETAB5_FORMATION6548_PERIODE123", // <<< id forgé non immuable !
  "id": "APPREN65497_ETAB5_FORMATION6548_PERIODE123",
  "instancePegase": "PEGASE_INSA",
  "apprenant": {
    "code": "APPREN65497", // <<< le code apprenant peut changer suite à une "fusion apprenant" !
    "INE": "551541446" // <<< l'INE aussi peut changer (INE provisoire => définitif) !
    "code": "APPREN65497",
    "INE": "551541446"
  },
  "inscription": {
    "statutInscription": "valide",
@@ -23,47 +17,3 @@ Extrait exemple du JSON envoyé :
  }
}
```
 No newline at end of file

L'id reçu pour l'inscription n'est pas un id technique immuable (ex : UUID ou séquence), il est forgé à partir de :
  - l'établissement
  - l'apprenant
  - la formation
  - la période

Conséquences :
  - Une inscription en 2022 et une inscription en 2023 = 2 inscriptions.
  - Si le code apprenant change : l'id change !
    Si l'id change, l'inscription dont l'id était forgé avec l'ancien code apprenant perdure dans SyGAL sans moyen de 
    savoir qu'il faut la supprimer !
    Le code apprenant peut changer suite à une "fusion apprenant".
  - Si l'INE de l'apprenant changent (INE = source_code utilisé par SyGAL), SyGAL pensera que c'est une inscription
    concernant un autre doctorant ! Comment retrouver la trace du doctorant dont l'INE a changé ??


Problème de la fusion apprenant
-------------------------------

Sylvie, le 01/06/23 :

"Avant de pouvoir commencer une inscription, l'apprenant doit avoir un INE confirmé (via le WS INES). Le dédoublonnage
dans Pégase se fait via le n° INE. Il peut arriver que l'apprenant existe déjà avec des inscriptions validées sur un
autre n° INE (mauvaise reprise RDD, INE trop ancien,non reconnu par INES,...) ce qui fait qu'on ne le reconnaît pas
comme un réinscrit mais comme un nouvel apprenant (avec un nouveau code). L'établissement souhaite alors fusionner les
deux apprenants pour avoir un dossier complet le concernant. La plupart du temps, le gestionnaire ne s'aperçoit du
doublon qu'une fois que l'inscription avec le nouveau code apprenant a été validée et vous a donc été envoyée. L'unicité
de l'apprenant se faisant avec son code apprenant dans Sygal, la question se pose de savoir comment faire pour que vous
compreniez qu'il s'agit d'un changement de code. Est-ce qu'on peut vous envoyer une annulation de l'inscription avec le
mauvais code et une création avec le nouveau code ? est-ce qu'il faut prévoir quelque chose d'autre ?" 

Discussion à ce propos : https://confluence.pc-scol.fr/pages/viewpage.action?pageId=73881459


Améliorations possibles
-----------------------

- Comme le code apprenant (notamment) peut changer suite à une fusion apprenant, envoyer un id technique immuable (clé
  primaire de type UUID ou séquentiel) partout où c'est possible. A minima doctorant et inscription. Ce qui permet côté
  SyGAL de savoir quelles inscriptions et quels doctorants sont déjà connus et ne nécessitent qu'une mise à jour.
- Un changement de code apprenant ou d'INE est un événement qui concerne le doctorant (pas l'inscription). Un flux
  supplémentaire "doctorant" dédié permettrait d'envoyer les doctorants et leurs modifications au fil du temps (à
  condition d'avoir un id technique immuable).
 No newline at end of file
+0 −55
Changes for module/SygalApiImpl/src/V1/Facade/AbstractImportFacade.php: 0 added lines, 55 removed lines.
Original line number Diff line number Diff line
<?php

namespace SygalApiImpl\V1\Facade;

use Doctrine\DBAL\Connection;
use UnicaenDbImport\Domain\Import;
use UnicaenDbImport\Domain\Synchro;
use UnicaenDbImport\Service\ImportService;
use UnicaenDbImport\Service\SynchroService;

abstract class AbstractImportFacade implements ImportFacadeInterface
{
    protected Connection $destinationConnection;
    protected ImportService $importService;
    protected SynchroService $synchroService;

    public function setImportService(ImportService $importService): void
    {
        $this->importService = $importService;
    }

    public function setSynchroService(SynchroService $synchroService): void
    {
        $this->synchroService = $synchroService;
    }
    
    public function setDestinationConnection(Connection $destinationConnection): void
    {
        $this->destinationConnection = $destinationConnection;
    }

    /**
     * @throws \Exception
     */
    protected function runImport(Import $import)
    {
        $result = $this->importService->runImport($import);

        if ($exception = $result->getFailureException()) {
            throw $exception;
        }
    }

    /**
     * @throws \Exception
     */
    protected function runSynchro(Synchro $synchro)
    {
        $result = $this->synchroService->runSynchro($synchro);

        if ($exception = $result->getFailureException()) {
            throw $exception;
        }
    }
}
 No newline at end of file
+0 −13
Changes for module/SygalApiImpl/src/V1/Facade/ImportFacadeInterface.php: 0 added lines, 13 removed lines.
Original line number Diff line number Diff line
<?php

namespace SygalApiImpl\V1\Facade;

use stdClass;

interface ImportFacadeInterface
{
    /**
     * @throws \Exception
     */
    public function import(stdClass $data);
}
 No newline at end of file
Loading