RepoDb
in package
implements
RepoInterface
Uses
RepoTrait
Provides a read only access to the repository on the relational database level.
Tags
Table of Contents
Interfaces
Properties
- $resourceClass : string
- A class used to instantiate objects representing repository resources.
- $auth : AuthInterface|null
- $baseUrl : string
- Repository REST API base URL
- $headers : Schema
- An object providing mappings of repository REST API parameters to HTTP headers used by a given repository instance.
- $highlightParam : array<string|int, string>
- $nonRelationProperties : array<string|int, string>
- $pdo : PDO
- $queryLog : AbstractLogger|null
- $schema : Schema
- An object providing mappings of repository concepts to RDF properties used to denote them by a given repository instance.
Methods
- __construct() : mixed
- factory() : RepoDb
- Creates a repository object instance from a given configuration file.
- getBaseUrl() : string
- Returns the repository REST API base URL.
- getGraphBySearchTerms() : Graph
- Returns RDF metadata graph of the search results.
- getGraphBySqlQuery() : Graph
- Returns RDF metadata graph of the search results.
- getHeaderName() : string
- Returns an HTTP header name to be used to pass a given information in the repository request.
- getMetadataAuthQuery() : QueryPart
- getPdoStatementBySearchTerms() : PDOStatement
- getPdoStatementBySqlQuery() : PDOStatement
- getResourceById() : RepoResourceInterface
- Tries to find a repository resource with a given id.
- getResourceByIds() : RepoResourceDb
- Tries to find a single repository resource matching provided identifiers.
- getResourcesBySearchTerms() : Generator<string|int, RepoResourceDb>
- Returns repository resources matching all provided search terms.
- getResourcesBySqlQuery() : Generator<string|int, RepoResourceDb>
- Performs a search
- getSchema() : Schema
- Returns the `Schema` object defining repository entities to RDF property mappings.
- parsePdoStatement() : Graph
- Parses SQL query results containing resources metadata into an RDF graph.
- runQuery() : PDOStatement
- setQueryLog() : void
- Sets a search queries logger
- getFtsQuery() : QueryPart
- Prepares an SQL query adding a full text search query results as metadata graph edges.
- getOrderByQuery() : array<string|int, QueryPart>
- getPagingQuery() : QueryPart
- logQuery() : void
- parseMetadataReadMode() : array<string|int, int>
- parseSearchGraph() : Generator<string|int, RepoResourceDb>
- sortMatchingResources() : void
Properties
$resourceClass
A class used to instantiate objects representing repository resources.
public
static string
$resourceClass
= '\\acdhOeaw\\arche\\lib\\RepoResourceDb'
To be used by external libraries extending the RepoResource class funcionality provided by this library.
$auth
private
AuthInterface|null
$auth
$baseUrl
Repository REST API base URL
private
string
$baseUrl
$headers
An object providing mappings of repository REST API parameters to HTTP headers used by a given repository instance.
private
Schema
$headers
$highlightParam
private
static array<string|int, string>
$highlightParam
= ['StartSel', 'StopSel', 'MaxWords', 'MinWords', 'ShortWord', 'HighlightAll', 'MaxFragments', 'FragmentDelimiter']
$nonRelationProperties
private
array<string|int, string>
$nonRelationProperties
$pdo
private
PDO
$pdo
$queryLog
private
AbstractLogger|null
$queryLog
$schema
An object providing mappings of repository concepts to RDF properties used to denote them by a given repository instance.
private
Schema
$schema
Methods
__construct()
public
__construct(string $baseUrl, Schema $schema, Schema $headers, PDO $pdo[, array<string|int, string> $nonRelationProperties = [] ][, AuthInterface $auth = null ]) : mixed
Parameters
- $baseUrl : string
- $schema : Schema
- $headers : Schema
- $pdo : PDO
- $nonRelationProperties : array<string|int, string> = []
- $auth : AuthInterface = null
factory()
Creates a repository object instance from a given configuration file.
public
static factory(string $configFile[, string $dbSettings = 'guest' ]) : RepoDb
Automatically parses required config properties and passes them to the RepoDb object constructor.
At the moment it doesn't support authorization provider instantiating.
Parameters
- $configFile : string
-
a path to the YAML config file
- $dbSettings : string = 'guest'
-
database connection variant to read from the config
Return values
RepoDbgetBaseUrl()
Returns the repository REST API base URL.
public
getBaseUrl() : string
Return values
stringgetGraphBySearchTerms()
Returns RDF metadata graph of the search results.
public
getGraphBySearchTerms(array<string|int, SearchTerm> $searchTerms, SearchConfig $config) : Graph
Parameters
- $searchTerms : array<string|int, SearchTerm>
- $config : SearchConfig
Return values
GraphgetGraphBySqlQuery()
Returns RDF metadata graph of the search results.
public
getGraphBySqlQuery(string $query, array<string|int, mixed> $parameters, SearchConfig $config) : Graph
Parameters
- $query : string
- $parameters : array<string|int, mixed>
- $config : SearchConfig
Return values
GraphgetHeaderName()
Returns an HTTP header name to be used to pass a given information in the repository request.
public
getHeaderName(string $purpose) : string
Parameters
- $purpose : string
Return values
stringgetMetadataAuthQuery()
public
getMetadataAuthQuery() : QueryPart
Return values
QueryPartgetPdoStatementBySearchTerms()
public
getPdoStatementBySearchTerms(array<string|int, SearchTerm> $searchTerms, SearchConfig $config) : PDOStatement
Parameters
- $searchTerms : array<string|int, SearchTerm>
- $config : SearchConfig
Return values
PDOStatementgetPdoStatementBySqlQuery()
public
getPdoStatementBySqlQuery(string $query, array<string|int, mixed> $parameters, SearchConfig $config) : PDOStatement
Parameters
- $query : string
- $parameters : array<string|int, mixed>
- $config : SearchConfig
Tags
Return values
PDOStatementgetResourceById()
Tries to find a repository resource with a given id.
public
getResourceById(string $id[, string $class = null ]) : RepoResourceInterface
Throws an error on failure.
Parameters
- $id : string
- $class : string = null
-
an optional class of the resulting object representing the resource (to be used by extension libraries)
Return values
RepoResourceInterfacegetResourceByIds()
Tries to find a single repository resource matching provided identifiers.
public
getResourceByIds(array<string|int, string> $ids[, string $class = null ]) : RepoResourceDb
A resource matches the search if at lest one id matches the provided list. Resource is not required to have all provided ids.
If more then one resources matches the search or there is no resource matching the search, an error is thrown.
Parameters
- $ids : array<string|int, string>
-
an array of identifiers (being strings)
- $class : string = null
-
an optional class of the resulting object representing the resource (to be used by extension libraries)
Tags
Return values
RepoResourceDbgetResourcesBySearchTerms()
Returns repository resources matching all provided search terms.
public
getResourcesBySearchTerms(array<string|int, SearchTerm> $searchTerms, SearchConfig $config) : Generator<string|int, RepoResourceDb>
Parameters
- $searchTerms : array<string|int, SearchTerm>
- $config : SearchConfig
Return values
Generator<string|int, RepoResourceDb>getResourcesBySqlQuery()
Performs a search
public
getResourcesBySqlQuery(string $query, array<string|int, mixed> $parameters, SearchConfig $config) : Generator<string|int, RepoResourceDb>
Parameters
- $query : string
- $parameters : array<string|int, mixed>
- $config : SearchConfig
Return values
Generator<string|int, RepoResourceDb>getSchema()
Returns the `Schema` object defining repository entities to RDF property mappings.
public
getSchema() : Schema
Return values
SchemaparsePdoStatement()
Parses SQL query results containing resources metadata into an RDF graph.
public
parsePdoStatement(PDOStatement $query) : Graph
Parameters
- $query : PDOStatement
Return values
GraphrunQuery()
public
runQuery(string $query, array<string|int, mixed> $param) : PDOStatement
Parameters
- $query : string
- $param : array<string|int, mixed>
Return values
PDOStatementsetQueryLog()
Sets a search queries logger
public
setQueryLog(AbstractLogger $log) : void
Parameters
- $log : AbstractLogger
getFtsQuery()
Prepares an SQL query adding a full text search query results as metadata graph edges.
private
getFtsQuery(SearchConfig $cfg) : QueryPart
Parameters
- $cfg : SearchConfig
Return values
QueryPartgetOrderByQuery()
private
getOrderByQuery(SearchConfig $config) : array<string|int, QueryPart>
Parameters
- $config : SearchConfig
Return values
array<string|int, QueryPart>getPagingQuery()
private
getPagingQuery(SearchConfig $config) : QueryPart
Parameters
- $config : SearchConfig
Return values
QueryPartlogQuery()
private
logQuery(string $query, array<string|int, mixed> $param) : void
Parameters
- $query : string
- $param : array<string|int, mixed>
parseMetadataReadMode()
private
parseMetadataReadMode(string $mode) : array<string|int, int>
Parameters
- $mode : string
Return values
array<string|int, int>parseSearchGraph()
private
parseSearchGraph(Graph $graph, SearchConfig $config) : Generator<string|int, RepoResourceDb>
Parameters
- $graph : Graph
- $config : SearchConfig
Return values
Generator<string|int, RepoResourceDb>sortMatchingResources()
private
sortMatchingResources(array<string|int, resource> &$resources, string $searchOrderProp) : void
Parameters
- $resources : array<string|int, resource>
- $searchOrderProp : string