use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class MarcRecordImpl method addDataField.
@Override
public void addDataField(String tag, char ind1, char ind2, String... subfields) {
MarcFactory factory = MarcFactoryImpl.newInstance();
DataField df = factory.newDataField(tag, ind1, ind2, subfields);
record.addVariableField(df);
}
use of org.marc4j.marc.DataField 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.DataField in project RecordManager2 by moravianlibrary.
the class AdresarKnihovenMarcFunctions method adresarGetUrlDisplay.
public List<String> adresarGetUrlDisplay(MarcFunctionContext ctx) {
List<String> results = new ArrayList<>();
results.addAll(ctx.record().getFields("URL", " | ", 'u', 'z'));
for (DataField df : ctx.record().getDataFields("ADK")) {
if (df.getSubfield('u') != null) {
results.add(df.getSubfield('u').getData() + " | " + (df.getSubfield('z') != null ? df.getSubfield('z').getData() : URL_COMMENT));
}
}
return results.isEmpty() ? null : results;
}
use of org.marc4j.marc.DataField 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.DataField in project RecordManager2 by moravianlibrary.
the class RecordUtils method sortFields.
public static Record sortFields(Record record) {
Record newRecord = factory.newRecord();
newRecord.setLeader(record.getLeader());
for (ControlField cf : record.getControlFields()) {
newRecord.addVariableField(cf);
}
MarcRecord marc = new MarcRecordImpl(record);
Map<String, List<DataField>> dfMap = marc.getAllFields();
for (String tag : new TreeSet<>(dfMap.keySet())) {
// sorted tags
for (DataField df : dfMap.get(tag)) {
newRecord.addVariableField(df);
}
}
return newRecord;
}
Aggregations