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

WIP import multi select

parent ef5647ac
Loading
Loading
Loading
Loading
+3 −3
Changes for doc/release-notes/fiche_rncp/01_fiche_rncp.sql: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ WHERE NOT EXISTS (SELECT 1
                  WHERE p.CODE = d.code);

-- ajout des privilèges au profil BDD (Maison du Doctorat), ADMIN_TECH, GEST_ED
select privilege__grant_privileges_to_profiles('formation_formation',
call privilege__grant_privileges_to_profiles('formation_formation',
                                               ARRAY[
                                                   'configurer-module'
                                               ],
@@ -113,7 +113,7 @@ VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'rncp'), 'resta
INSERT INTO public.unicaen_privilege_privilege (categorie_id, code, libelle, ordre)
VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'rncp'), 'supprimer-competence', 'Supprimer une compétence et/ou un bloc de compétences', 4);

select privilege__grant_privileges_to_profiles('rncp',
call privilege__grant_privileges_to_profiles('rncp',
                                               ARRAY[
                                                   'modifier-competence',
                                                   'historiser-competence',
@@ -304,7 +304,7 @@ VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'portfolio'), '
INSERT INTO public.unicaen_privilege_privilege (categorie_id, code, libelle, ordre)
VALUES ((SELECT id FROM unicaen_privilege_categorie WHERE code = 'portfolio'), 'exporter', 'Exporter le portfolio au format PDF', 2);

select privilege__grant_privileges_to_profiles('portfolio',
call privilege__grant_privileges_to_profiles('portfolio',
                                               ARRAY['afficher', 'exporter'],
                                               ARRAY['ADMIN_TECH', 'DOCTORANT']
);
+5 −1
Changes for module/Portfolio/config/module.config.php: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -12,6 +12,8 @@ use Portfolio\Facade\PortfolioFacadeFactory;
use Portfolio\Provider\Privilege\PortfolioPrivileges;
use Portfolio\Service\Exporter\PortfolioExporter;
use Portfolio\Service\Exporter\PortfolioExporterFactory;
use Portfolio\Service\PublicationSelectGenerator;
use Portfolio\Service\PublicationSelectGeneratorFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use UnicaenPrivilege\Provider\Rule\PrivilegeRuleProvider;

@@ -138,7 +140,9 @@ return [
            PortfolioFacade::class => PortfolioFacadeFactory::class,
            PortfolioAssertion::class => PortfolioAssertionFactory::class,

            PortfolioExporter::class => PortfolioExporterFactory::class
            PortfolioExporter::class => PortfolioExporterFactory::class,

            PublicationSelectGenerator::class => PublicationSelectGeneratorFactory::class,
        ],
    ],
    'view_manager' => [
+43 −0
Changes for module/Portfolio/src/Portfolio/Service/PublicationSelectGenerator.php: 43 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Portfolio\Service;

use Doctorant\Service\DoctorantServiceAwareTrait;
use RuntimeException;
use UnicaenDbImport\Domain\SelectGeneratorInterface;

class PublicationSelectGenerator implements SelectGeneratorInterface
{
    use DoctorantServiceAwareTrait;

    private string $urlTemplate = '/search/?q=authIdHal_i:%s&rows=10&wt=json&fl=idHal_s,title_s,authFullName_s,publicationDate_s,halId_s,publisher_s,uri_s';
    private ?array $idsHal = null;

    public function getSelects(): array
    {
//        if ($this->idsHal) {
//            $this->idsHal = $this->fetchIdsHal();
//        }
        $this->idsHal = ['201165233', '201165233'];

        return array_map(
            fn($id) => sprintf($this->urlTemplate, $id),
            $this->idsHal
        );
    }

    private function fetchIdsHal(): array
    {
        $rows = $this->doctorantService->getRepository()->findByText($text = 'gaut', 10);
        if (count($rows) === 0) {
            throw new RuntimeException(sprintf("La recherche de doctorant '%s' n'a retourné aucun résultat !", $text));
        }

        $idsHal = array_filter(array_map(fn(array $row) => $row['id_hal'], $rows));
        if (count($idsHal) === 0) {
            throw new RuntimeException("Aucun id HAL obtenu !");
        }

        return $idsHal;
    }
}
 No newline at end of file
+21 −0
Changes for module/Portfolio/src/Portfolio/Service/PublicationSelectGeneratorFactory.php: 21 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Portfolio\Service;

use Doctorant\Service\DoctorantService;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerInterface;

class PublicationSelectGeneratorFactory implements FactoryInterface
{
    public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): PublicationSelectGenerator
    {
        $service = new PublicationSelectGenerator();

        /** @var DoctorantService $doctorantService */
        $doctorantService = $container->get(DoctorantService::class);
        $service->setDoctorantService($doctorantService);

        return $service;
    }
}
 No newline at end of file