VuFind API Documentation

DAIA extends AbstractBase
in package
implements HttpServiceAwareInterface, LoggerAwareInterface Uses CacheTrait, HttpServiceAwareTrait, LoggerAwareTrait

ILS Driver for VuFind to query availability information via DAIA.

Tags
category

VuFind

author

Jochen Lienhard lienhard@ub.uni-freiburg.de

author

Oliver Goldschmidt o.goldschmidt@tu-harburg.de

author

André Lahmann lahmann@ub.uni-leipzig.de

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Interfaces, Classes, Traits and Enums

HttpServiceAwareInterface
LoggerAwareInterface

Table of Contents

$baseUrl  : string
Base URL for DAIA Service
$cache  : StorageInterface
Cache for storing data temporarily (e.g. patron blocks with the ILS driver)
$cacheLifetime  : int
Lifetime of cache (in seconds).
$config  : array<string|int, mixed>
Driver configuration
$contentTypesRequest  : array<string|int, mixed>
ContentTypes to use in DAIA HTTP requests in HTTP header
$contentTypesResponse  : array<string|int, mixed>
Acceptable ContentTypes delivered by DAIA server in HTTP header
$daiaCacheEnabled  : bool
Flag to switch on/off caching for DAIA items
$daiaIdPrefix  : string
DAIA query identifier prefix
$daiaResponseFormat  : string
DAIA response format
$daiaTimeout  : string
Timeout in seconds to be used for DAIA http requests
$dateConverter  : Converter
Date converter object
$multiQuery  : bool
Flag to enable multiple DAIA-queries
__construct()  : mixed
Constructor
getConfig()  : array<string|int, mixed>
Public Function which retrieves renew, hold and cancel settings from the driver ini file.
getHolding()  : array<string|int, mixed>
Get Holding
getHoldLink()  : string
Get Hold Link
getPurchaseHistory()  : array<string|int, mixed>
Get Purchase History
getStatus()  : mixed
Get Status
getStatuses()  : array<string|int, mixed>
Get Statuses
init()  : void
Initialize the driver.
setCacheStorage()  : void
Set a cache storage object.
setConfig()  : void
Set configuration.
checkIsRecallable()  : bool
Helper function to determine if item is recallable.
checkIsStorageRetrievalRequest()  : bool
Helper function to determine if the item is available as storage retrieval.
convertDaiaXmlToJson()  : mixed
Converts a DAIA XML response to an array identical with a DAIA JSON response for the sent query.
convertDate()  : string
Support method to handle date uniformly
convertDatetime()  : string
Support method to handle datetime uniformly
debug()  : void
Log a debug message.
doHTTPRequest()  : xml
Perform an HTTP request.
extractDaiaDoc()  : array<string|int, mixed>|DOMNode|null
Extract a DAIA document identified by an id
generateMultiURIs()  : string
Combine several ids to DAIA Query API conform URIs
generateURI()  : string
Generate a DAIA URI necessary for the query
getAvailableItemServices()  : array<string|int, mixed>
Returns the available services of the given set of available and unavailable services
getCachedData()  : mixed|null
Helper function for fetching cached data.
getCacheKey()  : string
DAIA specific override of method to ensure uniform cache keys for cached VuFind objects.
getCustomData()  : array<string|int, mixed>
Helper function to allow custom data in status array.
getHoldType()  : string
Helper function to determine the holdtype available for current item.
getItemBarcode()  : string
Returns the value for "location" in VuFind getStatus/getHolding array
getItemCallnumber()  : string
Returns the value for "callnumber" in VuFind getStatus/getHolding array
getItemDepartment()  : string
Returns the value of item.department.content (e.g. to be used in VuFind getStatus/getHolding array as location)
getItemDepartmentId()  : string
Returns the value of item.department.id (e.g. to be used in VuFind getStatus/getHolding array as location)
getItemDepartmentLink()  : string
Returns the value of item.department.href (e.g. to be used in VuFind getStatus/getHolding array for linking the location)
getItemLimitation()  : array<string|int, mixed>
Returns the evaluated value of the provided limitation element
getItemLimitationContent()  : array<string|int, mixed>
Returns the evaluated values of the provided limitations element
getItemLimitationTypes()  : array<string|int, mixed>
Returns the evaluated values of the provided limitations element
getItemNumber()  : mixed
Returns the value for "number" in VuFind getStatus/getHolding array
getItemReserveStatus()  : string
Returns the value for "reserve" in VuFind getStatus/getHolding array
getItemStatus()  : array<string|int, mixed>
Returns an array with status information for provided item.
getItemStorage()  : string
Returns the value of item.storage.content (e.g. to be used in VuFind getStatus/getHolding array as location)
getItemStorageId()  : string
Returns the value of item.storage.id (e.g. to be used in VuFind getStatus/getHolding array as location)
getItemStorageLink()  : string
Returns the value of item.storage.href (e.g. to be used in VuFind getStatus/getHolding array for linking the location)
getStatusString()  : string
Helper function to return an appropriate status string for current item.
log()  : void
Send a message to the logger.
logError()  : void
Log an error message.
logMessages()  : void
Logs content of message elements in DAIA response for debugging
logWarning()  : void
Log a warning message.
parseDaiaArray()  : array<string|int, mixed>
Parse an array with DAIA status information.
parseDaiaDoc()  : array<string|int, mixed>
Parse a DAIA document depending on its type.
putCachedData()  : void
Helper function for storing cached data.
removeCachedData()  : void
Helper function for removing cached data.
throwAsIlsException()  : never
Rethrow the provided exception as an ILS exception.

