Skip to content
Snippets Groups Projects
Commit 93d7ba8e authored by Robert Lange's avatar Robert Lange Committed by Dorian Merz
Browse files

refs #17508 [master] handle ill pickup branch

* introduce PAIA options containing pickupbranch
* needed to differentiate between storageId and pickuplocation of ILL items:
** read paiaConditions from FincLibero.ini
** add method 'mapOptions' to read certain or all options of PAIA conditions

for details see issue/17508
parent 4e25eb88
Branches
Tags
No related merge requests found
...@@ -71,6 +71,11 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -71,6 +71,11 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
protected $notificationsPrefix; protected $notificationsPrefix;
/**
* @var array
*/
protected $conditions;
/** /**
* Constructor * Constructor
* *
...@@ -97,6 +102,10 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -97,6 +102,10 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
if (isset($this->config['PAIA']['paiaNotificationsPrefix'])) { if (isset($this->config['PAIA']['paiaNotificationsPrefix'])) {
$this->notificationsPrefix = $this->config['PAIA']['paiaNotificationsPrefix']; $this->notificationsPrefix = $this->config['PAIA']['paiaNotificationsPrefix'];
} }
if (isset($this->config['PAIA']['paiaConditions'])) {
$this->conditions = $this->config['PAIA']['paiaConditions'];
}
} }
/** /**
...@@ -972,6 +981,9 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -972,6 +981,9 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
$result['upc'] = null; $result['upc'] = null;
*/ */
/* #17508 read optional PAIA information like pickupbranch */
$this->mapOptions($doc, $result);
$results[] = $result; $results[] = $result;
} }
return $results; return $results;
...@@ -1511,4 +1523,66 @@ class PAIA extends \VuFind\ILS\Driver\PAIA ...@@ -1511,4 +1523,66 @@ class PAIA extends \VuFind\ILS\Driver\PAIA
// return TRUE on success // return TRUE on success
return true; return true;
} }
/***
* finds conditions in PAIA items array and adds it as options in finc converted items array
*
* Conditions according to PAIA default are only intended for request, renew or cancel
* BUT here used for items too, therefore should be only one option per condition
* see: http://gbv.github.io/paia/paia.html#conditions-and-confirmations
*
* @param array $doc Array of PAIA input to be mapped
* @param array $result Array of PAIA output - called by reference
* @param array|null $configConditions conditions to be considered (optional, if null use config)
*
* @return bool True if any option was found, otherwise false.
*/
protected function mapOptions(array $doc, array &$result, array $configConditions = null): bool
{
$configConditions = $configConditions ?? $this->conditions ?? [];
foreach ($configConditions as $configCondition) {
if ($optionsValues = $doc["condition"][$configCondition]["option"] ?? []) {
$found = $result["options"][$configCondition] = $optionsValues;
}
}
return !empty($found);
}
/**
* Get (first) option for given condition and valid options from finc converted PAIA result
*
* @param string $condition
* @param array $result
* @param boolean $onlyFirst
* @param array $validOptions
*
* @return array of option values: each either valid id or label or null if none set
*/
public function getOptions(string $condition, array $result, bool $onlyFirst, array $validOptions = null): array
{
$retval = [];
if (in_array($condition, $this->conditions)) {
$options = $result['options'][$condition] ?? [];
foreach ($options as $option) {
if (!$validOptions) {
$retval[] = $option['about'] ?? $option['id'] ?? null;
if ($onlyFirst) {
break;
}
} else {
foreach ($validOptions as $validOption) {
if (array_intersect($validOption, $option)) {
$retval[] = $option['id'] ?? $option['about'] ?? null;
if ($onlyFirst) {
break 2;
}
}
}
}
}
}
return $retval;
}
} }
HTTP/1.1 200 OK
Server: vzg-paia/2.2-RC3 (Wed Jun 01 17:38:24 CEST 2016)
Date: Mon, 20 Jun 2020 10:38:21 GMT
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-OAuth-Scopes, X-Accepted-OAuth-Scopes
Access-Control-Allow-Headers: Content-Type, Authorization
Pragma: no-cache
X-OAuth-Scopes: change_password read_items read_fees read_patron
X-Accepted-OAuth-Scopes: read_patron
Content-Type: application/json; charset=UTF-8
{
"doc": [
{
"status": 3,
"item": "DE-Zi4:barcode:03201978",
"about": "Urbanität als Habitus",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 4,
"item": "DE-Zi4:barcode:80086919",
"about": "Fernleihe mit Abholstation",
"condition": {
"http://purl.org/ontology/paia#PickupCondition": {
"option": [
{
"id": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI",
"about": "Zweigbibliothek Zittau",
"amount": "2,50 EUR"
}
]
}
},
"storage": "Hochschulbibliothek Görlitz",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwGR"
},
{
"status": 0,
"item": "ILL:13940",
"about": "Aushandlungen städtischer Größe - Eckert, Anna",
"label": "Medium im Vormerkregal",
"starttime": "2020-03-12T00:00:00+01:00"
}
]
}
HTTP/1.1 200 OK
Server: vzg-paia/2.2-RC3 (Wed Jun 01 17:38:24 CEST 2016)
Date: Mon, 20 Jun 2020 10:38:21 GMT
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-OAuth-Scopes, X-Accepted-OAuth-Scopes
Access-Control-Allow-Headers: Content-Type, Authorization
Pragma: no-cache
X-OAuth-Scopes: change_password read_items read_fees read_patron
X-Accepted-OAuth-Scopes: read_patron
Content-Type: application/json; charset=UTF-8
{
"doc": [
{
"status": 3,
"item": "DE-Zi4:barcode:03201978",
"about": "Urbanität als Habitus",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 4,
"item": "DE-Zi4:barcode:80086919",
"about": "Fernleihe mit Abholstation",
"condition": {
"http://purl.org/ontology/paia#PickupCondition": {
"option": [
{
"id": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI",
"about": "Zweigbibliothek Zittau"
},
{
"id": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwGR",
"about": "Zweigbibliothek Görlitz"
}
]
}
},
"storage": "Hochschulbibliothek Görlitz",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwGR"
},
{
"status": 0,
"item": "ILL:13940",
"about": "Aushandlungen städtischer Größe - Eckert, Anna",
"label": "Medium im Vormerkregal",
"starttime": "2020-03-12T00:00:00+01:00"
}
]
}
HTTP/1.1 200 OK
Server: vzg-paia/2.2-RC3 (Wed Jun 01 17:38:24 CEST 2016)
Date: Mon, 20 Jun 2020 10:38:21 GMT
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-OAuth-Scopes, X-Accepted-OAuth-Scopes
Access-Control-Allow-Headers: Content-Type, Authorization
Pragma: no-cache
X-OAuth-Scopes: change_password read_items read_fees read_patron
X-Accepted-OAuth-Scopes: read_patron
Content-Type: application/json; charset=UTF-8
{
"doc": [
{
"status": 4,
"item": "DE-Zi4:barcode:80086919",
"about": "Fernleihe mit Abholstation",
"condition": {
"http://purl.org/ontology/paia#PickupCondition": {
"option": [
{
"id": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwGR",
"about": "Zweigbibliothek Görlitz",
"amount": "2.50 EUR"
}
]
}
},
"storage": "Hochschulbibliothek Zittau",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI"
},
{
"status": 3,
"item": "DE-Zi4:barcode:02415857",
"about": "Die Eigenlogik der Städte",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 4,
"item": "DE-Zi4:barcode:03039724",
"about": "Stadtsoziologie",
"storage": "Hochschulbibliothek Zittau",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI"
},
{
"status": 3,
"item": "DE-Zi4:barcode:03201978",
"about": "Urbanität als Habitus",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 0,
"item": "ILL:13940",
"about": "Aushandlungen städtischer Größe - Eckert, Anna",
"label": "Medium im Vormerkregal",
"starttime": "2020-03-12T00:00:00+01:00"
}
]
}
HTTP/1.1 200 OK
Server: vzg-paia/2.2-RC3 (Wed Jun 01 17:38:24 CEST 2016)
Date: Mon, 20 Jun 2020 10:38:21 GMT
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-OAuth-Scopes, X-Accepted-OAuth-Scopes
Access-Control-Allow-Headers: Content-Type, Authorization
Pragma: no-cache
X-OAuth-Scopes: change_password read_items read_fees read_patron
X-Accepted-OAuth-Scopes: read_patron
Content-Type: application/json; charset=UTF-8
{
"doc": [
{
"status": 4,
"item": "DE-Zi4:barcode:80086919",
"about": "Fernleihe mit Abholstation",
"condition": {
"http://purl.org/ontology/paia#PickupCondition": {
"option": [
{
"id": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/unknownLocation",
"about": "Zweigbibliothek Neu aber noch nicht bekannt / konfiguriert => soll nicht angezeigt werden"
}
]
}
},
"storage": "Hochschulbibliothek Zittau",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI"
},
{
"status": 3,
"item": "DE-Zi4:barcode:02415857",
"about": "Die Eigenlogik der Städte",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 4,
"item": "DE-Zi4:barcode:03039724",
"about": "Stadtsoziologie",
"storage": "Hochschulbibliothek Zittau",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI"
},
{
"status": 3,
"item": "DE-Zi4:barcode:03201978",
"about": "Urbanität als Habitus",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 0,
"item": "ILL:13940",
"about": "Aushandlungen städtischer Größe - Eckert, Anna",
"label": "Medium im Vormerkregal",
"starttime": "2020-03-12T00:00:00+01:00"
}
]
}
HTTP/1.1 200 OK
Server: vzg-paia/2.2-RC3 (Wed Jun 01 17:38:24 CEST 2016)
Date: Mon, 20 Jun 2020 10:38:21 GMT
Cache-Control: no-cache
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: X-OAuth-Scopes, X-Accepted-OAuth-Scopes
Access-Control-Allow-Headers: Content-Type, Authorization
Pragma: no-cache
X-OAuth-Scopes: change_password read_items read_fees read_patron
X-Accepted-OAuth-Scopes: read_patron
Content-Type: application/json; charset=UTF-8
{
"doc": [
{
"status": 4,
"item": "DE-Zi4:barcode:80086919",
"about": "Fernleihe mit Abholstation",
"storage": "Hochschulbibliothek Zittau",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI"
},
{
"status": 3,
"item": "DE-Zi4:barcode:02415857",
"about": "Die Eigenlogik der Städte",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 4,
"item": "DE-Zi4:barcode:03039724",
"about": "Stadtsoziologie",
"storage": "Hochschulbibliothek Zittau",
"storageid": "http://data.ub.uni-leipzig.de/resource/DE-Zi4/department/zwZI"
},
{
"status": 3,
"item": "DE-Zi4:barcode:03201978",
"about": "Urbanität als Habitus",
"renewals": 3,
"starttime": "2020-03-13T00:00:00+01:00",
"endtime": "2020-07-10T00:00:00+02:00",
"canrenew": true
},
{
"status": 0,
"item": "ILL:13940",
"about": "Aushandlungen städtischer Größe - Eckert, Anna",
"label": "Medium im Vormerkregal",
"starttime": "2020-03-12T00:00:00+01:00"
}
]
}
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment