From aeac1f612ea19a396c612811ee52bb90cfd4293d Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 13 Dec 2013 10:41:12 -0500 Subject: [PATCH] Adding getFullCallNumberNormalized indexing routine. - Resolves VUFIND-598. --- import/index_scripts/callnumber.bsh | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/import/index_scripts/callnumber.bsh b/import/index_scripts/callnumber.bsh index ef0714aa57d..adefd8dfbcb 100644 --- a/import/index_scripts/callnumber.bsh +++ b/import/index_scripts/callnumber.bsh @@ -6,6 +6,7 @@ * it will be applied during indexing. */ import org.marc4j.marc.Record; +import org.solrmarc.tools.CallNumUtils; // define the base level indexer so that its methods can be called from the script. // note that the SolrIndexer code will set this value before the script methods are called. @@ -101,3 +102,35 @@ public String getCallNumberSubject(Record record, String fieldSpec) { } return(null); } + +/** + * Normalize a single LCCN + * @param record + * @param fieldSpec + * @return String Normalized LCCN + */ +public String getFullCallNumberNormalized(Record record) { + + return(getFullCallNumberNormalized(record, "099ab:090ab:050ab")); +} + +/** + * Normalize a single LCCN + * @param record + * @param fieldSpec + * @return String Normalized LCCN + */ +public String getFullCallNumberNormalized(Record record, String fieldSpec) { + + if (fieldSpec != null) { + String cn = indexer.getFirstFieldVal(record, fieldSpec); + try { + return CallNumUtils.getLCShelfkey(cn, null); + } catch(Exception e) { + // Don't bail out of indexing just because of a weird call number! + //System.out.println("getFullCallNumberNormalized error: " + e); + } + } + // If we got this far, we couldn't find a valid value: + return null; +} \ No newline at end of file -- GitLab