Commit fec1801b authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Abandon de la recherche du futur membre d'ED,UR,Etab dans le LDAP au profit de...

Abandon de la recherche du futur membre d'ED,UR,Etab dans le LDAP au profit de la table Individu (sauf sur la page Utilsateurs)
parent d24b6b04
Loading
Loading
Loading
Loading
Loading
+55 −0
Changes for data/SQL/sygal/recherche.sql: 55 added lines, 0 removed lines.
Original line number Diff line number Diff line
-------------------------------------------
-- Table, trigger et fonction de recherche --
-------------------------------------------


-- table de recherche
create table INDIVIDU_RECH (
  ID NUMBER not null constraint INDIVIDU_RECH_PK primary key,
  HAYSTACK CLOB
);
-- contenu initial
insert into INDIVIDU_RECH(ID, HAYSTACK)
  select
    id,
    trim(UNICAEN_ORACLE.str_reduce(NOM_USUEL || ' ' || NOM_PATRONYMIQUE || ' ' || PRENOM1 || ' ' || SOURCE_CODE))
  from INDIVIDU;


-- fonction haystack
create or replace function individu_haystack(
  NOM_USUEL varchar2,
  NOM_PATRONYMIQUE varchar2,
  PRENOM1 varchar2,
  SOURCE_CODE varchar2) RETURN VARCHAR2
AS
  BEGIN
    return trim(UNICAEN_ORACLE.str_reduce(NOM_USUEL || ' ' || NOM_PATRONYMIQUE || ' ' || PRENOM1 || ' ' || SOURCE_CODE));
  END;


-- trigger de màj de la table de recherche
--drop trigger INDIVIDU_RECH_UPDATE;
CREATE TRIGGER INDIVIDU_RECH_UPDATE
  AFTER DELETE OR INSERT OR UPDATE OF NOM_USUEL, NOM_PATRONYMIQUE, PRENOM1, PRENOM2, PRENOM3, SOURCE_CODE ON INDIVIDU
  FOR EACH ROW
  DECLARE
    v_haystack CLOB := individu_haystack(:new.NOM_USUEL, :new.NOM_PATRONYMIQUE, :new.PRENOM1, :new.SOURCE_CODE);
  BEGIN
    IF INSERTING THEN
      insert into INDIVIDU_RECH(ID, HAYSTACK) values (:new.ID, v_haystack);
    END IF;
    IF UPDATING THEN
      UPDATE INDIVIDU_RECH SET HAYSTACK = v_haystack where ID = :new.ID;
    END IF;
    IF DELETING THEN
      delete from INDIVIDU_RECH where id = :old.ID;
    END IF;
  END;


-- test
update INDIVIDU set source_code = source_code||' x' where id = 102443;
-- verif
select * from INDIVIDU where  id = 102443;
select * from INDIVIDU_RECH where  id = 102443;
+10 −0
Changes for module/Application/config/others/utilisateur.config.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ return [
                    'controller' => 'Application\Controller\Utilisateur',
                    'action'     => [
                        'rechercher-people',
                        'rechercher-individu',
                    ],
                    'privileges' => UtilisateurPrivileges::UTILISATEUR_CONSULTATION,
                ],
@@ -89,6 +90,15 @@ return [
                            ],
                        ],
                    ],
                    'rechercher-individu' => [
                        'type'          => 'Segment',
                        'options'       => [
                            'route'       => '/rechercher-individu',
                            'defaults'    => [
                                'action' => 'rechercher-individu',
                            ],
                        ],
                    ],
                ],
            ],
        ],
+5 −12
Changes for module/Application/src/Application/Controller/EcoleDoctoraleController.php: 5 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -2,8 +2,8 @@

namespace Application\Controller;

use Application\Entity\UserWrapper;
use Application\Entity\Db\EcoleDoctorale;
use Application\Entity\Db\Individu;
use Application\Entity\Db\IndividuRole;
use Application\Entity\Db\Role;
use Application\Form\EcoleDoctoraleForm;
@@ -12,7 +12,6 @@ use Application\Service\EcoleDoctorale\EcoleDoctoraleServiceAwareTrait;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
use Application\Service\Role\RoleServiceAwareTrait;
use UnicaenLdap\Entity\People;
use UnicaenLdap\Service\LdapPeopleServiceAwareTrait;
use Zend\View\Model\ViewModel;

