From 3813b483f7b35e2140912883aed999dfaee53dd2 Mon Sep 17 00:00:00 2001 From: Viola Elsenhans <elsenhans@ub.uni-leipzig.de> Date: Thu, 30 Aug 2018 14:09:49 +0200 Subject: [PATCH] refs #13723 * adds method getLocalStockSpecification() to get marc field 972$h --- .../finc/RecordDriver/SolrMarcFincTrait.php | 263 ++++++++++-------- 1 file changed, 141 insertions(+), 122 deletions(-) diff --git a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php index 996509e3276..b32373607b1 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcFincTrait.php @@ -45,6 +45,7 @@ trait SolrMarcFincTrait * Returns true if the record supports real-time AJAX status lookups. * * @return bool + * @access public */ public function supportsAjaxStatus() { @@ -52,34 +53,11 @@ trait SolrMarcFincTrait } /** - * Do we have an attached ILS connection and (finc specific) do we want ILS support - * for the records source_id and access_facet-value? - * - * @return bool - */ - /*protected function hasILS() - { - // put all ILS supported source_id in here - $ilsSourceIds = ['0']; - - // put all ILS supported access_facet values in here - $accessFacetValues = ['Local Holdings']; - - if (in_array($this->getSourceID(), $ilsSourceIds) - && in_array($this->getAccessFacet(), $accessFacetValues) - ) { - return parent::hasILS(); - } - - // ILS connection for this source_id not supported - return false; - }*/ - - /** - * Returns whether the current record is a RDA record (contains string 'rda' in - * 040$e) + * Returns whether the current record is a RDA record (contains string 'rda' + * in 040$e) * * @return bool + * @access public */ public function isRDA() { @@ -181,11 +159,9 @@ trait SolrMarcFincTrait /** * Checks if the record is an EBL record (as defined in config.ini section - * [Ebl]->product_sigel) + * [Ebl]->product_sigel). Refs #8055 #9634 * * @return bool - * @link https://intern.finc.info/issues/8055 - * @link https://intern.finc.info/issues/9634 */ private function _isEBLRecord() { @@ -218,6 +194,7 @@ trait SolrMarcFincTrait * LocalMarcFieldOfLibrary $m * * @return null|string + * @access public */ public function getLocalOrderInformation() { @@ -237,13 +214,13 @@ trait SolrMarcFincTrait } /** - * Return the local callnumber. + * Return the local callnumber. Refs #2639 * * @todo Optimization by removing of prefixed isils * * @return array Return fields. - * @deprecated (https://intern.finc.info/issues/6324) - * @link https://intern.finc.info/issues/2639 + * @access public + * @deprecated (Cmp. refs #6324) */ public function getLocalCallnumber() { @@ -271,11 +248,11 @@ trait SolrMarcFincTrait } /** - * Get local callnumbers of a special library. + * Get local callnumbers of a special library. Refs #6324 * * @return array * @access protected - * @deprecated (https://intern.finc.info/issues/6324) + * @deprecated (Cmp. refs #6324) */ protected function getLocalCallnumbersByLibrary() { @@ -315,7 +292,10 @@ trait SolrMarcFincTrait protected function getLocalGivenCallnumber() { if (null != $this->getLocalMarcFieldOfLibrary()) { - return $this->getFieldArray($this->getLocalMarcFieldOfLibrary(), ['i']); + return $this->getFieldArray( + $this->getLocalMarcFieldOfLibrary(), + ['i'] + ); } return []; } @@ -323,8 +303,9 @@ trait SolrMarcFincTrait /** * Get an array of supplements and special issue entry. * - * @link http://www.loc.gov/marc/bibliographic/bd770.html * @return array + * @access public + * @link http://www.loc.gov/marc/bibliographic/bd770.html */ public function getSupplements() { @@ -364,10 +345,10 @@ trait SolrMarcFincTrait /** * Special method to extracting the index of German prints of the marc21 - * field 024 indicator 8 subfield a + * field 024 indicator 8 subfield $a. Refs #1442 * * @return array - * @link https://intern.finc.info/fincproject/issues/1442 + * @access public */ public function getIndexOfGermanPrints() { @@ -398,6 +379,7 @@ trait SolrMarcFincTrait * of the Petrucci music library subfield 590b * * @return array + * @access public */ public function getInstrumentation() { @@ -405,11 +387,10 @@ trait SolrMarcFincTrait } /** - * Get the ISSN from a record. + * Get the ISSN from a record. Refs #969 * * @return array - * @access protected - * @link https://intern.finc.info/fincproject/issues/969 description + * @access public */ public function getISSNs() { @@ -417,10 +398,10 @@ trait SolrMarcFincTrait } /** - * Get the ISSN from a the parallel title of a record. + * Get the ISSN from a the parallel title of a record. Refs #969 * * @return array - * @link https://intern.finc.info/fincproject/issues/969 description + * @access public */ public function getISSNsParallelTitles() { @@ -494,8 +475,11 @@ trait SolrMarcFincTrait * * @return array */ - protected function getLinkedFieldArray($field, $subfields = null, $concat = true, - $separator = ' ' + protected function getLinkedFieldArray( + $field, + $subfields = null, + $concat = true, + $separator = ' ' ) { // Default to subfield a if nothing is specified. if (!is_array($subfields)) { @@ -651,6 +635,7 @@ trait SolrMarcFincTrait * subfield t and (if present) subfield r. * * @return array + * @access public */ public function getWorkPartTitleDetails() { @@ -693,6 +678,7 @@ trait SolrMarcFincTrait * from MARC field 700. * * @return array + * @access public */ public function getWorkTitleDetails() { @@ -789,19 +775,16 @@ trait SolrMarcFincTrait /** * Get an array of information about Journal holdings realised for the * special needs of University library of Chemnitz. MAB fields 720. + * Refs #328 * * @return array - * @link https://intern.finc.info/fincproject/issues/338 + * @access public */ public function getJournalHoldings() { $retval = []; $match = []; - // Get ID and connect to catalog - //$catalog = ConnectionManager::connectToCatalog(); - //$terms = $catalog->getConfig('OrderJournalTerms'); - $fields = $this->getMarcRecord()->getFields('971'); if (!$fields) { return []; @@ -809,18 +792,15 @@ trait SolrMarcFincTrait $key = 0; foreach ($fields as $field) { - /*if ($subfield = $field->getSubfield('j')) { - preg_match('/\(.*\)(.*)/', $subfield->getData(), $match); - $retval[$key]['callnumber'] = trim($match[1]); - }*/ if ($subfield = $field->getSubfield('k')) { - preg_match('/(.*)##(.*)##(.*)/', trim($subfield->getData()), $match); + preg_match( + '/(.*)##(.*)##(.*)/', + trim($subfield->getData()), + $match + ); $retval[$key]['callnumber'] = trim($match[1]); $retval[$key]['holdings'] = trim($match[2]); $retval[$key]['footnote'] = trim($match[3]); - // deprecated check if a certain wording exist - // $retval[$key]['is_holdable'] = (in_array(trim($match[3]), $terms['terms'])) ? 1 : 0; - // if subfield k exists so make journal holdable $retval[$key]['is_holdable'] = 1; if (count($this->getBarcode()) == 1) { @@ -829,14 +809,13 @@ trait SolrMarcFincTrait } else { $barcode = ''; } - // deprecated check if a certain wording exist - // $retval[$key]['link'] = (in_array(trim($match[3]), $terms['terms'])) ? '/Record/' . $this->getUniqueID() .'/HoldJournalCHE?callnumber=' . urlencode($retval[$key]['callnumber']) .'&barcode=' . $barcode : ''; - // if subfield k exists so make journal holdable - $retval[$key]['link'] = '/Record/' . $this->getUniqueID() .'/HoldJournalCHE?callnumber=' . urlencode($retval[$key]['callnumber']) .'&barcode=' . $barcode; - //var_dump($retval[$key]['is_holdable'], $terms); + $retval[$key]['link'] = + '/Record/' . $this->getUniqueID() + .'/HoldJournalCHE?callnumber=' + . urlencode($retval[$key]['callnumber']) + .'&barcode=' . $barcode; $key++; } - } return $retval; } @@ -844,16 +823,18 @@ trait SolrMarcFincTrait /** * Return a local access number for call number. * Marc field depends on library e.g. 975 for WHZ. - * Seems to be very extraordinary special case. + * Seems to be very extraordinary special case. Refs #1302 * * @return array * @access protected - * @link https://intern.finc.info/issues/1302 */ protected function getLocalAccessNumber() { if (null != $this->getLocalMarcFieldOfLibrary()) { - return $this->getFieldArray($this->getLocalMarcFieldOfLibrary(), ['o']); + return $this->getFieldArray( + $this->getLocalMarcFieldOfLibrary(), + ['o'] + ); } return []; } @@ -861,10 +842,10 @@ trait SolrMarcFincTrait /** * Return a local access number for call number. * Marc field depends on library e.g. 986 for GfzK. - * Seems to be very extraordinary special case. + * Seems to be very extraordinary special case. Refs #7924 * * @return array - * @link https://intern.finc.info/issues/7924 + * @access public */ public function getLocalSubject() { @@ -885,11 +866,10 @@ trait SolrMarcFincTrait } /** - * Get all local class subjects. First realization for HGB. + * Get all local class subjects. First realization for HGB. Refs #2626 * * @return array * @access protected - * @link https://intern.finc.info/issues/2626 */ protected function getLocalClassSubjects() { @@ -907,19 +887,6 @@ trait SolrMarcFincTrait } // end if subfield a if ($line->getSubfield('9')) { $array[$key]['data'] = $line->getSubfield('9')->getData(); - /* $tmp = $line->getSubfield('9')->getData(); - $tmpArray = array(); - $data = explode(',', $tmp); - if(is_array($data) && (count($data) > 0)) { - foreach ($data as $value) { - $tmpArray[] = $value; - } - } - if(count($tmpArray) > 0) { - $array[$key]['data'] = $tmpArray; - } else { - $array[$key]['data'] = $data; - }*/ } } // end foreach return $array; @@ -932,6 +899,7 @@ trait SolrMarcFincTrait * 972 for TUBAF * * @return array + * @access public */ public function getLocalFormat() { @@ -951,10 +919,10 @@ trait SolrMarcFincTrait /** * Returns lazily the library specific Marc field configured by CustomIndex - * settings in config.ini + * settings in config.ini. Refs 7063 * * @return mixed - * @link https://intern.finc.info/issues/7063 + * @access protected */ protected function getLocalMarcFieldOfLibrary() { @@ -985,10 +953,10 @@ trait SolrMarcFincTrait /** * Return a local notice via an consortial defined field with subfield $k. * Marc field depends on library e.g. 970 for HMT or 972 for TUBAF. + * Refs #1308 * * @return array * @access protected - * @link https://intern.finc.info/fincproject/issues/1308 */ protected function getLocalNotice() { @@ -1000,10 +968,10 @@ trait SolrMarcFincTrait /** * Return a local signature via an consortial defined field with subfield $f. - * Marc field depends on library e.g. 986 for GFZK + * Marc field depends on library e.g. 986 for GFZK. Refs #8146 * * @return array - * @link https://intern.finc.info/fincproject/issues/8146 + * @access public */ public function getLocalSignature() { @@ -1022,11 +990,29 @@ trait SolrMarcFincTrait return $retval; } + /** + * Return a stock specification via a consortial defined field of + * subfield $h. Marc field depends on library e.g. 972 for TUF. + * + * @return array + * @access protected + */ + protected function getLocalStockSpecification() + { + if (null != $this->getLocalMarcFieldOfLibrary()) { + return $this->getFieldArray( + $this->getLocalMarcFieldOfLibrary(), + ['h'] + ); + } + return []; + } + /** * Get an array of musical heading based on a swb field * at the marc field. * - * @return mixed null if there's no field or array with results + * @return mixed null if there's no field or array with results * @access public */ public function getMusicHeading() @@ -1052,7 +1038,7 @@ trait SolrMarcFincTrait } /** - * Get an array of successing titles for the record. Opposite method to + * Get an array of succeeding titles for the record. Opposite method to * getting previous title of marc field 780. * * @return array @@ -1108,13 +1094,13 @@ trait SolrMarcFincTrait } /** - * Returns the contens of MARC 787 as an array using 787$i as associative key and - * having the array value with the key 'text' containing the contents of - * 787 $a{t} and the key 'link' containing a PPN to the mentioned record in - * 787 $a{t}. + * Returns the contens of MARC 787 as an array using 787$i as associative + * key and having the array value with the key 'text' containing the + * contents of 787 $a{t} and the key 'link' containing a PPN to the + * mentioned record in 787 $a{t}. * * @return array|null - * @link https://intern.finc.info/issues/8510 + * @access public */ public function getOtherRelationshipEntry() { @@ -1204,6 +1190,7 @@ trait SolrMarcFincTrait * of the Petrucci music library subfield 590a * * @return array + * @access public */ public function getPieceStyle() { @@ -1211,14 +1198,13 @@ trait SolrMarcFincTrait } /** - * Get specific marc information about parallel editions. Unflexible solution - * for HMT only implemented. + * Get specific marc information about parallel editions. Unflexible + * solution for HMT only implemented. * * @todo More flexible implementation * * @return array * @access protected - * @link https://intern.finc.info/issues/4327 */ protected function getParallelEditions() { @@ -1310,6 +1296,7 @@ trait SolrMarcFincTrait * @todo pass prices by euro currency * * @return string + * @access public */ public function getPrice() { @@ -1338,6 +1325,7 @@ trait SolrMarcFincTrait * Get the provenience of a title. * * @return array + * @access public */ public function getProvenience() { @@ -1368,7 +1356,6 @@ trait SolrMarcFincTrait * @return array * @access protected * @link http://www.loc.gov/marc/bibliographic/bd830.html - * @link https://intern.finc.info/fincproject/issues/457 */ protected function getSeriesWithVolume() { @@ -1395,18 +1382,18 @@ trait SolrMarcFincTrait /** * Get local classification of UDK. * - * @todo Check if method is used by other institution than HTWK. - * * @return array * @access protected - * @link https://intern.finc.info/fincproject/issues/1135 + * @deprecated Seems to be only for HTWK in use formerly? */ protected function getUDKs() { $array = []; if (null != $this->getLocalMarcFieldOfLibrary()) { - $udk = $this->getMarcRecord()->getFields($this->getLocalMarcFieldOfLibrary()); + $udk = $this->getMarcRecord()->getFields( + $this->getLocalMarcFieldOfLibrary() + ); // if not return void value if (!$udk) { return $array; @@ -1476,10 +1463,10 @@ trait SolrMarcFincTrait /** * Get specific marc information about additional items. Unflexible solution - * for UBL only implemented. + * for UBL only implemented. Refs. #1315 * * @return array - * @link https://intern.finc.info/fincproject/issues/1315 + * @access public */ public function getAdditionals() { @@ -1544,10 +1531,11 @@ trait SolrMarcFincTrait } /** - * Returns notes and additional information stored in Marc 546a + * Returns notes and additional information stored in Marc 546$a. + * Refs. #8509 * * @return array|null - * @link https://intern.finc.info/issues/8509 + * @access public */ public function getAdditionalNotes() { @@ -1568,9 +1556,10 @@ trait SolrMarcFincTrait /** * Marc specific implementation for retrieving hierarchy parent id(s). + * Refs #8369 * * @return array - * @link https://intern.finc.info/issues/8369 + * @access public */ public function getHierarchyParentID() { @@ -1636,9 +1625,10 @@ trait SolrMarcFincTrait /** * Marc specific implementation for compiling hierarchy parent titles. + * Refs #8369 * * @return array - * @link https://intern.finc.info/issues/8369 + * @access public */ public function getHierarchyParentTitle() { @@ -1721,6 +1711,7 @@ trait SolrMarcFincTrait * the bsz heading subjects chains. * * @return array + * @access public */ public function getAllSubjectHeadingsExtended() { @@ -1760,6 +1751,7 @@ trait SolrMarcFincTrait * @param boolean $extended If dynamic index extension activated * * @return array + * @access public */ public function getAllSubjectHeadings($extended = false) { @@ -1834,11 +1826,13 @@ trait SolrMarcFincTrait * Check if Topics exists. Realized for instance of UBL only. * * @return boolean True if topics exist. + * @access public */ public function hasTopics() { $rvk = $this->getRvkWithMetadata(); - return (parent::hasTopics() + return ( + parent::hasTopics() || (is_array($rvk) && count($rvk) > 0) ); } @@ -1848,10 +1842,14 @@ trait SolrMarcFincTrait * for UBL only implemented. * * @return array + * @access public */ public function getTopics() { - return array_merge($this->getAllSubjectHeadings(), $this->getAllSubjectHeadingsExtended()); + return array_merge( + $this->getAllSubjectHeadings(), + $this->getAllSubjectHeadingsExtended() + ); } /** @@ -1932,6 +1930,7 @@ trait SolrMarcFincTrait * Get dissertation notes for the record. * * @return array $retVal + * @access public */ public function getDissertationNote() { @@ -1953,10 +1952,12 @@ trait SolrMarcFincTrait /** * Get id of related items * + * @params boolean $allow_multiple_results + * * @return string|array * @access protected */ - protected function getRelatedItems($allow_multiple_results=FALSE) + protected function getRelatedItems($allow_multiple_results = false) { if ($allow_multiple_results) { return $this->getFieldArray('776', ['z']); @@ -1965,16 +1966,28 @@ trait SolrMarcFincTrait } } - protected function getRelatedRecords($limit,$backend_id='Solr') + /** + * Get related records via search index + * + * @params int $limit + * @params string $backend_id Search engine + * + * @return array + * @access protected + */ + protected function getRelatedRecords($limit, $backend_id = 'Solr') { - $related = $this->getRelatedItems(TRUE); + $related = $this->getRelatedItems(true); if (empty($related)) return []; - $query = new Query('isbn' . ':' . implode(' OR ',$related) . ' AND NOT id:' . $this->getUniqueID()); + $query = new Query( + 'isbn' . ':' . implode(' OR ',$related) + . ' AND NOT id:' . $this->getUniqueID() + ); - $result = $this->searchService->search($backend_id, $query,0,$limit); + $result = $this->searchService->search($backend_id, $query, 0, $limit); $return['first_results'] = $result->getRecords(); if ($result->getTotal() > $limit) { $return['more_query'] = $query->getString(); @@ -1982,11 +1995,11 @@ trait SolrMarcFincTrait return $return; } - /** - * Get RVK classification number with metadata from Marc records. + /** + * Get RVK classification number with metadata from Marc records. Refs #599 * * @return array - * @link https://intern.finc.info/fincproject/issues/599 + * @access public */ public function getRvkWithMetadata() { @@ -2021,6 +2034,7 @@ trait SolrMarcFincTrait * Get an array of citations and references notes. * * @return array + * @access public */ public function getReferenceNotes() { @@ -2031,6 +2045,7 @@ trait SolrMarcFincTrait * Get the publishers number and source of the record. * * @return array + * @access public */ public function getPublisherNumber() { @@ -2041,6 +2056,7 @@ trait SolrMarcFincTrait * Get the musical key of a piece (Marc 384). * * @return array + * @access public */ public function getMusicalKey() { @@ -2048,8 +2064,11 @@ trait SolrMarcFincTrait } /** - * @deprecated Remove when Bibliotheca support ends + * Get Mediennummer (media number) identifier for Bibliotheca ILS + * * @returns items internal Bibliotheca-ID called "Mediennummer" + * @deprecated Remove when Bibliotheca support ends + * @access public */ public function getMediennummer() { // loop through all existing LocalMarcFieldOfLibrary @@ -2061,7 +2080,7 @@ trait SolrMarcFincTrait $field = $field->getSubfield('a'); if ($field) { $matches = []; - if (preg_match('/\w+$/',$field->getData(),$matches)) { + if (preg_match('/\w+$/', $field->getData(), $matches)) { return $matches[0]; } } -- GitLab