Loading module/Application/src/Application/Entity/Db/Fonction.php +5 Changes for module/Application/src/Application/Entity/Db/Fonction.php: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -114,4 +114,9 @@ class Fonction { return null; } public function setId($id) { $this->id = $id; } } No newline at end of file module/Application/src/Application/Service/Fonction/FonctionService.php +65 −2 Changes for module/Application/src/Application/Service/Fonction/FonctionService.php: 65 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Application\Service\Fonction; use Application\Entity\Db\Fonction; use Application\Entity\Db\FonctionLibelle; use Application\Entity\Db\Source; use DateTime; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\OptimisticLockException; Loading Loading @@ -302,11 +303,42 @@ class FonctionService { { $fonctionType = $this->getFonctionService()->getFonctionTypeByNom(FonctionType::FONCTION_STRUCTURELLE); $fonctions_OCTOPUS = $this->getFonctionService()->getFonctionsByType($fonctionType); $fonctions_PREECOG = $this->getFonctions(); foreach ($fonctions_OCTOPUS as $fonction_OCTOPUS) { $fonction = $this->createFromOctopus($fonction_OCTOPUS); $nouvelles = []; $modifiees = []; $supprimees = []; foreach ($fonctions_OCTOPUS as $fonction) { $res = array_filter($fonctions_PREECOG, function(Fonction $s) use ($fonction) { return ($s->getSource() === 'OCTOPUS' && $s->getIdSource() == $fonction->getId()); }); if (! empty($res)) { $modification = $this->updateFromOctopus(current($res), $fonction); if ($modification) $modifiees[] = current($res); } else { //nouvelle structure $nouvelle = $this->createFromOctopus($fonction); $nouvelles[] = $nouvelle; } } foreach ($fonctions_PREECOG as $fonction) { if ($fonction->getSource() === Source::Octopus) { $res = array_filter($fonctions_OCTOPUS, function (\Octopus\Entity\Db\Fonction $s) use ($fonction) { return ($fonction->getSource() === 'OCTOPUS' && $s->getId() == $fonction->getIdSource()); }); if (empty($res)) { $this->delete($fonction); $supprimees[] = $fonction; } } } return [ 'nouvelles' => $nouvelles, 'modifiees' => $modifiees, 'supprimees' => $supprimees, ]; } /** * @var \Octopus\Entity\Db\Fonction $fonction_OCTOPUS Loading Loading @@ -337,6 +369,35 @@ class FonctionService { return $fonction; } /** * @var Fonction $current * @var \Octopus\Entity\Db\Fonction $fonction * @return Fonction */ private function updateFromOctopus($current, \Octopus\Entity\Db\Fonction $fonction) { $libelles = $current->getLibelles(); foreach ($libelles as $libelle) { $current->removeLibelle($libelle); $this->deleteLibelle($libelle); } foreach ($fonction->getLibelles() as $libelle_OCTOPUS) { $libelle = new FonctionLibelle(); $libelle->setFonction($current); $libelle->setLibelle($libelle_OCTOPUS->getLibelle()); $libelle->setGenre($libelle_OCTOPUS->getGenre()); $libelle->setDefault(($libelle_OCTOPUS->getDefault()) ? 'O' : 'N'); $libelle->setSource('OCTOPUS'); $libelle->setIdSource($libelle_OCTOPUS->getId()); $this->createLibelle($libelle); $current->addLibelle($libelle); } $this->update($current); return $current; } public function getFonctionsAsOption() { $options = []; Loading @@ -348,4 +409,6 @@ class FonctionService { return $options; } } module/Application/src/Application/Service/Structure/StructureService.php +6 −1 Changes for module/Application/src/Application/Service/Structure/StructureService.php: 6 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Service\Structure; use Application\Entity\Db\Source; use Application\Entity\Db\Structure; use Application\Entity\Db\StructureType; use Utilisateur\Service\User\UserServiceAwareTrait; Loading Loading @@ -248,13 +249,17 @@ class StructureService } } foreach ($structures_PREECOG as $structure) { if ($structure->getSource() === Source::Octopus) { $res = array_filter($structures_OCTOPUS, function(\Octopus\Entity\Db\Structure $s) use ($structure) { return ($structure->getSource() === 'OCTOPUS' && $s->getId() == $structure->getIdSource()); }); function (\Octopus\Entity\Db\Structure $s) use ($structure) { return ($structure->getSource() === 'OCTOPUS' && $s->getId() == $structure->getIdSource()); }); if (empty($res)) { $this->delete($structure); $supprimees[] = $structure; } } } return [ 'nouvelles' => $nouvelles, 'modifiees' => $modifiees, Loading Loading
module/Application/src/Application/Entity/Db/Fonction.php +5 Changes for module/Application/src/Application/Entity/Db/Fonction.php: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -114,4 +114,9 @@ class Fonction { return null; } public function setId($id) { $this->id = $id; } } No newline at end of file
module/Application/src/Application/Service/Fonction/FonctionService.php +65 −2 Changes for module/Application/src/Application/Service/Fonction/FonctionService.php: 65 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Application\Service\Fonction; use Application\Entity\Db\Fonction; use Application\Entity\Db\FonctionLibelle; use Application\Entity\Db\Source; use DateTime; use Doctrine\ORM\NonUniqueResultException; use Doctrine\ORM\OptimisticLockException; Loading Loading @@ -302,11 +303,42 @@ class FonctionService { { $fonctionType = $this->getFonctionService()->getFonctionTypeByNom(FonctionType::FONCTION_STRUCTURELLE); $fonctions_OCTOPUS = $this->getFonctionService()->getFonctionsByType($fonctionType); $fonctions_PREECOG = $this->getFonctions(); foreach ($fonctions_OCTOPUS as $fonction_OCTOPUS) { $fonction = $this->createFromOctopus($fonction_OCTOPUS); $nouvelles = []; $modifiees = []; $supprimees = []; foreach ($fonctions_OCTOPUS as $fonction) { $res = array_filter($fonctions_PREECOG, function(Fonction $s) use ($fonction) { return ($s->getSource() === 'OCTOPUS' && $s->getIdSource() == $fonction->getId()); }); if (! empty($res)) { $modification = $this->updateFromOctopus(current($res), $fonction); if ($modification) $modifiees[] = current($res); } else { //nouvelle structure $nouvelle = $this->createFromOctopus($fonction); $nouvelles[] = $nouvelle; } } foreach ($fonctions_PREECOG as $fonction) { if ($fonction->getSource() === Source::Octopus) { $res = array_filter($fonctions_OCTOPUS, function (\Octopus\Entity\Db\Fonction $s) use ($fonction) { return ($fonction->getSource() === 'OCTOPUS' && $s->getId() == $fonction->getIdSource()); }); if (empty($res)) { $this->delete($fonction); $supprimees[] = $fonction; } } } return [ 'nouvelles' => $nouvelles, 'modifiees' => $modifiees, 'supprimees' => $supprimees, ]; } /** * @var \Octopus\Entity\Db\Fonction $fonction_OCTOPUS Loading Loading @@ -337,6 +369,35 @@ class FonctionService { return $fonction; } /** * @var Fonction $current * @var \Octopus\Entity\Db\Fonction $fonction * @return Fonction */ private function updateFromOctopus($current, \Octopus\Entity\Db\Fonction $fonction) { $libelles = $current->getLibelles(); foreach ($libelles as $libelle) { $current->removeLibelle($libelle); $this->deleteLibelle($libelle); } foreach ($fonction->getLibelles() as $libelle_OCTOPUS) { $libelle = new FonctionLibelle(); $libelle->setFonction($current); $libelle->setLibelle($libelle_OCTOPUS->getLibelle()); $libelle->setGenre($libelle_OCTOPUS->getGenre()); $libelle->setDefault(($libelle_OCTOPUS->getDefault()) ? 'O' : 'N'); $libelle->setSource('OCTOPUS'); $libelle->setIdSource($libelle_OCTOPUS->getId()); $this->createLibelle($libelle); $current->addLibelle($libelle); } $this->update($current); return $current; } public function getFonctionsAsOption() { $options = []; Loading @@ -348,4 +409,6 @@ class FonctionService { return $options; } }
module/Application/src/Application/Service/Structure/StructureService.php +6 −1 Changes for module/Application/src/Application/Service/Structure/StructureService.php: 6 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Application\Service\Structure; use Application\Entity\Db\Source; use Application\Entity\Db\Structure; use Application\Entity\Db\StructureType; use Utilisateur\Service\User\UserServiceAwareTrait; Loading Loading @@ -248,13 +249,17 @@ class StructureService } } foreach ($structures_PREECOG as $structure) { if ($structure->getSource() === Source::Octopus) { $res = array_filter($structures_OCTOPUS, function(\Octopus\Entity\Db\Structure $s) use ($structure) { return ($structure->getSource() === 'OCTOPUS' && $s->getId() == $structure->getIdSource()); }); function (\Octopus\Entity\Db\Structure $s) use ($structure) { return ($structure->getSource() === 'OCTOPUS' && $s->getId() == $structure->getIdSource()); }); if (empty($res)) { $this->delete($structure); $supprimees[] = $structure; } } } return [ 'nouvelles' => $nouvelles, 'modifiees' => $modifiees, Loading