diff --git a/module/finc/src/finc/RecordDriver/SolrMarc.php b/module/finc/src/finc/RecordDriver/SolrMarc.php index ae935ed0dda425274e5ad8d1fea6382b820bf498..922fa599b29326125f5c357d460e614ca1e93ece 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarc.php +++ b/module/finc/src/finc/RecordDriver/SolrMarc.php @@ -5,6 +5,7 @@ * PHP version 5 * * Copyright (C) Villanova University 2010. + * Copyright (C) The National Library of Finland 2015. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, @@ -22,6 +23,7 @@ * @category VuFind2 * @package RecordDrivers * @author Demian Katz <demian.katz@villanova.edu> + * @author Ere Maijala <ere.maijala@helsinki.fi> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/vufind2:record_drivers Wiki */ @@ -36,17 +38,18 @@ use VuFind\Exception\ILS as ILSException, * @category VuFind2 * @package RecordDrivers * @author Demian Katz <demian.katz@villanova.edu> + * @author Ere Maijala <ere.maijala@helsinki.fi> * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @link http://vufind.org/wiki/vufind2:record_drivers Wiki */ class SolrMarc extends SolrDefault { /** - * MARC record + * MARC record. Access only via getMarcRecord() as this is initialized lazily. * * @var \File_MARC_Record */ - protected $marcRecord; + protected $lazyMarcRecord = null; /** * ILS connection @@ -69,43 +72,6 @@ class SolrMarc extends SolrDefault */ protected $titleHoldLogic; - /** - * Set raw data to initialize the object. - * - * @param mixed $data Raw data representing the record; Record Model - * objects are normally constructed by Record Driver objects using data - * passed in from a Search Results object. In this case, $data is a Solr record - * array containing MARC data in the 'fullrecord' field. - * - * @return void - */ - public function setRawData($data) - { - // Call the parent's set method... - parent::setRawData($data); - - // Also process the MARC record: - $marc = trim($data['fullrecord']); - - // check if we are dealing with MARCXML - $xmlHead = '<?xml version'; - if (substr($marc, 0, 1) == '<') { - $marc = new \File_MARCXML($marc, \File_MARCXML::SOURCE_STRING); - } else { - // When indexing over HTTP, SolrMarc may use entities instead of certain - // control characters; we should normalize these: - $marc = str_replace( - ['#29;', '#30;', '#31;'], ["\x1D", "\x1E", "\x1F"], $marc - ); - $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); - } - - $this->marcRecord = $marc->next(); - if (!$this->marcRecord) { - throw new \File_MARC_Exception('Cannot Process MARC Record'); - } - } - /** * Get access restriction notes for the record. * @@ -136,7 +102,7 @@ class SolrMarc extends SolrDefault // Try each MARC field one at a time: foreach ($fields as $field) { // Do we have any results for the current field? If not, try the next. - $results = $this->marcRecord->getFields($field); + $results = $this->getMarcRecord()->getFields($field); if (!$results) { continue; } @@ -185,24 +151,24 @@ class SolrMarc extends SolrDefault */ public function getBibliographicLevel() { - $leader = $this->marcRecord->getLeader(); + $leader = $this->getMarcRecord()->getLeader(); $biblioLevel = strtoupper($leader[7]); switch ($biblioLevel) { - case 'M': // Monograph - return "Monograph"; - case 'S': // Serial - return "Serial"; - case 'A': // Monograph Part - return "MonographPart"; - case 'B': // Serial Part - return "SerialPart"; - case 'C': // Collection - return "Collection"; - case 'D': // Collection Part - return "CollectionPart"; - default: - return "Unknown"; + case 'M': // Monograph + return "Monograph"; + case 'S': // Serial + return "Serial"; + case 'A': // Monograph Part + return "MonographPart"; + case 'B': // Serial Part + return "SerialPart"; + case 'C': // Collection + return "Collection"; + case 'D': // Collection Part + return "CollectionPart"; + default: + return "Unknown"; } } @@ -256,7 +222,7 @@ class SolrMarc extends SolrDefault // Try to look up the specified field, return empty array if it doesn't // exist. - $fields = $this->marcRecord->getFields($field); + $fields = $this->getMarcRecord()->getFields($field); if (!is_array($fields)) { return $matches; } @@ -349,7 +315,7 @@ class SolrMarc extends SolrDefault // consistent with default SolrMarc handling of names/dates. $pubResults = $copyResults = []; - $fields = $this->marcRecord->getFields('264'); + $fields = $this->getMarcRecord()->getFields('264'); if (is_array($fields)) { foreach ($fields as $currentField) { $currentVal = $currentField->getSubfield($subfield); @@ -357,12 +323,12 @@ class SolrMarc extends SolrDefault ? $currentVal->getData() : null; if (!empty($currentVal)) { switch ($currentField->getIndicator('2')) { - case '1': - $pubResults[] = $currentVal; - break; - case '4': - $copyResults[] = $currentVal; - break; + case '1': + $pubResults[] = $currentVal; + break; + case '4': + $copyResults[] = $currentVal; + break; } } } @@ -497,7 +463,7 @@ class SolrMarc extends SolrDefault // Loop through the field specification.... foreach ($fieldInfo as $field => $subfields) { // Did we find any matching fields? - $series = $this->marcRecord->getFields($field); + $series = $this->getMarcRecord()->getFields($field); if (is_array($series)) { foreach ($series as $currentField) { // Can we find a name using the specified subfield list? @@ -635,7 +601,7 @@ class SolrMarc extends SolrDefault public function getTOC() { // Return empty array if we have no table of contents: - $fields = $this->marcRecord->getFields('505'); + $fields = $this->getMarcRecord()->getFields('505'); if (!$fields) { return []; } @@ -664,7 +630,7 @@ class SolrMarc extends SolrDefault public function getHierarchicalPlaceNames() { $placeNames = []; - if ($fields = $this->marcRecord->getFields('752')) { + if ($fields = $this->getMarcRecord()->getFields('752')) { foreach ($fields as $field) { $subfields = $field->getSubfields(); $current = []; @@ -699,12 +665,12 @@ class SolrMarc extends SolrDefault // Which fields/subfields should we check for URLs? $fieldsToCheck = [ - '856' => ['y', 'z'], // Standard URL + '856' => ['y', 'z', '3'], // Standard URL '555' => ['a'] // Cumulative index/finding aids ]; foreach ($fieldsToCheck as $field => $subfields) { - $urls = $this->marcRecord->getFields($field); + $urls = $this->getMarcRecord()->getFields($field); if ($urls) { foreach ($urls as $url) { // Is there an address in the current field? @@ -761,7 +727,7 @@ class SolrMarc extends SolrDefault $retVal = []; foreach ($fieldsNames as $value) { $value = trim($value); - $fields = $this->marcRecord->getFields($value); + $fields = $this->getMarcRecord()->getFields($value); if (!empty($fields)) { foreach ($fields as $field) { // Check to see if we should display at all @@ -803,16 +769,16 @@ class SolrMarc extends SolrDefault // Assign notes based on the relationship type $value = $field->getTag(); switch ($value) { - case '780': - if (in_array($relationshipIndicator, range('0', '7'))) { - $value .= '_' . $relationshipIndicator; - } - break; - case '785': - if (in_array($relationshipIndicator, range('0', '8'))) { - $value .= '_' . $relationshipIndicator; - } - break; + case '780': + if (in_array($relationshipIndicator, range('0', '7'))) { + $value .= '_' . $relationshipIndicator; + } + break; + case '785': + if (in_array($relationshipIndicator, range('0', '8'))) { + $value .= '_' . $relationshipIndicator; + } + break; } return 'note_' . $value; @@ -847,46 +813,46 @@ class SolrMarc extends SolrDefault // If no reference found, check the next link type instead foreach ($linkTypes as $linkType) { switch (trim($linkType)){ - case 'oclc': - foreach ($linkFields as $current) { - if ($oclc = $this->getIdFromLinkingField($current, 'OCoLC')) { - $link = ['type' => 'oclc', 'value' => $oclc]; + case 'oclc': + foreach ($linkFields as $current) { + if ($oclc = $this->getIdFromLinkingField($current, 'OCoLC')) { + $link = ['type' => 'oclc', 'value' => $oclc]; + } } - } - break; - case 'dlc': - foreach ($linkFields as $current) { - if ($dlc = $this->getIdFromLinkingField($current, 'DLC', true)) { - $link = ['type' => 'dlc', 'value' => $dlc]; + break; + case 'dlc': + foreach ($linkFields as $current) { + if ($dlc = $this->getIdFromLinkingField($current, 'DLC', true)) { + $link = ['type' => 'dlc', 'value' => $dlc]; + } } - } - break; - case 'id': - foreach ($linkFields as $current) { - if ($bibLink = $this->getIdFromLinkingField($current)) { - $link = ['type' => 'bib', 'value' => $bibLink]; + break; + case 'id': + foreach ($linkFields as $current) { + if ($bibLink = $this->getIdFromLinkingField($current)) { + $link = ['type' => 'bib', 'value' => $bibLink]; + } } - } - break; - case 'isbn': - if ($isbn = $field->getSubfield('z')) { - $link = [ - 'type' => 'isn', 'value' => trim($isbn->getData()), - 'exclude' => $this->getUniqueId() - ]; - } - break; - case 'issn': - if ($issn = $field->getSubfield('x')) { - $link = [ - 'type' => 'isn', 'value' => trim($issn->getData()), - 'exclude' => $this->getUniqueId() - ]; - } - break; - case 'title': - $link = ['type' => 'title', 'value' => $title]; - break; + break; + case 'isbn': + if ($isbn = $field->getSubfield('z')) { + $link = [ + 'type' => 'isn', 'value' => trim($isbn->getData()), + 'exclude' => $this->getUniqueId() + ]; + } + break; + case 'issn': + if ($issn = $field->getSubfield('x')) { + $link = [ + 'type' => 'isn', 'value' => trim($issn->getData()), + 'exclude' => $this->getUniqueId() + ]; + } + break; + case 'title': + $link = ['type' => 'title', 'value' => $title]; + break; } // Exit loop if we have a link if (isset($link)) { @@ -945,7 +911,7 @@ class SolrMarc extends SolrDefault // Try to look up the specified field, return empty array if it doesn't // exist. - $fields = $this->marcRecord->getFields($field); + $fields = $this->getMarcRecord()->getFields($field); if (!is_array($fields)) { return $matches; } @@ -1000,7 +966,7 @@ class SolrMarc extends SolrDefault { // Special case for MARC: if ($format == 'marc21') { - $xml = $this->marcRecord->toXML(); + $xml = $this->getMarcRecord()->toXML(); $xml = str_replace( [chr(27), chr(28), chr(29), chr(30), chr(31)], ' ', $xml ); @@ -1035,8 +1001,8 @@ class SolrMarc extends SolrDefault * @return void */ public function attachILS(\VuFind\ILS\Connection $ils, - \VuFind\ILS\Logic\Holds $holdLogic, - \VuFind\ILS\Logic\TitleHolds $titleHoldLogic + \VuFind\ILS\Logic\Holds $holdLogic, + \VuFind\ILS\Logic\TitleHolds $titleHoldLogic ) { $this->ils = $ils; $this->holdLogic = $holdLogic; @@ -1117,11 +1083,32 @@ class SolrMarc extends SolrDefault /** * Get access to the raw File_MARC object. * - * @return File_MARCBASE + * @return \File_MARCBASE */ public function getMarcRecord() { - return $this->marcRecord; + if (null === $this->lazyMarcRecord) { + $marc = trim($this->fields['fullrecord']); + + // check if we are dealing with MARCXML + if (substr($marc, 0, 1) == '<') { + $marc = new \File_MARCXML($marc, \File_MARCXML::SOURCE_STRING); + } else { + // When indexing over HTTP, SolrMarc may use entities instead of + // certain control characters; we should normalize these: + $marc = str_replace( + ['#29;', '#30;', '#31;'], ["\x1D", "\x1E", "\x1F"], $marc + ); + $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); + } + + $this->lazyMarcRecord = $marc->next(); + if (!$this->lazyMarcRecord) { + throw new \File_MARC_Exception('Cannot Process MARC Record'); + } + } + + return $this->lazyMarcRecord; } /** @@ -1132,7 +1119,7 @@ class SolrMarc extends SolrDefault public function getRDFXML() { return XSLTProcessor::process( - 'record-rdf-mods.xsl', trim($this->marcRecord->toXML()) + 'record-rdf-mods.xsl', trim($this->getMarcRecord()->toXML()) ); } @@ -1145,4 +1132,24 @@ class SolrMarc extends SolrDefault { return $this->getFieldArray('035', 'a', true); } + + /** + * Magic method for legacy compatibility with marcRecord property. + * + * @param string $key Key to access. + * + * @return mixed + */ + public function __get($key) + { + if ($key === 'marcRecord') { + // property deprecated as of release 2.5. + trigger_error( + 'marcRecord property is deprecated; use getMarcRecord()', + E_USER_DEPRECATED + ); + return $this->getMarcRecord(); + } + return null; + } } diff --git a/module/finc/src/finc/RecordDriver/SolrMarcRemote.php b/module/finc/src/finc/RecordDriver/SolrMarcRemote.php index fce2858ef88d61314799c20e058d285a10fccbd5..86a2ef213646aefebcb79573174750e7da68ef66 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcRemote.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcRemote.php @@ -51,11 +51,11 @@ class SolrMarcRemote extends SolrMarc implements use \VuFind\Log\LoggerAwareTrait; /** - * MARC record + * MARC record. Access only via getMarcRecord() as this is initialized lazily. * * @var \File_MARC_Record */ - protected $marcRecord; + protected $lazyMarcRecord = null; /** * holds the URI-Pattern of the service that returns the marc binary blob by id @@ -86,6 +86,8 @@ class SolrMarcRemote extends SolrMarc implements * @param \Zend\Config\Config $recordConfig Record-specific configuration file * (omit to use $mainConfig as $recordConfig) * @param \Zend\Config\Config $searchSettings Search-specific configuration file + * + * @throws \Exception */ public function __construct($mainConfig = null, $recordConfig = null, $searchSettings = null @@ -108,33 +110,77 @@ class SolrMarcRemote extends SolrMarc implements } /** - * Set raw data to initialize the object. - * - * @param mixed $data Raw data representing the record; Record Model - * objects are normally constructed by Record Driver objects using data - * passed in from a Search Results object. In this case, $data is a Solr record - * array containing MARC data in the 'fullrecord' field. + * Get access to the raw File_MARC object. * + * @return \File_MARCBASE * @throws \Exception * @throws \File_MARC_Exception - * @return void */ - public function setRawData($data) + public function getMarcRecord() { - // Don't call the parent's set method as this would require the fullrecord in the Solr-Data - // Instead perform basic assignment of data to fields - $this->fields = $data; + if (null === $this->lazyMarcRecord) { + // handle availability of fullrecord + if (isset($this->fields['fullrecord'])) { + // standard Vufind2-behaviour + + // also process the MARC record: + $marc = trim($this->fields['fullrecord']); + + } else { + // fallback: retrieve fullrecord from external source + + if (! isset($this->fields['id'])) { + throw new \Exception( + 'No unique id given for fullrecord retrieval' + ); + } + + $marc = $this->getRemoteFullrecord($this->fields['id']); + + } + + if (isset($marc)) { + // continue with standard Vufind2-behaviour if marcrecord is present + + // check if we are dealing with MARCXML + if (substr($marc, 0, 1) == '<') { + $marc = new \File_MARCXML($marc, \File_MARCXML::SOURCE_STRING); + } else { + // When indexing over HTTP, SolrMarc may use entities instead of + // certain control characters; we should normalize these: + $marc = str_replace( + ['#29;', '#30;', '#31;'], ["\x1D", "\x1E", "\x1F"], $marc + ); + $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); + } + + $this->lazyMarcRecord = $marc->next(); + if (!$this->lazyMarcRecord) { + throw new \File_MARC_Exception('Cannot Process MARC Record'); + } + + } else { + // no marcrecord was found + + throw new \Exception( + 'no Marc was found neither on the marc server ' . + 'nor in the solr-record for id ' . $this->fields['id'] + ); + } + } + + return $this->lazyMarcRecord; } /** * Retrieves the full Marcrecord from a remote service defined by uriPattern * - * @params String $id - this record's unique identifier - * @throws \Exception + * @param String $id - this record's unique identifier * - * @return marc binary blob + * @return bool|string + * @throws \Exception */ - private function retrieveFullrecord($id) + protected function getRemoteFullrecord($id) { if (empty($id)) { @@ -150,7 +196,7 @@ class SolrMarcRemote extends SolrMarc implements try { $response = $this->httpService->get($url); } catch (\Exception $e) { - throw new Exception($e->getMessage()); + throw new \Exception($e->getMessage()); } if (!$response->isSuccess()) { @@ -164,299 +210,4 @@ class SolrMarcRemote extends SolrMarc implements return $response->getBody(); } - - /** - * Load data from remote server - * - * @throws \Exception - * @throws \File_MARC_Exception - */ - protected function getRemoteData() { - - // handle availability of fullrecord - if (isset($this->fields['fullrecord'])) { - // standard Vufind2-behaviour - - // also process the MARC record: - $marc = trim($this->fields['fullrecord']); - - } else { - // fallback: retrieve fullrecord from external source - - if (! isset($this->fields['id'])) { - throw new \File_MARC_Exception('No unique id given for fullrecord retrieval'); - } - - $marc = $this->retrieveFullrecord($this->fields['id']); - - } - - if (isset($marc)) { - // continue with standard Vufind2-behaviour if marcrecord is present - - // check if we are dealing with MARCXML - $xmlHead = '<?xml version'; - if (strcasecmp(substr($marc, 0, strlen($xmlHead)), $xmlHead) === 0) { - $marc = new \File_MARCXML($marc, \File_MARCXML::SOURCE_STRING); - } else { - // When indexing over HTTP, SolrMarc may use entities instead of certain - // control characters; we should normalize these: - $marc = str_replace( - ['#29;', '#30;', '#31;'], ["\x1D", "\x1E", "\x1F"], $marc - ); - $marc = new \File_MARC($marc, \File_MARC::SOURCE_STRING); - } - - $this->marcRecord = $marc->next(); - if (!$this->marcRecord) { - throw new \File_MARC_Exception('Cannot Process MARC Record'); - } - } else { - // no marcrecord was found - - throw new \Exception('no Marc was found neither on the marc server nor in the solr-record for id ' . $this->fields['id']); - } - } - - /** - * Get the field-value identified by $string - * - * @param String field-name - * - * @return String - */ - public function getILSIdentifier($string) - { - return (isset($this->fields[$string]) ? $this->fields[$string] : ''); - } - - /** - * Return an array of associative URL arrays with one or more of the following - * keys: - * - * <li> - * <ul>desc: URL description text to display (optional)</ul> - * <ul>url: fully-formed URL (required if 'route' is absent)</ul> - * <ul>route: VuFind route to build URL with (required if 'url' is absent)</ul> - * <ul>routeParams: Parameters for route (optional)</ul> - * <ul>queryString: Query params to append after building route (optional)</ul> - * </li> - * - * @return array - */ - public function getURLs() - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getURLs(); - } - - /** - * Get all subject headings associated with this record. Each heading is - * returned as an array of chunks, increasing from least specific to most - * specific. - * - * @return array - */ - public function getAllSubjectHeadings() - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getAllSubjectHeadings(); - } - - /** - * Get the bibliographic level of the current record. - * - * @return string - */ - public function getBibliographicLevel() - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getBibliographicLevel(); - } - - /** - * Return an array of all values extracted from the specified field/subfield - * combination. If multiple subfields are specified and $concat is true, they - * will be concatenated together in the order listed -- each entry in the array - * will correspond with a single MARC field. If $concat is false, the return - * array will contain separate entries for separate subfields. - * - * @param string $field The MARC field number to read - * @param array $subfields The MARC subfield codes to read - * @param bool $concat Should we concatenate subfields? - * - * @return array - */ - protected function getFieldArray($field, $subfields = null, $concat = true) - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getFieldArray($field, $subfields, $concat); - } - - /** - * Get the item's publication information - * - * @param string $subfield The subfield to retrieve ('a' = location, 'c' = date) - * - * @return array - */ - protected function getPublicationInfo($subfield = 'a') - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getPublicationInfo($subfield); - } - - /** - * Support method for getSeries() -- given a field specification, look for - * series information in the MARC record. - * - * @param array $fieldInfo Associative array of field => subfield information - * (used to find series name) - * - * @return array - */ - protected function getSeriesFromMARC($fieldInfo) - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getSeriesFromMARC($fieldInfo); - } - - /** - * Get an array of lines from the table of contents. - * - * @return array - */ - public function getTOC() - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getTOC(); - } - - /** - * Get hierarchical place names (MARC field 752) - * - * returns an array of formatted hierarchical place names, consisting of all - * alpha-subfields, concatenated for display - * - * @return array - */ - public function getHierarchicalPlaceNames() - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getHierarchicalPlaceNames(); - } - - /** - * Get all record links related to the current record. Each link is returned as - * array. - * Format: - * array( - * array( - * 'title' => label_for_title - * 'value' => link_name - * 'link' => link_URI - * ), - * ... - * ) - * - * @return null|array - */ - public function getAllRecordLinks() - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getAllRecordLinks(); - } - - /** - * Get Status/Holdings Information from the internally stored MARC Record - * (support method used by the NoILS driver). - * - * @param array $field The MARC Field to retrieve - * @param array $data A keyed array of data to retrieve from subfields - * - * @return array - */ - public function getFormattedMarcDetails($field, $data) - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getFormattedMarcDetails($field, $data); - } - - /** - * Return an XML representation of the record using the specified format. - * Return false if the format is unsupported. - * - * @param string $format Name of format to use (corresponds with OAI-PMH - * metadataPrefix parameter). - * @param string $baseUrl Base URL of host containing VuFind (optional; - * may be used to inject record URLs into XML when appropriate). - * @param RecordLink $recordLink Record link helper (optional; may be used to - * inject record URLs into XML when appropriate). - * - * @return mixed XML, or false if format unsupported. - */ - public function getXML($format, $baseUrl = null, $recordLink = null) - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getXML($format, $baseUrl, $recordLink); - } - - /** - * Get access to the raw File_MARC object. - * - * @return File_MARCBASE - */ - public function getMarcRecord() - { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - - return parent::getMarcRecord(); - } } diff --git a/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php b/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php index 3e4cbd5aabe3abc3e5f2ea3fb594a0f8e95bb4ef..ae17961f3e72db445ce6813827b96c45b4181555 100644 --- a/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php +++ b/module/finc/src/finc/RecordDriver/SolrMarcRemoteFinc.php @@ -130,11 +130,6 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ public function getURLs() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - $retVal = []; // Which fields/subfields should we check for URLs? @@ -144,7 +139,7 @@ class SolrMarcRemoteFinc extends SolrMarcRemote ]; foreach ($fieldsToCheck as $field => $subfields) { - $urls = $this->marcRecord->getFields($field); + $urls = $this->getMarcRecord()->getFields($field); if ($urls) { foreach ($urls as $url) { @@ -297,14 +292,9 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getSupplements() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - //return $this->_getFieldArray('770', array('i','t')); // has been originally 'd','h','n','x' but only 'i' and 't' for ubl requested; $array = []; - $supplement = $this->marcRecord->getFields('770'); + $supplement = $this->getMarcRecord()->getFields('770'); // if not return void value if (!$supplement) { return $array; @@ -333,6 +323,18 @@ class SolrMarcRemoteFinc extends SolrMarcRemote return $this->addFincIDToRecord($array); } + /** + * Get the field-value identified by $string + * + * @param String field-name + * + * @return String + */ + public function getILSIdentifier($string) + { + return (isset($this->fields[$string]) ? $this->fields[$string] : ''); + } + /** * Special method to extracting the index of German prints of the marc21 * field 024 indicator 8 subfield a @@ -343,16 +345,11 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getIndexOfGermanPrints() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - // define a false indicator $lookfor_indicator = '8'; $retval = []; - $fields = $this->marcRecord->getFields('024'); + $fields = $this->getMarcRecord()->getFields('024'); if (!$fields) { return null; } @@ -417,11 +414,6 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ public function getJournalHoldings() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - $retval = []; $match = []; @@ -429,7 +421,7 @@ class SolrMarcRemoteFinc extends SolrMarcRemote //$catalog = ConnectionManager::connectToCatalog(); //$terms = $catalog->getConfig('OrderJournalTerms'); - $fields = $this->marcRecord->getFields('971'); + $fields = $this->getMarcRecord()->getFields('971'); if (!$fields) { return []; } @@ -494,13 +486,8 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getLocalClassSubjects() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - $array = []; - $classsubjects = $this->marcRecord->getFields('979'); + $classsubjects = $this->getMarcRecord()->getFields('979'); // if not return void value if (!$classsubjects) { return $array; @@ -581,14 +568,9 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getMusicHeading() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - $retval = []; - $fields = $this->marcRecord->getFields('937'); + $fields = $this->getMarcRecord()->getFields('937'); if (!$fields) { return null; } @@ -642,18 +624,13 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getParallelEditions() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - $array = []; $fields = ['775']; $i = 0; foreach ($fields as $field) { - $related = $this->marcRecord->getFields($field); + $related = $this->getMarcRecord()->getFields($field); // if no entry break it if ($related) { foreach ($related as $key => $line) { @@ -764,15 +741,10 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getUDKs() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - $array = []; if (null != $this->localMarcFieldOfLibrary) { - $udk = $this->marcRecord->getFields($this->localMarcFieldOfLibrary); + $udk = $this->getMarcRecord()->getFields($this->localMarcFieldOfLibrary); // if not return void value if (!$udk) { return $array; @@ -820,15 +792,10 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getAdditionalAuthors() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - // result array to return $retval = []; - $results = $this->marcRecord->getFields('700'); + $results = $this->getMarcRecord()->getFields('700'); if (!$results) { return $retval; } @@ -855,18 +822,13 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getAdditionals() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - $array = []; $fields = ['770','775','776']; $i = 0; foreach ($fields as $field) { - $related = $this->marcRecord->getFields($field); + $related = $this->getMarcRecord()->getFields($field); // if no entry break it if ($related) { foreach ($related as $key => $line) { @@ -904,16 +866,11 @@ class SolrMarcRemoteFinc extends SolrMarcRemote */ protected function getAllSubjectHeadingsExtended() { - - if(empty($this->marcRecord)) { - $this->getRemoteData(); - } - // define a false indicator $firstindicator = 'x'; $retval = []; - $fields = $this->marcRecord->getFields('689'); + $fields = $this->getMarcRecord()->getFields('689'); if (!$fields) { return null; }