diff --git a/module/finc/config/module.config.php b/module/finc/config/module.config.php index 2d330d37d220f51eac8c7ce8e8b792832c1b5cd7..b6b91aa270efe1751ecf53d1ee5e32e16feab156 100644 --- a/module/finc/config/module.config.php +++ b/module/finc/config/module.config.php @@ -36,6 +36,8 @@ $config = [ 'factories' => [ 'fincils' => 'finc\ILS\Driver\Factory::getFincILS', 'paia' => 'finc\ILS\Driver\Factory::getPAIA', + //finctheca is deprecated: Remove when Bibliotheca support ends + 'finctheca' => 'finc\ILS\Driver\Factory::GetFincTheca' ], ], 'recommend' => [ diff --git a/module/finc/src/finc/ILS/Driver/Factory.php b/module/finc/src/finc/ILS/Driver/Factory.php index da1a515eddef8c683a3aa5915f00a36fc6b68c1c..5d05e83ef7d92e3788e1f3c241a21259dd998972 100644 --- a/module/finc/src/finc/ILS/Driver/Factory.php +++ b/module/finc/src/finc/ILS/Driver/Factory.php @@ -95,4 +95,34 @@ class Factory return $paia; } + /** + * @deprecated Remove when Bibliotheca support ends + * @param ServiceManager $sm + * @return FincTheca + */ + public static function getFincTheca(ServiceManager $sm) + { + $factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($sm->getServiceLocator()->get('VuFind\ProxyConfig')); + + $callback = function (& $wrapped, $proxy) use ($sm) { + $wrapped = $sm->getServiceLocator()->get('ZfcRbac\Service\AuthorizationService'); + + $proxy->setProxyInitializer(null); + }; + + $fl = new FincTheca( + $sm->getServiceLocator()->get('VuFind\DateConverter'), + $sm->getServiceLocator()->get('VuFind\SessionManager'), + $sm->getServiceLocator()->get('VuFind\RecordLoader'), + $sm->getServiceLocator()->get('VuFind\Search'), + $sm->getServiceLocator()->get('VuFind\Config')->get('config'), + $factory->createProxy('ZfcRbac\Service\AuthorizationService', $callback) + ); + + $fl->setCacheStorage( + $sm->getServiceLocator()->get('VuFind\CacheManager')->getCache('object') + ); + + return $fl; + } } \ No newline at end of file diff --git a/module/finc/src/finc/ILS/Driver/FincILS.php b/module/finc/src/finc/ILS/Driver/FincILS.php index 3095a85dfe66372639fb36e7e9a2aba7762d9da7..8b3102edb3502d0e41c2d883d496675473a6f6a4 100644 --- a/module/finc/src/finc/ILS/Driver/FincILS.php +++ b/module/finc/src/finc/ILS/Driver/FincILS.php @@ -405,6 +405,10 @@ class FincILS extends PAIA implements LoggerAwareInterface } } + protected function doGetStatus($id) { + return parent::getStatus($id); + } + /** * Get Statuses * @@ -1344,7 +1348,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return \VuFind\RecordDriver\AbstractBase */ - private function _getRecord($id) + protected function _getRecord($id) { return $this->recordLoader->load($id); } @@ -1435,7 +1439,7 @@ class FincILS extends PAIA implements LoggerAwareInterface * * @return string $ilsRecordId */ - private function _getILSRecordId($id, $ilsIdentifier = null) + protected function _getILSRecordId($id, $ilsIdentifier = null) { // override ilsIdentifier with the ilsIdentifier set in ILS driver config if ($ilsIdentifier == null) { diff --git a/module/finc/src/finc/ILS/Driver/FincTheca.php b/module/finc/src/finc/ILS/Driver/FincTheca.php new file mode 100644 index 0000000000000000000000000000000000000000..9ffc16537cfa25f22d6e0d45ae74c279d33b5ccf --- /dev/null +++ b/module/finc/src/finc/ILS/Driver/FincTheca.php @@ -0,0 +1,91 @@ +<?php + +namespace finc\ILS\Driver; + +/** + * Class FincTheca + * @deprecated Remove when Bibliotheca support ends + * @package finc\ILS\Driver + */ +class FincTheca extends FincILS { + + private $identifier_type = 'ppn'; + private $daiaIdPrefixBase; + + public function init() + { + parent::init(); + if (isset($this->config['DAIA']['daiaIdPrefixBase'])) { + $this->daiaIdPrefixBase = $this->config['DAIA']['daiaIdPrefixBase']; + } + } + + public function getStatus($id) + { + $result = []; + try { + $result = parent::getStatus($id); + } catch (\Exception $e) { + + } + if (empty($result)) { + $result = $this->getStatusViaMediennummer($id); + } + return $result; + } + + /** + * @param $record_id String Finc-ID of record, used to retrieve Mediennummer + * @return array|mixed + */ + protected function getStatusViaMediennummer($record_id) { + $result = []; + if ($ilsRecordId = $this->_getRecord($record_id)->tryMethod('getMediennummer')) { + $this->identifier_type = 'mediennr'; + $result = parent::doGetStatus($ilsRecordId); + foreach($result as &$item) { + //fix-up IDs + $item['id'] = $record_id; + } + } + return $result; + } + + public function getStatuses($ids) + { + $results = parent::getStatuses($ids); + if (count($results) < count($ids)) { + //some records had no availability info + $missing = array_flip($ids); + foreach ($results as $items) { + $item = current($items); + if (isset($missing[$item['id']])) unset($missing[$item['id']]); + } + foreach (array_keys($missing) as $missing_id) { + $results[] = $this->getStatusViaMediennummer($missing_id); + } + } + return $results; + } + + protected function generateURI($id) + { + if (isset($this->daiaIdPrefixBase)) { + return + $this->daiaIdPrefixBase + .':'.$this->identifier_type + .':'.$id; + } + return parent::generateMultiURIs($id); + } + + protected function getItemBarcode($item) + { + $matches = []; + if (preg_match('/^'.$this->daiaIdPrefixBase.':'.$this->identifier_type.':\w+:(\w+)$/',$item['id'],$matches)) { + return $matches[1]; + } + return null; + } + +} \ No newline at end of file diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php index a9cd5074ba238d2304bdb867b02d769c6dd5cfb8..2fe54de4004d9c49776a05cc7746d5271197a544 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php @@ -2073,4 +2073,26 @@ trait SolrMarcFincTrait { return $this->getFieldArray('384'); } + + /** + * @deprecated Remove when Bibliotheca support ends + * @returns items internal Bibliotheca-ID called "Mediennummer" + */ + public function getMediennummer() { + // loop through all existing LocalMarcFieldOfLibrary + if ($fields = $this->getMarcRecord()->getFields( + $this->getLocalMarcFieldOfLibrary()) + ) { + foreach($fields as $field) { + // return the first occurance of $m + $field = $field->getSubfield('a'); + if ($field) { + $matches = []; + if (preg_match('/\w+$/',$field->getData(),$matches)) { + return $matches[0]; + } + } + } + } + } }