use of org.marc4j.marc.Subfield in project RecordManager2 by moravianlibrary.
the class AdresarKnihovenMarcFunctions method adresarGetHours.
public String adresarGetHours(MarcFunctionContext ctx) {
String separator = " | ";
for (DataField df : ctx.record().getDataFields("OTD")) {
StringBuilder sb = new StringBuilder();
for (Subfield sf : df.getSubfields()) {
try {
List<String> get = propertyResolver.resolve(MAP_ADRESAR_HOURS).get(String.valueOf(sf.getCode()));
if (get != null) {
if (sb.length() > 0)
sb.append(separator);
sb.append(get.get(0) + " " + sf.getData());
}
} catch (IOException e) {
e.printStackTrace();
}
}
String temp = sb.toString();
if (!temp.isEmpty())
return temp;
}
return null;
}
use of org.marc4j.marc.Subfield in project RecordManager2 by moravianlibrary.
the class GetStatusesMarcFunctions method getStatuses.
private List<String> getStatuses(MarcRecord record, String statusField) {
List<DataField> fields = record.getAllFields().get(statusField);
if (fields == null || fields.isEmpty()) {
return Collections.emptyList();
}
List<String> statuses = new ArrayList<String>();
boolean present = false;
boolean absent = false;
boolean freestack = false;
for (DataField field : fields) {
Subfield s = field.getSubfield('s');
if (s == null) {
continue;
}
String statusInS = s.getData().toLowerCase();
switch(statusInS) {
case ABSENT:
absent = true;
break;
case PRESENT:
present = true;
break;
}
s = field.getSubfield('a');
if (s == null) {
continue;
}
String statusInA = s.getData().toLowerCase();
switch(statusInA) {
case FREESTACK:
freestack = true;
break;
}
}
if (absent) {
statuses.addAll(SolrUtils.createHierarchicFacetValues("absent"));
}
if (present) {
statuses.addAll(SolrUtils.createHierarchicFacetValues("present"));
}
if (freestack) {
statuses.addAll(SolrUtils.createHierarchicFacetValues("freestack"));
}
return statuses;
}
use of org.marc4j.marc.Subfield in project RecordManager2 by moravianlibrary.
the class EANUtils method createEan.
/**
* @param rawDataField {@link DataField}, usually tag 024, 1. indicator = 3
* @return {@link Ean}
*/
public static Ean createEan(final DataField rawDataField) {
Subfield subfieldA = rawDataField.getSubfield('a');
if (rawDataField.getIndicator1() != '3' || subfieldA == null)
throw new NoDataException(IdentifierUtils.NO_SUBFIELD);
Matcher matcher = EAN_NOTE_PATTERN.matcher(subfieldA.getData());
if (!matcher.find())
throw new NoDataException(IdentifierUtils.NO_USABLE_DATA);
Long validEan = getEAN13Long(matcher.group(1));
if (validEan == null)
throw new NumberFormatException(matcher.group(1));
List<String> notes = new ArrayList<>();
notes.add(IdentifierUtils.parseNote(matcher.group(2)));
for (Subfield subfieldQ : rawDataField.getSubfields('q')) {
notes.add(IdentifierUtils.parseNote(subfieldQ.getData()));
}
return Ean.create(validEan, 1L, String.join(" ", notes));
}
use of org.marc4j.marc.Subfield in project RecordManager2 by moravianlibrary.
the class ISBNUtils method createIsbn.
/**
* @param rawDataField {@link DataField}, usually tag 020
* @return {@link Isbn}
*/
public static Isbn createIsbn(final DataField rawDataField) {
Subfield subfieldA = rawDataField.getSubfield('a');
if (subfieldA == null)
throw new NoDataException(IdentifierUtils.NO_SUBFIELD);
Matcher matcherIsbn = ISBN_PATTERN.matcher(subfieldA.getData());
if (!matcherIsbn.find())
throw new NoDataException(IdentifierUtils.NO_USABLE_DATA);
Long isbnLong = toISBN13LongThrowing(matcherIsbn.group(1));
List<String> notes = new ArrayList<>();
notes.add(IdentifierUtils.parseNote(matcherIsbn.group(2)));
for (Subfield subfieldQ : rawDataField.getSubfields('q')) {
notes.add(IdentifierUtils.parseNote(subfieldQ.getData()));
}
return Isbn.create(isbnLong, 1L, String.join(" ", notes));
}
use of org.marc4j.marc.Subfield in project RecordManager2 by moravianlibrary.
the class ISSNUtils method createIssn.
/**
* @param rawDataField {@link DataField}, usually tag 022
* @return {@link Issn}
*/
public static Issn createIssn(final DataField rawDataField) {
Subfield subfieldA = rawDataField.getSubfield('a');
if (subfieldA == null)
throw new NoDataException(IdentifierUtils.NO_SUBFIELD);
Matcher matcherIssn = ISSN_PATTERN.matcher(subfieldA.getData());
if (!matcherIssn.find())
throw new NoDataException(IdentifierUtils.NO_USABLE_DATA);
if (!isValidLocal(matcherIssn.group(1)))
throw new NumberFormatException(matcherIssn.group(1));
List<String> notes = new ArrayList<>();
notes.add(IdentifierUtils.parseNote(matcherIssn.group(2)));
for (Subfield subfieldQ : rawDataField.getSubfields('q')) {
notes.add(IdentifierUtils.parseNote(subfieldQ.getData()));
}
return Issn.create(matcherIssn.group(1), 1L, String.join(" ", notes));
}
Aggregations