[solrmarc] r1785 committed - VuFindIndexer.getLCSortable edge case for no call number

2 views
Skip to first unread message

solr...@googlecode.com

unread,
Mar 6, 2015, 1:37:58 PM3/6/15
to solrmarc...@googlegroups.com
Revision: 1785
Author: olso...@gmail.com
Date: Fri Mar 6 18:37:35 2015 UTC
Log: VuFindIndexer.getLCSortable edge case for no call number
https://code.google.com/p/solrmarc/source/detail?r=1785

Modified:
/trunk/examples/GenericVuFind/src/org/solrmarc/index/VuFindIndexer.java

/trunk/examples/GenericVuFind/test/src/org/solrmarc/index/VuFindIndexerTest.java

=======================================
--- /trunk/examples/GenericVuFind/src/org/solrmarc/index/VuFindIndexer.java
Fri Mar 6 18:06:06 2015 UTC
+++ /trunk/examples/GenericVuFind/src/org/solrmarc/index/VuFindIndexer.java
Fri Mar 6 18:37:35 2015 UTC
@@ -1084,7 +1084,8 @@

/**
* Normalize LC numbers for sorting purposes (use only the first valid
number!).
- * Will return first call number found if none pass validation.
+ * Will return first call number found if none pass validation,
+ * or empty string if no call numbers.
*
* @param record current MARC record
* @param fieldSpec which MARC fields / subfields need to be analyzed
@@ -1094,14 +1095,14 @@
public static String getLCSortable(Record record, String fieldSpec) {
// Loop through the specified MARC fields:
Set<String> input = getFieldList(record, fieldSpec);
- String firstCall = null;
+ String firstCall = "";
for (String current : input) {
// If this is a valid LC number, return the sortable shelf key:
LCCallNumber callNum = new LCCallNumber(current);
if (callNum.isValid()) {
return callNum.getShelfKey(); // RETURN first valid
}
- if (firstCall == null) {
+ if (firstCall.length() == 0) {
firstCall = current;
}
}
=======================================
---
/trunk/examples/GenericVuFind/test/src/org/solrmarc/index/VuFindIndexerTest.java
Fri Mar 6 18:06:06 2015 UTC
+++
/trunk/examples/GenericVuFind/test/src/org/solrmarc/index/VuFindIndexerTest.java
Fri Mar 6 18:37:35 2015 UTC
@@ -181,5 +181,27 @@
assertEquals(new LCCallNumber(callNumDDC).getShelfKey(),
VuFindIndexer.getLCSortable(myCallNumRec, "090a"));
}
+
+
+ /**
+ * Unit test for VuFindIndexer.getLCSortable
+ * case where no call number is in the record.
+ */
+ @Test
+ public void testGetLCSortableNoCallNums() {
+
+ // Init records
+ Record myCallNumRec = new RecordImpl();
+ myCallNumRec.setLeader(genericLeader);;
+
+ String callNumDDC = "324.987 B34";
+ DataField df245 = new DataFieldImpl("245", ' ', ' ');
+ df245.addSubfield(new SubfieldImpl('a', "The Hobbit : "));
+ df245.addSubfield(new SubfieldImpl('b', "or There and Back Again
/ "));
+ df245.addSubfield(new SubfieldImpl('c', "by J.R.R. Tolien"));
+ myCallNumRec.addVariableField(df245);
+
+ assertEquals("",
VuFindIndexer.getLCSortable(myCallNumRec, "090a"));
+ }

}
Reply all
Reply to author
Forward
0 new messages