@@ -185,19 +184,13 @@ class EcoleDoctoraleController extends AbstractController
    public function ajouterIndividuAction()
    {
        $edId       = $this->params()->fromRoute('ecoleDoctorale');
        $data       = $this->params()->fromPost('people');
        $data       = $this->params()->fromPost('individu');
        $roleId     = $this->params()->fromPost('role');

        if (!empty($data['id'])) {
            /** @var People $people */
            if ($people = $this->ldapPeopleService->get($data['id'])) {
                $userWrapper = UserWrapper::inst($people);
                $etablissement = $this->etablissementService->getRepository()->findOneByDomaine($userWrapper->getDomainFromEppn());
                $individu = $this->individuService->getRepository()->findOneByEmpIdAndEtab($userWrapper->getSupannEmpId(), $etablissement);
                if (! $individu) {
                    $individu = $this->individuService->createFromPeopleAndEtab($people, $etablissement);
                }

            /** @var Individu $individu */
            $individu = $this->individuService->getRepository()->find($data['id']);
            if ($individu) {
                /**
                 * @var EcoleDoctorale $ecole
                 * @var Role $role
+5 −12
Changes for module/Application/src/Application/Controller/EtablissementController.php: 5 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -3,15 +3,14 @@
namespace Application\Controller;

use Application\Entity\Db\Etablissement;
use Application\Entity\Db\Individu;
use Application\Entity\Db\IndividuRole;
use Application\Entity\Db\Role;
use Application\Entity\UserWrapper;
use Application\Form\EtablissementForm;
use Application\RouteMatch;
use Application\Service\Etablissement\EtablissementServiceAwareTrait;
use Application\Service\Individu\IndividuServiceAwareTrait;
use Application\Service\Role\RoleServiceAwareTrait;
use UnicaenLdap\Entity\People;
use UnicaenLdap\Service\LdapPeopleServiceAwareTrait;
use Zend\View\Model\ViewModel;

@@ -268,19 +267,13 @@ class EtablissementController extends AbstractController
    public function ajouterIndividuAction()
    {
        $etabId     = $this->params()->fromRoute('etablissement');
        $data       = $this->params()->fromPost('people');
        $data       = $this->params()->fromPost('individu');
        $roleId     = $this->params()->fromPost('role');

        if (!empty($data['id'])) {
            /** @var People $people */
            if ($people = $this->ldapPeopleService->get($data['id'])) {
                $userWrapper = UserWrapper::inst($people);
                $etablissement = $this->etablissementService->getRepository()->findOneByDomaine($userWrapper->getDomainFromEppn());
                $individu = $this->individuService->getRepository()->findOneByEmpIdAndEtab($userWrapper->getSupannEmpId(), $etablissement);
                if (! $individu) {
                    $individu = $this->individuService->createFromPeopleAndEtab($people, $etablissement);
                }

            /** @var Individu $individu */
            $individu = $this->individuService->getRepository()->find($data['id']);
            if ($individu) {
                /**
                 * @var Etablissement $etablissement
                 * @var Role $role
+8 −4
Changes for module/Application/src/Application/Controller/Factory/UtilisateurControllerFactory.php: 8 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -3,30 +3,34 @@
namespace Application\Controller\Factory;

use Application\Controller\UtilisateurController;
use Application\Service\Individu\IndividuServiceLocateTrait;
use Application\Service\Role\RoleService;
use Application\Service\Utilisateur\UtilisateurService;
use UnicaenLdap\Service\People as LdapPeopleService;
use Zend\Mvc\Controller\ControllerManager;


class UtilisateurControllerFactory
{
    use IndividuServiceLocateTrait;

    public function __invoke(ControllerManager $controllerManager)
    {
        $sl = $controllerManager->getServiceLocator();

        /**
         * @var RoleService $roleService
         * @var UtilisateurService $utilisateurService
         * @var LdapPeopleService $ldapPeopleService
         */
        $roleService = $controllerManager->getServiceLocator()->get('RoleService');
        $ldapPeopleService  = $controllerManager->getServiceLocator()->get('LdapServicePeople');
        $utilisateurService = $controllerManager->getServiceLocator()->get('UtilisateurService');
        $roleService = $sl->get('RoleService');
        $ldapPeopleService  = $sl->get('LdapServicePeople');
        $utilisateurService = $sl->get('UtilisateurService');

        $controller = new UtilisateurController();
        $controller->setRoleService($roleService);
        $controller->setLdapPeopleService($ldapPeopleService);
        $controller->setUtilisateurService($utilisateurService);
        $controller->setIndividuService($this->locateIndividuService($sl));

        return $controller;
    }
Loading