BaseSearch
in package
implements
SearchInterface
Implements basic OAI-PMH search. It is assumed that all OAI-PMH search facets (id, date, set) and data required to create <header> nodes (again id, date, set) are accessible as repository resource's metadata RDF properties.
Mappings between OAI-PMH terms (id, date, set) and RDF properties is provided
by the statically initialized acdhOeaw\util\RepoConfig
class.
Includes metadataClass::extendSearchQuery()
SPARQL query part in the
performed search (where metadataClass
is read from the metadata format
descriptor).
Tags
Table of Contents
Interfaces
- SearchInterface
- Interface for classes implementing OAI-PMH resources search.
Properties
- $config : object
- Configuration object
- $deleted : DeletedInterface
- Object handling deleted resources information
- $format : MetadataFormat|null
- Metadata format descriptor.
- $pdo : PDO
- Repistory database connection object
- $records : array<string|int, HeaderData>
- Last search results
- $repo : RepoDb
- High-level repository API handle object
- $resumptionCount : int
- Total number of resources of the original search read from the resumption dump file
- $resumptionCursor : int
- Value of the resumptionCursor attribute read from the resumption dump file
- $resumptionToken : string|null
- Resumption token value used
- $sets : SetInterface
- Object handling sets
- $t0 : int
- Object creation timestamp. Used to determine resumption timeout.
Methods
- __construct() : mixed
- Creates a search engine object.
- checkResumptionTimeout() : bool
- Checks if the timeout for resumption token generation has been reached.
- find() : void
- Performs search using given filter values.
- findResumptionToken() : string
- Reads search results based on the resumption token.
- getCount() : int
- Returns number of resources matching last search (last call of the `find()` method).
- getHeader() : HeaderData
- Provides the `HeaderData` object for a given search result.
- getMetadata() : MetadataInterface
- Provides the `MetadataInterface` object for a given search result.
- getResumptionToken() : ResumptionTokenData
- Saves the current search in a way it can be recreated from the resumption token and returns the resumption token data.
- setLogger() : void
- Sets a logger for the search object
- setMetadataFormat() : void
- Sets metadata format configuration
- getDateFilter() : QueryPart
- Creates SPARQL clauses implementing the date filter.
- getIdFilter() : QueryPart
- Creates SPARQL query clause implementing the id filter.
- getSetFilter() : QueryPart
- Creates SPARQL clause implementing the set filter.
Properties
$config
Configuration object
private
object
$config
$deleted
Object handling deleted resources information
private
DeletedInterface
$deleted
$format
Metadata format descriptor.
private
MetadataFormat|null
$format
$pdo
Repistory database connection object
private
PDO
$pdo
$records
Last search results
private
array<string|int, HeaderData>
$records
= []
$repo
High-level repository API handle object
private
RepoDb
$repo
$resumptionCount
Total number of resources of the original search read from the resumption dump file
private
int
$resumptionCount
$resumptionCursor
Value of the resumptionCursor attribute read from the resumption dump file
private
int
$resumptionCursor
= 0
$resumptionToken
Resumption token value used
private
string|null
$resumptionToken
$sets
Object handling sets
private
SetInterface
$sets
$t0
Object creation timestamp. Used to determine resumption timeout.
private
int
$t0
Methods
__construct()
Creates a search engine object.
public
__construct(SetInterface $sets, DeletedInterface $deleted, object $config, PDO $pdo) : mixed
Parameters
- $sets : SetInterface
- $deleted : DeletedInterface
- $config : object
-
configuration object
- $pdo : PDO
-
repository database connection object
checkResumptionTimeout()
Checks if the timeout for resumption token generation has been reached.
public
checkResumptionTimeout() : bool
If it is reached, returns true.
Return values
boolfind()
Performs search using given filter values.
public
find(string $id, string $from, string $until, string $set) : void
Parameters
- $id : string
-
id filter value
- $from : string
-
date from filter value
- $until : string
-
date to filter value
- $set : string
-
set filter value
findResumptionToken()
Reads search results based on the resumption token.
public
findResumptionToken(string $token) : string
Parameters
- $token : string
Return values
stringgetCount()
Returns number of resources matching last search (last call of the `find()` method).
public
getCount() : int
Return values
intgetHeader()
Provides the `HeaderData` object for a given search result.
public
getHeader(int $pos) : HeaderData
Parameters
- $pos : int
-
seach result resource index
Return values
HeaderDatagetMetadata()
Provides the `MetadataInterface` object for a given search result.
public
getMetadata(int $pos) : MetadataInterface
Parameters
- $pos : int
-
seach result resource index
Return values
MetadataInterfacegetResumptionToken()
Saves the current search in a way it can be recreated from the resumption token and returns the resumption token data.
public
getResumptionToken(int $pos) : ResumptionTokenData
Parameters
- $pos : int
-
index of last read resource
Return values
ResumptionTokenDatasetLogger()
Sets a logger for the search object
public
setLogger(AbstractLogger $log) : void
Parameters
- $log : AbstractLogger
setMetadataFormat()
Sets metadata format configuration
public
setMetadataFormat(MetadataFormat|null $format) : void
Parameters
- $format : MetadataFormat|null
-
metadata format descriptor
getDateFilter()
Creates SPARQL clauses implementing the date filter.
private
getDateFilter(string $from, string $until) : QueryPart
Parameters
- $from : string
-
date from filter value
- $until : string
-
date to filter value
Return values
QueryPartgetIdFilter()
Creates SPARQL query clause implementing the id filter.
private
getIdFilter(string $id) : QueryPart
Parameters
- $id : string
-
id filter value
Return values
QueryPartgetSetFilter()
Creates SPARQL clause implementing the set filter.
private
getSetFilter(string $set) : QueryPart
Parameters
- $set : string
-
set filter value