use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class MarcDSL method getAllFields.
/*
* Get all fields starting with the 100 and ending with the 839
* This will ignore any "code" fields and only use textual fields
*/
public List<String> getAllFields() {
Map<String, List<DataField>> allFields = record.getAllFields();
List<String> result = new ArrayList<String>();
for (Entry<String, List<DataField>> entry : allFields.entrySet()) {
int tag = -1;
try {
tag = Integer.parseInt(entry.getKey());
} catch (NumberFormatException nfe) {
continue;
}
if ((tag < 100) || (tag >= 840)) {
continue;
}
List<DataField> fields = entry.getValue();
StringBuffer buffer = new StringBuffer();
for (DataField field : fields) {
List<Subfield> subfields = field.getSubfields();
Iterator<Subfield> subfieldsIter = subfields.iterator();
while (subfieldsIter.hasNext()) {
Subfield subfield = (Subfield) subfieldsIter.next();
if (buffer.length() > 0) {
buffer.append(" " + subfield.getData());
} else {
buffer.append(subfield.getData());
}
}
}
result.add(buffer.toString());
}
return result;
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class MarcDSL method getAuthorDisplay.
public String getAuthorDisplay() {
List<DataField> list = record.getDataFields("100");
if (list.isEmpty())
return null;
DataField df = list.get(0);
String name = getNameForDisplay(df);
if (name != null && name.isEmpty())
return null;
else
return name;
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class AdresarKnihovenMarcFunctions method adresarGetResponsibility.
public List<String> adresarGetResponsibility(MarcFunctionContext ctx) {
List<String> results = new ArrayList<>();
char[] sfCodes = new char[] { 't', 'k', 'p', 'r', 'f', 'e' };
Subfield sf;
for (DataField df : ctx.record().getDataFields("JMN")) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < sfCodes.length; i++) {
if ((sf = df.getSubfield(sfCodes[i])) == null)
continue;
switch(sf.getCode()) {
case 'k':
case 'p':
sb.append(" ");
sb.append(sf.getData());
break;
case 'r':
sb.append(" (");
sb.append(sf.getData());
sb.append(")");
break;
case 'f':
case 'e':
sb.append(" ; ");
sb.append(sf.getData());
break;
default:
sb.append(sf.getData());
break;
}
}
results.add(sb.toString().trim());
}
return results;
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class AdresarKnihovenMarcFunctions method adresarGetNameAlt.
public List<String> adresarGetNameAlt(MarcFunctionContext ctx, String separator) {
List<String> results = new ArrayList<>();
for (DataField df : ctx.record().getDataFields("VAR")) {
if (df.getIndicator1() == '2') {
StringBuilder sb = new StringBuilder();
for (char code : new char[] { 'a', 'b', 'c' }) {
if (df.getSubfield(code) != null) {
sb.append(df.getSubfield(code).getData());
sb.append(separator);
}
}
String temp = sb.toString();
if (temp.endsWith(separator))
temp = temp.substring(0, temp.length() - separator.length());
results.add(temp);
}
}
return results;
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class AdresarKnihovenMarcFunctions method getAllLibraryFields.
public Set<String> getAllLibraryFields(MarcFunctionContext ctx) {
Set<String> results = new HashSet<>();
for (List<DataField> list : ctx.record().getAllFields().values()) {
StringBuffer sb = new StringBuffer();
for (DataField df : list) {
for (Subfield sf : df.getSubfields()) {
if (sb.length() > 0)
sb.append(" ");
sb.append(sf.getData());
}
}
results.add(sb.toString());
}
return results;
}
Aggregations