Skip to content

Commit

Permalink
MetaData: pull search stuff out of repository
Browse files Browse the repository at this point in the history
  • Loading branch information
schmitz-ilias committed Sep 26, 2024
1 parent 37a4980 commit 1eb4c45
Show file tree
Hide file tree
Showing 44 changed files with 194 additions and 155 deletions.
9 changes: 2 additions & 7 deletions Services/MetaData/classes/Copyright/Search/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,24 @@

namespace ILIAS\MetaData\Copyright\Search;

use ILIAS\MetaData\Repository\RepositoryInterface as LOMRepository;
use ILIAS\MetaData\Repository\Search\Filters\FactoryInterface as SearchFilterFactory;
use ILIAS\MetaData\Repository\Search\Clauses\FactoryInterface as SearchClauseFactory;
use ILIAS\MetaData\Search\Filters\FactoryInterface as SearchFilterFactory;
use ILIAS\MetaData\Search\Clauses\FactoryInterface as SearchClauseFactory;
use ILIAS\MetaData\Paths\FactoryInterface as PathFactory;
use ILIAS\MetaData\Copyright\Identifiers\HandlerInterface as CopyrightIdentifierHandler;

class Factory implements FactoryInterface
{
protected LOMRepository $lom_repository;
protected SearchFilterFactory $search_filter_factory;
protected SearchClauseFactory $search_clause_factory;
protected PathFactory $path_factory;
protected CopyrightIdentifierHandler $copyright_identifier_handler;

public function __construct(
LOMRepository $lom_repository,
SearchFilterFactory $search_filter_factory,
SearchClauseFactory $search_clause_factory,
PathFactory $path_factory,
CopyrightIdentifierHandler $copyright_identifier_handler,
) {
$this->lom_repository = $lom_repository;
$this->search_filter_factory = $search_filter_factory;
$this->search_clause_factory = $search_clause_factory;
$this->path_factory = $path_factory;
Expand All @@ -51,7 +47,6 @@ public function __construct(
public function get(): SearcherInterface
{
return new Searcher(
$this->lom_repository,
$this->search_filter_factory,
$this->search_clause_factory,
$this->path_factory,
Expand Down
8 changes: 6 additions & 2 deletions Services/MetaData/classes/Copyright/Search/NullSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@

namespace ILIAS\MetaData\Copyright\Search;

use ILIAS\MetaData\Repository\RepositoryInterface as LOMRepository;
use ILIAS\MetaData\Elements\RessourceID\RessourceIDInterface;

class NullSearcher implements SearcherInterface
{
/**
* @return RessourceIDInterface[]
*/
public function search(int $first_entry_id, int ...$further_entry_ids): \Generator
{
public function search(
LOMRepository $lom_repository,
int $first_entry_id,
int ...$further_entry_ids
): \Generator {
yield from [];
}

Expand Down
22 changes: 11 additions & 11 deletions Services/MetaData/classes/Copyright/Search/Searcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,16 @@

use ILIAS\MetaData\Elements\RessourceID\RessourceIDInterface;
use ILIAS\MetaData\Repository\RepositoryInterface as LOMRepository;
use ILIAS\MetaData\Repository\Search\Filters\FactoryInterface as SearchFilterFactory;
use ILIAS\MetaData\Repository\Search\Clauses\FactoryInterface as SearchClauseFactory;
use ILIAS\MetaData\Search\Filters\FactoryInterface as SearchFilterFactory;
use ILIAS\MetaData\Search\Clauses\FactoryInterface as SearchClauseFactory;
use ILIAS\MetaData\Paths\FactoryInterface as PathFactory;
use ILIAS\MetaData\Copyright\Identifiers\HandlerInterface as CopyrightIdentifierHandler;
use ILIAS\MetaData\Repository\Search\Clauses\Mode;
use ILIAS\MetaData\Repository\Search\Clauses\Operator;
use ILIAS\MetaData\Repository\Search\Filters\Placeholder;
use ILIAS\MetaData\Search\Clauses\Mode;
use ILIAS\MetaData\Search\Clauses\Operator;
use ILIAS\MetaData\Search\Filters\Placeholder;

class Searcher implements SearcherInterface
{
protected LOMRepository $lom_repository;
protected SearchFilterFactory $search_filter_factory;
protected SearchClauseFactory $search_clause_factory;
protected PathFactory $path_factory;
Expand All @@ -45,13 +44,11 @@ class Searcher implements SearcherInterface
protected bool $restricted_to_repo_objects = false;

public function __construct(
LOMRepository $lom_repository,
SearchFilterFactory $search_filter_factory,
SearchClauseFactory $search_clause_factory,
PathFactory $path_factory,
CopyrightIdentifierHandler $copyright_identifier_handler,
) {
$this->lom_repository = $lom_repository;
$this->search_filter_factory = $search_filter_factory;
$this->search_clause_factory = $search_clause_factory;
$this->path_factory = $path_factory;
Expand All @@ -61,8 +58,11 @@ public function __construct(
/**
* @return RessourceIDInterface[]
*/
public function search(int $first_entry_id, int ...$further_entry_ids): \Generator
{
public function search(
LOMRepository $lom_repository,
int $first_entry_id,
int ...$further_entry_ids
): \Generator {
$path_to_copyright = $this->path_factory->custom()
->withNextStep('rights')
->withNextStep('description')
Expand Down Expand Up @@ -102,7 +102,7 @@ public function search(int $first_entry_id, int ...$further_entry_ids): \Generat
);
}

yield from $this->lom_repository->searchMD($full_search_clause, null, null, ...$filters);
yield from $lom_repository->searchMD($full_search_clause, null, null, ...$filters);
}

public function withRestrictionToRepositoryObjects(bool $restricted): SearcherInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@

namespace ILIAS\MetaData\Copyright\Search;

use ILIAS\MetaData\Repository\RepositoryInterface as LOMRepository;
use ILIAS\MetaData\Elements\RessourceID\RessourceIDInterface;

interface SearcherInterface
{
/**
* @return RessourceIDInterface[]
*/
public function search(int $first_entry_id, int ...$further_entry_ids): \Generator;
public function search(
LOMRepository $lom_repository,
int $first_entry_id,
int ...$further_entry_ids
): \Generator;

public function withRestrictionToRepositoryObjects(bool $restricted): SearcherInterface;

Expand Down
13 changes: 6 additions & 7 deletions Services/MetaData/classes/Copyright/Services/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace ILIAS\MetaData\Copyright\Services;

use ILIAS\DI\Container as GlobalContainer;
use ILIAS\MetaData\Repository\Services\Services as RepositoryServices;
use ILIAS\MetaData\Search\Services\Services as SearchServices;
use ILIAS\MetaData\Paths\Services\Services as PathsServices;
use ILIAS\MetaData\Copyright\RepositoryInterface;
use ILIAS\MetaData\Copyright\DatabaseRepository;
Expand All @@ -40,16 +40,16 @@ class Services
protected FactoryInterface $searcher_factory;

protected GlobalContainer $dic;
protected RepositoryServices $repository_services;
protected SearchServices $search_services;
protected PathsServices $paths_services;

public function __construct(
GlobalContainer $dic,
RepositoryServices $repository_services,
SearchServices $repository_services,
PathsServices $paths_services,
) {
$this->dic = $dic;
$this->repository_services = $repository_services;
$this->search_services = $repository_services;
$this->paths_services = $paths_services;
}

Expand Down Expand Up @@ -88,9 +88,8 @@ public function searcherFactory(): FactoryInterface
return $this->searcher_factory;
}
return $this->searcher_factory = new Factory(
$this->repository_services->repository(),
$this->repository_services->SearchFilterFactory(),
$this->repository_services->SearchClauseFactory(),
$this->search_services->searchFilterFactory(),
$this->search_services->searchClauseFactory(),
$this->paths_services->pathFactory(),
$this->identifiersHandler()
);
Expand Down
5 changes: 5 additions & 0 deletions Services/MetaData/classes/OERHarvester/Harvester.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use ILIAS\MetaData\OERHarvester\ResourceStatus\RepositoryInterface as StatusRepository;
use ILIAS\MetaData\OERHarvester\ExposedRecords\RepositoryInterface as ExposedRecordRepository;
use ILIAS\MetaData\Copyright\Search\FactoryInterface as CopyrightSearchFactory;
use ILIAS\MetaData\Repository\RepositoryInterface as LOMRepository;
use ILIAS\MetaData\OERHarvester\XML\WriterInterface as SimpleDCXMLWriter;
use ILIAS\MetaData\OERHarvester\ExposedRecords\RecordInterface;

Expand All @@ -36,6 +37,7 @@ class Harvester
protected StatusRepository $status_repository;
protected ExposedRecordRepository $exposed_record_repository;
protected CopyrightSearchFactory $copyright_search_factory;
protected LOMRepository $lom_repository;
protected SimpleDCXMLWriter $xml_writer;
protected \ilLogger $logger;

Expand All @@ -45,6 +47,7 @@ public function __construct(
StatusRepository $status_repository,
ExposedRecordRepository $exposed_record_repository,
CopyrightSearchFactory $copyright_search_factory,
LOMRepository $lom_repository,
SimpleDCXMLWriter $xml_writer,
\ilLogger $logger
) {
Expand All @@ -53,6 +56,7 @@ public function __construct(
$this->status_repository = $status_repository;
$this->exposed_record_repository = $exposed_record_repository;
$this->copyright_search_factory = $copyright_search_factory;
$this->lom_repository = $lom_repository;
$this->xml_writer = $xml_writer;
$this->logger = $logger;
}
Expand Down Expand Up @@ -101,6 +105,7 @@ protected function findHarvestableObjectIDs(): array
}
$search_results = [];
foreach ($searcher->search(
$this->lom_repository,
...$this->settings->getCopyrightEntryIDsSelectedForHarvesting()
) as $ressource_id) {
$search_results[] = $ressource_id->objID();
Expand Down
1 change: 1 addition & 0 deletions Services/MetaData/classes/OERHarvester/Initiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function harvester(): Harvester
$this->services->OERHarvester()->statusRepository(),
new DatabaseRepository($this->services->dic()->database()),
$this->services->copyright()->searcherFactory(),
$this->services->repository()->repository(),
new Writer(
$this->services->repository()->repository(),
$this->services->xml()->simpleDCWriter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
use ILIAS\MetaData\Paths\PathInterface;
use ILIAS\MetaData\Repository\Utilities\DatabaseReaderInterface;
use ILIAS\MetaData\Elements\RessourceID\RessourceIDFactoryInterface;
use ILIAS\MetaData\Repository\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Repository\Search\Filters\FilterInterface;
use ILIAS\MetaData\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Search\Filters\FilterInterface;
use ILIAS\MetaData\Repository\Utilities\Queries\DatabaseSearcherInterface;
use ILIAS\MetaData\Repository\IdentifierHandler\IdentifierHandlerInterface;

Expand Down
4 changes: 2 additions & 2 deletions Services/MetaData/classes/Repository/NullRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
use ILIAS\MetaData\Elements\SetInterface;
use ILIAS\MetaData\Paths\PathInterface;
use ILIAS\MetaData\Elements\RessourceID\RessourceIDInterface;
use ILIAS\MetaData\Repository\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Repository\Search\Filters\FilterInterface;
use ILIAS\MetaData\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Search\Filters\FilterInterface;

class NullRepository implements RepositoryInterface
{
Expand Down
4 changes: 2 additions & 2 deletions Services/MetaData/classes/Repository/RepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
use ILIAS\MetaData\Elements\SetInterface;
use ILIAS\MetaData\Paths\PathInterface;
use ILIAS\MetaData\Elements\RessourceID\RessourceIDInterface;
use ILIAS\MetaData\Repository\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Repository\Search\Filters\FilterInterface;
use ILIAS\MetaData\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Search\Filters\FilterInterface;

interface RepositoryInterface
{
Expand Down
22 changes: 0 additions & 22 deletions Services/MetaData/classes/Repository/Services/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
use ILIAS\MetaData\Repository\Utilities\Queries\DatabaseQuerier;
use ILIAS\MetaData\Repository\Utilities\Queries\Results\ResultFactory;
use ILIAS\MetaData\Repository\Utilities\Queries\Assignments\AssignmentFactory;
use ILIAS\Metadata\Repository\Search\Clauses\FactoryInterface as ClauseFactoryInterface;
use ILIAS\MetaData\Repository\Search\Filters\FactoryInterface as FilterFactoryInterface;
use ILIAS\MetaData\Repository\Search\Clauses\Factory as ClauseFactory;
use ILIAS\MetaData\Repository\Search\Filters\Factory as FilterFactory;
use ILIAS\MetaData\Repository\Utilities\Queries\DatabaseSearcher;
use ILIAS\MetaData\Repository\Utilities\Queries\Paths\DatabasePathsParserFactory;
use ILIAS\MetaData\Repository\IdentifierHandler\IdentifierHandler;
Expand All @@ -59,8 +55,6 @@ class Services
protected RepositoryInterface $repository;
protected ValidationDictionary $validation_dictionary;
protected RepositoryDictionary $repository_dictionary;
protected ClauseFactoryInterface $search_clause_factory;
protected FilterFactoryInterface $search_filter_factory;


protected GlobalContainer $dic;
Expand Down Expand Up @@ -169,20 +163,4 @@ public function repository(): RepositoryInterface
)
);
}

public function SearchClauseFactory(): ClauseFactoryInterface
{
if (isset($this->search_clause_factory)) {
return $this->search_clause_factory;
}
return $this->search_clause_factory = new ClauseFactory();
}

public function SearchFilterFactory(): FilterFactoryInterface
{
if (isset($this->search_filter_factory)) {
return $this->search_filter_factory;
}
return $this->search_filter_factory = new FilterFactory();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@

namespace ILIAS\MetaData\Repository\Utilities\Queries;

use ILIAS\MetaData\Repository\Search\Filters\FilterInterface;
use ILIAS\MetaData\Search\Filters\FilterInterface;
use ILIAS\MetaData\Elements\RessourceID\RessourceIDFactoryInterface;
use ILIAS\MetaData\Repository\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Repository\Search\Clauses\Operator;
use ILIAS\MetaData\Repository\Search\Clauses\Mode;
use ILIAS\MetaData\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Search\Clauses\Operator;
use ILIAS\MetaData\Search\Clauses\Mode;
use ILIAS\MetaData\Paths\PathInterface;
use ILIAS\MetaData\Repository\Utilities\Queries\Paths\DatabasePathsParserFactoryInterface;
use ILIAS\MetaData\Repository\Utilities\Queries\Paths\DatabasePathsParserInterface;
use ILIAS\MetaData\Repository\Search\Filters\Placeholder;
use ILIAS\MetaData\Repository\Search\Clauses\Properties\BasicPropertiesInterface;
use ILIAS\MetaData\Search\Filters\Placeholder;
use ILIAS\MetaData\Search\Clauses\Properties\BasicPropertiesInterface;

class DatabaseSearcher implements DatabaseSearcherInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

namespace ILIAS\MetaData\Repository\Utilities\Queries;

use ILIAS\MetaData\Repository\Search\Filters\FilterInterface;
use ILIAS\MetaData\Repository\Search\Clauses\ClauseInterface;
use ILIAS\MetaData\Search\Filters\FilterInterface;
use ILIAS\MetaData\Search\Clauses\ClauseInterface;

interface DatabaseSearcherInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

declare(strict_types=1);

namespace ILIAS\MetaData\Repository\Search\Clauses;
namespace ILIAS\MetaData\Search\Clauses;

use ILIAS\MetaData\Repository\Search\Clauses\Properties\JoinPropertiesInterface;
use ILIAS\MetaData\Repository\Search\Clauses\Properties\BasicPropertiesInterface;
use ILIAS\MetaData\Search\Clauses\Properties\JoinPropertiesInterface;
use ILIAS\MetaData\Search\Clauses\Properties\BasicPropertiesInterface;

class Clause implements ClauseInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

declare(strict_types=1);

namespace ILIAS\MetaData\Repository\Search\Clauses;
namespace ILIAS\MetaData\Search\Clauses;

use ILIAS\MetaData\Repository\Search\Clauses\Properties\JoinPropertiesInterface;
use ILIAS\MetaData\Repository\Search\Clauses\Properties\BasicPropertiesInterface;
use ILIAS\MetaData\Search\Clauses\Properties\JoinPropertiesInterface;
use ILIAS\MetaData\Search\Clauses\Properties\BasicPropertiesInterface;

interface ClauseInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

declare(strict_types=1);

namespace ILIAS\MetaData\Repository\Search\Clauses;
namespace ILIAS\MetaData\Search\Clauses;

use ILIAS\MetaData\Paths\PathInterface;
use ILIAS\MetaData\Repository\Search\Clauses\Properties\JoinProperties;
use ILIAS\MetaData\Repository\Search\Clauses\Properties\BasicProperties;
use ILIAS\MetaData\Search\Clauses\Properties\JoinProperties;
use ILIAS\MetaData\Search\Clauses\Properties\BasicProperties;

class Factory implements FactoryInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

declare(strict_types=1);

namespace ILIAS\MetaData\Repository\Search\Clauses;
namespace ILIAS\MetaData\Search\Clauses;

use ILIAS\MetaData\Paths\PathInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

declare(strict_types=1);

namespace ILIAS\MetaData\Repository\Search\Clauses;
namespace ILIAS\MetaData\Search\Clauses;

enum Mode: string
{
Expand Down
Loading

0 comments on commit 1eb4c45

Please sign in to comment.