Properties

$baseUrl

Base URL for DAIA Service

protected string $baseUrl

$cache

Cache for storing data temporarily (e.g. patron blocks with the ILS driver)

protected StorageInterface $cache = null

$cacheLifetime

Lifetime of cache (in seconds).

protected int $cacheLifetime = 30

$config

Driver configuration

protected array<string|int, mixed> $config = []

$contentTypesRequest

ContentTypes to use in DAIA HTTP requests in HTTP header

protected array<string|int, mixed> $contentTypesRequest = ['xml' => 'application/xml', 'json' => 'application/json']

$contentTypesResponse

Acceptable ContentTypes delivered by DAIA server in HTTP header

protected array<string|int, mixed> $contentTypesResponse

$daiaCacheEnabled

Flag to switch on/off caching for DAIA items

protected bool $daiaCacheEnabled = false

$daiaIdPrefix

DAIA query identifier prefix

protected string $daiaIdPrefix

$daiaResponseFormat

DAIA response format

protected string $daiaResponseFormat

$daiaTimeout

Timeout in seconds to be used for DAIA http requests

protected string $daiaTimeout = null

$dateConverter

Date converter object

protected Converter $dateConverter

$multiQuery

Flag to enable multiple DAIA-queries

protected bool $multiQuery = false

Methods

__construct()

Constructor

public __construct(Converter $converter) : mixed
Parameters
$converter : Converter

Date converter

Return values
mixed

getConfig()

Public Function which retrieves renew, hold and cancel settings from the driver ini file.

