Commit a15577e4 authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Correction bug chargens sur duplication de scénarios

parent b7c119aa
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ Objectif : Connecteur import Actul+ & système différentiel pour comparer des c
* Dans ODF, la liste des éléments dont on peut forcer la synchronisation tient maintenant compte des données à restaurer en plus de celles à insérer
* Correction sur le rafraichissement du rôle de l'intervenant lors d'un changement d'année universitaire (#39020)
* Correction sur la gestion des pièces jointes lors de l'archivage de celles-ci afin que cela impacte correctement la feuille de route et les indicateurs notamment pour les nouvelles pièces jointes à valider (#39195)

* Niveau Charges, lors de la duplication d'un scénario, le périmètre est pris en compte lors de la duplication pour ne pas écraser des données d'autres composantes à tort


# OSE 15.5 (01/07/2021)
+11 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ CREATE OR REPLACE PACKAGE BODY "OSE_CHARGENS" AS

  PROCEDURE DUPLIQUER( source_id NUMERIC, destination_id NUMERIC, utilisateur_id NUMERIC, structure_id NUMERIC, noeuds VARCHAR2 DEFAULT '', liens VARCHAR2 DEFAULT '' ) IS
  BEGIN
    UNICAEN_TBL.ACTIV_TRIGGERS := FALSE;

    /* Destruction de tous les liens antérieurs de la destination */
    DELETE FROM
@@ -194,6 +195,7 @@ CREATE OR REPLACE PACKAGE BODY "OSE_CHARGENS" AS
        SELECT id FROM lien WHERE lien.structure_id = DUPLIQUER.STRUCTURE_ID
      ))
    ;
    commit;

    /* Duplication des liens */
    INSERT INTO scenario_lien (
@@ -222,6 +224,7 @@ CREATE OR REPLACE PACKAGE BODY "OSE_CHARGENS" AS
      AND (DUPLIQUER.LIENS IS NULL OR DUPLIQUER.LIENS LIKE '%,' || lien_id || ',%' )
      AND (DUPLIQUER.STRUCTURE_ID IS NULL OR l.structure_id = DUPLIQUER.STRUCTURE_ID)
    ;
    commit;


    /* Destruction de tous les noeuds antérieurs de la destination */
@@ -235,6 +238,7 @@ CREATE OR REPLACE PACKAGE BODY "OSE_CHARGENS" AS
        SELECT id FROM noeud WHERE noeud.structure_id = DUPLIQUER.STRUCTURE_ID
      ))
    ;
    commit;

    /* Duplication des noeuds */
    INSERT INTO scenario_noeud (
@@ -261,6 +265,7 @@ CREATE OR REPLACE PACKAGE BODY "OSE_CHARGENS" AS
      AND (DUPLIQUER.NOEUDS IS NULL OR DUPLIQUER.NOEUDS LIKE '%,' || noeud_id || ',%' )
      AND (DUPLIQUER.STRUCTURE_ID IS NULL OR n.structure_id = DUPLIQUER.STRUCTURE_ID)
    ;
    commit;

    /* Duplication des effectifs */
    INSERT INTO scenario_noeud_effectif (
@@ -286,6 +291,7 @@ CREATE OR REPLACE PACKAGE BODY "OSE_CHARGENS" AS
      AND (DUPLIQUER.NOEUDS IS NULL OR DUPLIQUER.NOEUDS LIKE '%,' || sn_src.noeud_id || ',%' )
      AND (DUPLIQUER.STRUCTURE_ID IS NULL OR n.structure_id = DUPLIQUER.STRUCTURE_ID)
    ;
    commit;

    /* Duplication des seuils */
    INSERT INTO scenario_noeud_seuil (
@@ -311,6 +317,11 @@ CREATE OR REPLACE PACKAGE BODY "OSE_CHARGENS" AS
      AND (DUPLIQUER.NOEUDS IS NULL OR DUPLIQUER.NOEUDS LIKE '%,' || sn_src.noeud_id || ',%' )
      AND (DUPLIQUER.STRUCTURE_ID IS NULL OR n.structure_id = DUPLIQUER.STRUCTURE_ID)
    ;
    commit;

    UNICAEN_TBL.ACTIV_TRIGGERS := TRUE;

    UNICAEN_TBL.CALCULER( 'chargens', 'SCENARIO_ID', DUPLIQUER.destination_id );
  END;


+4 −3
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ class ScenarioService extends AbstractEntityService
    use BddConnecteurAwareTrait;



    /**
     * retourne la classe des entités
     *
@@ -47,7 +46,7 @@ class ScenarioService extends AbstractEntityService
     */
    public function finderByContext(QueryBuilder $qb = null, $alias = null)
    {
        list($qb, $alias) = $this->initQuery($qb, $alias);
        [$qb, $alias] = $this->initQuery($qb, $alias);

        if ($structure = $this->getServiceContext()->getStructure()) {
            $qb->andWhere($alias . '.structure = :structure OR ' . $alias . '.structure IS NULL')->setParameter(
@@ -71,11 +70,13 @@ class ScenarioService extends AbstractEntityService
        $bdd = new BddConnecteur();
        $bdd->setEntityManager($this->getEntityManager());

        $structure = $this->getServiceContext()->getStructure() ?: $source->getStructure();

        $bdd->execPlsql('OSE_CHARGENS.DUPLIQUER(:source, :destination, :utilisateur, :structure, :noeuds, :liens);', [
            'source'      => $source->getId(),
            'destination' => $destination->getId(),
            'utilisateur' => $this->getServiceContext()->getUtilisateur()->getId(),
            'structure'   => $this->getServiceContext()->getStructure() ? $this->getServiceContext()->getStructure()->getId() : null,
            'structure'   => $structure ? $structure->getId() : null,
            'noeuds'      => $noeuds,
            'liens'       => $liens,
        ]);