From 82729f58492c64a18182b394a9ddedab49daaaf4 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 28 Jan 2016 12:58:31 -0500 Subject: [PATCH] More consistent support of repeating 260/264 fields. --- import/index_scripts/getdate.bsh | 21 +++++++++++-------- import/index_scripts/getpublishers.bsh | 20 +++++++++++------- .../src/VuFind/RecordDriver/SolrMarc.php | 8 +++---- tests/data/testpubfields.mrc | 1 + 4 files changed, 29 insertions(+), 21 deletions(-) create mode 100644 tests/data/testpubfields.mrc diff --git a/import/index_scripts/getdate.bsh b/import/index_scripts/getdate.bsh index 5d615c15f74..0a8186b4d5b 100644 --- a/import/index_scripts/getdate.bsh +++ b/import/index_scripts/getdate.bsh @@ -137,23 +137,26 @@ public Set getDates(Record record) { Set dates = new LinkedHashSet(); // First check old-style 260c date: - String oldStyle = getDate(record); - if (oldStyle != null && oldStyle.length() > 0) { - dates.add(oldStyle); + List list260 = record.getVariableFields("260"); + for (VariableField vf : list260) { + DataField df = (DataField) vf; + List currentDates = df.getSubfields('c'); + for (Subfield sf : currentDates) { + String currentDateStr = cleanDate(sf.getData()); + dates.add(currentDateStr); + } } - // Now track down relevant RDA-style 264c dates; we only care about // copyright and publication dates (and ignore copyright dates if // publication dates are present). Set pubDates = new LinkedHashSet(); Set copyDates = new LinkedHashSet(); List list264 = record.getVariableFields("264"); - for (VariableField vf : list264) - { + for (VariableField vf : list264) { DataField df = (DataField) vf; - Subfield currentDate = df.getSubfield('c'); - if (currentDate != null) { - String currentDateStr = cleanDate(currentDate.getData()); + List currentDates = df.getSubfields('c'); + for (Subfield sf : currentDates) { + String currentDateStr = cleanDate(sf.getData()); char ind2 = df.getIndicator2(); switch (ind2) { diff --git a/import/index_scripts/getpublishers.bsh b/import/index_scripts/getpublishers.bsh index aa5a6e5034a..465909590cc 100644 --- a/import/index_scripts/getpublishers.bsh +++ b/import/index_scripts/getpublishers.bsh @@ -21,9 +21,12 @@ public Set getPublishers(Record record) { for (VariableField vf : list260) { DataField df = (DataField) vf; - Subfield current = df.getSubfield('b'); - if (current != null) { - publishers.add(current.getData()); + String currentString = ""; + for (Subfield current : df.getSubfields('b')) { + currentString = currentString.trim().concat(" " + current.getData()).trim(); + } + if (currentString.length() > 0) { + publishers.add(currentString); } } @@ -36,16 +39,19 @@ public Set getPublishers(Record record) { for (VariableField vf : list264) { DataField df = (DataField) vf; - Subfield currentName = df.getSubfield('b'); - if (currentName != null) { + String currentString = ""; + for (Subfield current : df.getSubfields('b')) { + currentString = currentString.trim().concat(" " + current.getData()).trim(); + } + if (currentString.length() > 0) { char ind2 = df.getIndicator2(); switch (ind2) { case '1': - pubNames.add(currentName.getData()); + pubNames.add(currentString); break; case '4': - copyNames.add(currentName.getData()); + copyNames.add(currentString); break; } } diff --git a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php index 4d1713e12e4..6593eeab706 100644 --- a/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php +++ b/module/VuFind/src/VuFind/RecordDriver/SolrMarc.php @@ -320,16 +320,14 @@ class SolrMarc extends SolrDefault $fields = $this->getMarcRecord()->getFields('264'); if (is_array($fields)) { foreach ($fields as $currentField) { - $currentVal = $currentField->getSubfield($subfield); - $currentVal = is_object($currentVal) - ? $currentVal->getData() : null; + $currentVal = $this->getSubfieldArray($currentField, [$subfield]); if (!empty($currentVal)) { switch ($currentField->getIndicator('2')) { case '1': - $pubResults[] = $currentVal; + $pubResults = array_merge($pubResults, $currentVal); break; case '4': - $copyResults[] = $currentVal; + $copyResults = array_merge($copyResults, $currentVal); break; } } diff --git a/tests/data/testpubfields.mrc b/tests/data/testpubfields.mrc new file mode 100644 index 00000000000..a72f0e3f1e3 --- /dev/null +++ b/tests/data/testpubfields.mrc @@ -0,0 +1 @@ +00830cam a2200253Ma 4500001001400000005001700014008004100031020001500072035002300087040002500110041001800135043001200153050002400165049000900189100003600198245004000234250002300274260007500297264007500372300002900447651006500476700002300541994001200564testpubfields20110419140028.0110214s1992 it a b 001 0 ita d a8820737493 a(OCoLC)ocm30585539 aRBNcRBNdOCLCGdPVU1 aitaalathlat ae-it---14aDG848.15b.V53 1992 aPVUM1 aVico, Giambattista,d1668-1744.14aThe test of the publication fields. aFictional edition. aLocation 1 ;aLocation 2 :bPublisher 1 ;bPublisher 2,c1992 ;c1993. 1aLocation 3 ;aLocation 4 :bPublisher 3 ;bPublisher 4,c2015 ;c2016. a296 p. :bill. ;c24 cm. 0aNaples (Kingdom)xHistoryySpanish rule, 1442-1707vSources.1 aPandolfi, Claudia. aC0bPVU \ No newline at end of file -- GitLab