public getConfig(string $function[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
$function : string

The name of the feature to be checked

$params : array<string|int, mixed> = []

Optional feature-specific parameters (array)

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
array<string|int, mixed>

An array with key-value pairs.

getHolding()

Get Holding

public getHolding(string $id[, array<string|int, mixed> $patron = null ][, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>

This is responsible for retrieving the holding information of a certain record.

Parameters
$id : string

The record id to retrieve the holdings for

$patron : array<string|int, mixed> = null

Patron data

$options : array<string|int, mixed> = []

Extra options (not currently used)

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
array<string|int, mixed>

On success, an associative array with the following keys: id, availability (boolean), status, location, reserve, callnumber, duedate, number, barcode.

Get Hold Link

public getHoldLink(string $id, array<string|int, mixed> $details) : string

The goal for this method is to return a URL to a "place hold" web page on the ILS OPAC. This is used for ILSs that do not support an API or method to place Holds.

Parameters
$id : string

The id of the bib record

$details : array<string|int, mixed>

Item details from getHoldings return array

Tags
SuppressWarnings

(PHPMD.UnusedFormalParameter)

Return values
string

URL to ILS's OPAC's place hold screen.

getPurchaseHistory()

Get Purchase History

public getPurchaseHistory(string $id) : array<string|int, mixed>

This is responsible for retrieving the acquisitions history data for the specific record (usually recently received issues of a serial).

Parameters
$id : string

The record id to retrieve the info for

Tags
throws
ILS
Return values
array<string|int, mixed>

An array with the acquisitions data on success.

getStatus()

Get Status

public getStatus(string $id) : mixed

This is responsible for retrieving the status information of a certain record.

Parameters
$id : string

The record id to retrieve the holdings for

Return values
mixed

On success, an associative array with the following keys: id, availability (boolean), status, location, reserve, callnumber.

getStatuses()

Get Statuses

public getStatuses(array<string|int, mixed> $ids) : array<string|int, mixed>

This is responsible for retrieving the status information for a collection of records. As the DAIA Query API supports querying multiple ids simultaneously (all ids divided by "|") getStatuses(ids) would call getStatus(id) only once, id containing the list of ids to be retrieved. This would cause some trouble as the list of ids does not necessarily correspond to the VuFind Record-id. Therefore getStatuses(ids) has its own logic for multiQuery-support and performs the HTTPRequest itself, retrieving one DAIA response for all ids and uses helper functions to split this one response into documents corresponding to the queried ids.

Parameters
$ids : array<string|int, mixed>

The array of record ids to retrieve the status for

Return values
array<string|int, mixed>

An array of status information values on success.

init()

Initialize the driver.

public init() : void

Validate configuration and perform all resource-intensive tasks needed to make the driver active.

Tags
throws
ILS
Return values
void

setCacheStorage()

Set a cache storage object.

public setCacheStorage([StorageInterface $cache = null ]) : void
Parameters
$cache : StorageInterface = null

Cache storage interface

Return values
void

setConfig()

Set configuration.

public setConfig(array<string|int, mixed> $config) : void

Set the configuration for the driver.

Parameters
$config : array<string|int, mixed>

Configuration array (usually loaded from a VuFind .ini file whose name corresponds with the driver class name).

Return values
void

checkIsRecallable()

Helper function to determine if item is recallable.

protected checkIsRecallable(array<string|int, mixed> $item) : bool

DAIA does not genuinly allow distinguishing between holdable and recallable items. This could be achieved by usage of limitations but this would not be shared functionality between different DAIA implementations (thus should be implemented in custom drivers). Therefore this returns whether an item is recallable based on unavailable services and the existence of an href.

Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
bool

checkIsStorageRetrievalRequest()

Helper function to determine if the item is available as storage retrieval.

protected checkIsStorageRetrievalRequest(array<string|int, mixed> $item) : bool
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
bool

convertDaiaXmlToJson()

Converts a DAIA XML response to an array identical with a DAIA JSON response for the sent query.

protected convertDaiaXmlToJson(string $daiaResponse) : mixed
Parameters
$daiaResponse : string

Response in XML format from DAIA service

Return values
mixed

convertDate()

Support method to handle date uniformly

protected convertDate(string $date) : string
Parameters
$date : string

String representing a date

Return values
string

Formatted date

convertDatetime()

Support method to handle datetime uniformly

protected convertDatetime(string $datetime) : string
Parameters
$datetime : string

String representing a datetime

Return values
string

Formatted datetime

debug()

Log a debug message.

protected debug(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

doHTTPRequest()

Perform an HTTP request.

protected doHTTPRequest(string $id) : xml
Parameters
$id : string

id for query in daia

Tags
throws
ILS
Return values
xml

or json object

extractDaiaDoc()

Extract a DAIA document identified by an id

protected extractDaiaDoc(string $id, string $daiaResponse) : array<string|int, mixed>|DOMNode|null

This method loops through all the existing DAIA document-elements in the given DAIA response and returns the first document whose id matches the given id.

Parameters
$id : string

Record Id of the DAIA document in question.

$daiaResponse : string

Raw response from DAIA request.

Tags
throws
ILS
Return values
array<string|int, mixed>|DOMNode|null

The DAIA document identified by id and type depending on daiaResponseFormat.

generateMultiURIs()

Combine several ids to DAIA Query API conform URIs

protected generateMultiURIs(array<string|int, mixed> $ids) : string
Parameters
$ids : array<string|int, mixed>

Array of ids which shall be converted into URIs and combined for querying multiple DAIA documents.

Tags
see
http://gbv.github.io/daia/daia.html#query-parameters
Return values
string

Combined URIs (delimited by "|")

generateURI()

Generate a DAIA URI necessary for the query

protected generateURI(string $id) : string
Parameters
$id : string

Id of the record whose DAIA document should be queried

Tags
see
http://gbv.github.io/daia/daia.html#query-parameters
Return values
string

URI of the DAIA document

getAvailableItemServices()

Returns the available services of the given set of available and unavailable services

protected getAvailableItemServices(array<string|int, mixed> $services) : array<string|int, mixed>
Parameters
$services : array<string|int, mixed>

Array with DAIA services available/unavailable

Return values
array<string|int, mixed>

getCachedData()

Helper function for fetching cached data.

protected getCachedData(string $key) : mixed|null

Data is cached for up to $this->cacheLifetime.

Parameters
$key : string

Cache entry key

Return values
mixed|null

Cached entry or null if not cached or expired

getCacheKey()

DAIA specific override of method to ensure uniform cache keys for cached VuFind objects.

protected getCacheKey([string|null $suffix = null ]) : string
Parameters
$suffix : string|null = null

Optional suffix that will get appended to the object class name calling getCacheKey()

Return values
string

getCustomData()

Helper function to allow custom data in status array.

protected getCustomData(array<string|int, mixed> $item) : array<string|int, mixed>
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
array<string|int, mixed>

getHoldType()

Helper function to determine the holdtype available for current item.

protected getHoldType(array<string|int, mixed> $item) : string

DAIA does not genuinly allow distinguishing between holdable and recallable items. This could be achieved by usage of limitations but this would not be shared functionality between different DAIA implementations (thus should be implemented in custom drivers). Therefore getHoldType always returns recall.

Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

'recall'|null

getItemBarcode()

Returns the value for "location" in VuFind getStatus/getHolding array

protected getItemBarcode(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

getItemCallnumber()

Returns the value for "callnumber" in VuFind getStatus/getHolding array

protected getItemCallnumber(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

getItemDepartment()

Returns the value of item.department.content (e.g. to be used in VuFind getStatus/getHolding array as location)

protected getItemDepartment(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

getItemDepartmentId()

Returns the value of item.department.id (e.g. to be used in VuFind getStatus/getHolding array as location)

protected getItemDepartmentId(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

Returns the value of item.department.href (e.g. to be used in VuFind getStatus/getHolding array for linking the location)

protected getItemDepartmentLink(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

getItemLimitation()

Returns the evaluated value of the provided limitation element

protected getItemLimitation(array<string|int, mixed> $limitations) : array<string|int, mixed>
Parameters
$limitations : array<string|int, mixed>

Array with DAIA limitation data

Return values
array<string|int, mixed>

getItemLimitationContent()

Returns the evaluated values of the provided limitations element

protected getItemLimitationContent(array<string|int, mixed> $limitations) : array<string|int, mixed>
Parameters
$limitations : array<string|int, mixed>

Array with DAIA limitation data

Return values
array<string|int, mixed>

getItemLimitationTypes()

Returns the evaluated values of the provided limitations element

protected getItemLimitationTypes(array<string|int, mixed> $limitations) : array<string|int, mixed>
Parameters
$limitations : array<string|int, mixed>

Array with DAIA limitation data

Return values
array<string|int, mixed>

getItemNumber()

Returns the value for "number" in VuFind getStatus/getHolding array

protected getItemNumber(array<string|int, mixed> $item, int $counter) : mixed
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

$counter : int

Integer counting items as alternative return value

Return values
mixed

getItemReserveStatus()

Returns the value for "reserve" in VuFind getStatus/getHolding array

protected getItemReserveStatus(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

getItemStatus()

Returns an array with status information for provided item.

protected getItemStatus(array<string|int, mixed> $item) : array<string|int, mixed>
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
array<string|int, mixed>

getItemStorage()

Returns the value of item.storage.content (e.g. to be used in VuFind getStatus/getHolding array as location)

protected getItemStorage(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

getItemStorageId()

Returns the value of item.storage.id (e.g. to be used in VuFind getStatus/getHolding array as location)

protected getItemStorageId(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

Returns the value of item.storage.href (e.g. to be used in VuFind getStatus/getHolding array for linking the location)

protected getItemStorageLink(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

getStatusString()

Helper function to return an appropriate status string for current item.

protected getStatusString(array<string|int, mixed> $item) : string
Parameters
$item : array<string|int, mixed>

Array with DAIA item data

Return values
string

log()

Send a message to the logger.

protected log(string $level, string $message[, array<string|int, mixed> $context = [] ][, bool $prependClass = false ]) : void
Parameters
$level : string

Log level

$message : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = false

Prepend class name to message?

Return values
void

logError()

Log an error message.

protected logError(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

logMessages()

Logs content of message elements in DAIA response for debugging

protected logMessages(array<string|int, mixed> $messages, string $context) : void
Parameters
$messages : array<string|int, mixed>

Array with message elements to be logged

$context : string

Description of current message context

Return values
void

logWarning()

Log a warning message.

protected logWarning(string $msg[, array<string|int, mixed> $context = [] ][, bool $prependClass = true ]) : void
Parameters
$msg : string

Log message

$context : array<string|int, mixed> = []

Log context

$prependClass : bool = true

Prepend class name to message?

Return values
void

parseDaiaArray()

Parse an array with DAIA status information.

protected parseDaiaArray(string $id, array<string|int, mixed> $daiaArray) : array<string|int, mixed>
Parameters
$id : string

Record id for the DAIA array.

$daiaArray : array<string|int, mixed>

Array with raw DAIA status information.

Return values
array<string|int, mixed>

Array with VuFind compatible status information.

parseDaiaDoc()

Parse a DAIA document depending on its type.

protected parseDaiaDoc(string $id, mixed $daiaDoc) : array<string|int, mixed>

Parse a DAIA document depending on its type and return a VuFind compatible array of status information. Supported types are: - array (for JSON results)

Parameters
$id : string

Record Id corresponding to the DAIA document

$daiaDoc : mixed

The DAIA document, only array is supported

Tags
throws
ILS
Return values
array<string|int, mixed>

An array with status information for the record

putCachedData()

Helper function for storing cached data.

protected putCachedData(string $key, mixed $entry[, int $lifetime = null ]) : void

Data is cached for up to $this->cacheLifetime seconds.

Parameters
$key : string

Cache entry key

$entry : mixed

Entry to be cached

$lifetime : int = null

Optional lifetime for the entry in seconds

Return values
void

removeCachedData()

Helper function for removing cached data.

protected removeCachedData(string $key) : void
Parameters
$key : string

Cache entry key

Return values
void

throwAsIlsException()

Rethrow the provided exception as an ILS exception.

protected throwAsIlsException(Throwable $exception[, string $msg = null ]) : never
Parameters
$exception : Throwable

Exception to rethrow

$msg : string = null

Override exception message (optional)

Tags
throws
ILS
Return values
never

Search results