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

WIP Bertrand select generator & data extractor

parent fe284de0
Loading
Loading
Loading
Loading
+6 −0
Changes for module/Portfolio/config/module.config.php: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ namespace Portfolio;

use Application\Navigation\ApplicationNavigationFactory;
use Laminas\Router\Http\Segment;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Portfolio\Assertion\PortfolioAssertion;
use Portfolio\Assertion\PortfolioAssertionFactory;
use Portfolio\Controller\PortfolioController;
@@ -12,8 +13,10 @@ use Portfolio\Facade\PortfolioFacadeFactory;
use Portfolio\Provider\Privilege\PortfolioPrivileges;
use Portfolio\Service\Exporter\PortfolioExporter;
use Portfolio\Service\Exporter\PortfolioExporterFactory;
use Portfolio\Service\GeneratoredSelectGenerator;
use Portfolio\Service\PublicationSelectGenerator;
use Portfolio\Service\PublicationSelectGeneratorFactory;
use Portfolio\Service\IteratorSelectGenerator;
use UnicaenPrivilege\Guard\PrivilegeController;
use UnicaenPrivilege\Provider\Rule\PrivilegeRuleProvider;

@@ -143,6 +146,9 @@ return [
            PortfolioExporter::class => PortfolioExporterFactory::class,

            PublicationSelectGenerator::class => PublicationSelectGeneratorFactory::class,
            // todo supprimer après tests :
            IteratorSelectGenerator::class => InvokableFactory::class,
            GeneratoredSelectGenerator::class => InvokableFactory::class,
        ],
    ],
    'view_manager' => [
+17 −0
Changes for module/Portfolio/src/Portfolio/Service/GeneratoredSelectGenerator.php: 17 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Portfolio\Service;

use UnicaenDbImport\Domain\SelectGeneratorInterface;

class GeneratoredSelectGenerator implements SelectGeneratorInterface
{
    public function getSelects(): iterable
    {
        $idsHal = ['201165233', '201165233', '201165233'];

        foreach ($idsHal as $idHal) {
            yield $idHal;
        }
    }
}
 No newline at end of file
+16 −0
Changes for module/Portfolio/src/Portfolio/Service/IteratorSelectGenerator.php: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?php

namespace Portfolio\Service;

use ArrayIterator;
use UnicaenDbImport\Domain\SelectGeneratorInterface;

class IteratorSelectGenerator implements SelectGeneratorInterface
{
    public function getSelects(): iterable
    {
        $idsHal = ['201165233', '201165233', '201165233'];

        return new ArrayIterator($idsHal);
    }
}
 No newline at end of file
+7 −5
Changes for module/Portfolio/src/Portfolio/Service/PublicationSelectGenerator.php: 7 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -10,15 +10,15 @@ 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 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 string $urlTemplate = '/search/?q=authIdHal_s:%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'];
        if ($this->idsHal === null) {
            $this->idsHal = $this->fetchIdsHal();
        }

        return array_map(
            fn($id) => sprintf($this->urlTemplate, $id),
@@ -28,6 +28,8 @@ class PublicationSelectGenerator implements SelectGeneratorInterface

    private function fetchIdsHal(): array
    {
        return ['*metivier', 'christophe-gaquiere', 'natalie-malikova', 'emmanuelle-dubois'];

        $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));