From: Andrew N. <and...@vi...> - 2008-08-28 15:06:10
|
Naomi - I apologize - I jumped the gun on this. I had fixed this locally and implemented it locally but never checked in my fixes into solrmarc. I just did so now. I believe the fixes were already incorporated in with VuFind however. Andrew From: vuf...@li... [mailto:vuf...@li...] On Behalf Of Naomi Dushay Sent: Wednesday, August 27, 2008 10:54 AM To: vuf...@li... Subject: [VuFind-Tech] Fwd: bug in VuFindIndexer for fullXXX fields ... and a fix Andrew, just want to make sure you saw this. The getAllSubfields() method, as of v127, only gets the *first* of the marc fields indicated by the tag. I believe the intent may have been to cycle through *all* of the marc fields matching the tags. This affects the following VuFind fields: fullTopic fullGenre fullGeographic fullTitle Patch : Index: src/org/solrmarc/index/VuFindIndexer.java =================================================================== --- src/org/solrmarc/index/VuFindIndexer.java (revision 699) +++ src/org/solrmarc/index/VuFindIndexer.java (working copy) @@ -275,31 +275,30 @@ * @param marcFieldNum - the marc field number as a string (e.g. "245") * @return */ - public Set<String> getAllSubfields(final Record record, String marcFieldNum) - { - Set<String> result = new LinkedHashSet<String>(); - - StringBuffer buffer = new StringBuffer(""); - - DataField marcField = (DataField) record.getVariableField(marcFieldNum); - if (marcField != null) { - List<Subfield> subfields = marcField.getSubfields(); - Iterator<Subfield> iter = subfields.iterator(); + public Set<String> getAllSubfields(final Record record, String marcFieldNum) + { + Set<String> result = new LinkedHashSet<String>(); - Subfield subfield; - while (iter.hasNext()) { - subfield = iter.next(); - if (buffer.length() > 0) { - buffer.append(" " + subfield.getData()); - } else { - buffer.append(subfield.getData()); - } - } - result.add(buffer.toString()); + List<VariableField> marcFields = record.getVariableFields(marcFieldNum); + for (VariableField vf : marcFields) { + StringBuffer buffer = new StringBuffer(""); + DataField df = (DataField) vf; + if (df != null) { + List<Subfield> subfields = df.getSubfields(); + for (Subfield sf : subfields) { + if (buffer.length() > 0) { + buffer.append(" " + sf.getData()); + } else { + buffer.append(sf.getData()); + } + } + } + if (buffer.length() > 0) + result.add(buffer.toString()); } - return result; + return result; } /** - Naomi Begin forwarded message: From: Naomi Dushay <nd...@st...<mailto:nd...@st...>> Date: August 22, 2008 4:15:10 PM PDT To: sol...@go...<mailto:sol...@go...> Subject: bug in VuFindIndexer for fullXXX fields ... and a fix Reply-To: sol...@go...<mailto:sol...@go...> The getAllSubfields() method, as of v127, only gets the *first* of the marc fields indicated by the tag. I believe the intent may have been to cycle through *all* of the marc fields matching the tags. This affects the following VuFind fields: fullTopic fullGenre fullGeographic fullTitle Original version of method: public Set<String> getAllSubfields(final Record record, String marcFieldNum) { Set<String> result = new LinkedHashSet<String>(); StringBuffer buffer = new StringBuffer(""); DataField marcField = (DataField) record.getVariableField(marcFieldNum); if (marcField != null) { List<Subfield> subfields = marcField.getSubfields(); Iterator<Subfield> iter = subfields.iterator(); Subfield subfield; while (iter.hasNext()) { subfield = iter.next(); if (buffer.length() > 0) { buffer.append(" " + subfield.getData()); } else { buffer.append(subfield.getData()); } } result.add(buffer.toString()); } return result; } Fixed method: public Set<String> getAllSubfields(final Record record, String marcFieldNum) { Set<String> result = new LinkedHashSet<String>(); List<VariableField> marcFields = record.getVariableFields(marcFieldNum); for (VariableField vf : marcFields) { StringBuffer buffer = new StringBuffer(""); DataField df = (DataField) vf; if (df != null) { List<Subfield> subfields = df.getSubfields(); for (Subfield sf : subfields) { if (buffer.length() > 0) { buffer.append(" " + sf.getData()); } else { buffer.append(sf.getData()); } } } if (buffer.length() > 0) result.add(buffer.toString()); } return result; } Fix that uses an array of tags: /** * For each occurrence of a marc field in the tags list, extract all * subfield data from the field, place it in a single string (individual * subfield data separated by spaces) and add the string to the result set. */ @SuppressWarnings("unchecked") public static final Set<String> getAllSubfields(final Record record, String[] tags) { Set<String> result = new LinkedHashSet<String>(); List<VariableField> varFlds = record.getVariableFields(tags); for (VariableField vf : varFlds) { StringBuffer buffer = new StringBuffer(500); DataField df = (DataField) vf; if (df != null) { List<Subfield> subfields = df.getSubfields(); for (Subfield sf : subfields) { if (buffer.length() > 0) { buffer.append(" " + sf.getData()); } else { buffer.append(sf.getData()); } } } if (buffer.length() > 0) result.add(buffer.toString()); } return result; } This method also might live in org.solrmarc.tools.Utils , no? (Sorry - I'm not able to give you a patch at this time ) Naomi Dushay nd...@st...<mailto:nd...@st...> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "solrmarc-tech" group. To post to this group, send email to sol...@go...<mailto:sol...@go...> To unsubscribe from this group, send email to sol...@go...<mailto:sol...@go...> For more options, visit this group at http://groups.google.com/group/solrmarc-tech?hl=en -~----------~----~----~----~------~----~------~--~--- Naomi Dushay nd...@st...<mailto:nd...@st...> |