Search in sources :

Example 1 with DataField

use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.

the class MarcDSL method getAuthor2Display.

public List<String> getAuthor2Display() {
    List<String> result = new ArrayList<String>();
    for (DataField df : record.getDataFields("700")) {
        result.add(getNameForDisplay(df));
    }
    result.addAll(getFields("110ab:111ab:710ab:711ab"));
    return result;
}
Also used : DataField(org.marc4j.marc.DataField)

Example 2 with DataField

use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.

the class MarcDSL method getPublisherStrMv.

public List<String> getPublisherStrMv() throws IOException {
    Set<String> publishers = new HashSet<String>();
    for (DataField dataField : record.getDataFields("264")) {
        if (dataField.getIndicator2() == '1') {
            dataField.getSubfields('b').stream().forEach(sf -> publishers.add(editPublisherName(sf.getData())));
        }
    }
    for (DataField dataField : record.getDataFields("928")) {
        if (dataField.getIndicator1() == '9') {
            dataField.getSubfields('a').stream().forEach(sf -> publishers.add(editPublisherName(sf.getData())));
        }
    }
    getFields("260b:978ab").stream().forEach(str -> publishers.add(editPublisherName(str)));
    Set<String> result = new HashSet<String>();
    for (String publisher : publishers) {
        List<String> newPublisher = translate("publisher.map", publisher, null);
        if (newPublisher == null)
            result.add(publisher);
        else
            result.addAll(newPublisher);
    }
    return new ArrayList<String>(result);
}
Also used : DataField(org.marc4j.marc.DataField)

Example 3 with DataField

use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.

the class MarcDSL method getPublisher.

public List<String> getPublisher() {
    List<String> publishers = new ArrayList<String>();
    for (DataField dataField : record.getDataFields("264")) {
        if (dataField.getIndicator2() == '1') {
            publishers.addAll(getFieldsTrim("264b"));
        }
    }
    publishers.addAll(getFieldsTrim("260b"));
    return publishers;
}
Also used : DataField(org.marc4j.marc.DataField)

Example 4 with DataField

use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.

the class MarcDSL method getHoldings996.

public List<String> getHoldings996() {
    List<String> result = new ArrayList<>();
    Map<String, List<DataField>> allFields = record.getAllFields();
    List<DataField> list996 = allFields.get("996");
    if (list996 == null) {
        return result;
    }
    for (DataField dataField : list996) {
        StringBuilder currentSb = new StringBuilder();
        // 996 with '0' in subfield 'q'
        if (dataField.getSubfield('q') != null && dataField.getSubfield('q').getData().equals("0")) {
            continue;
        }
        for (Subfield subfield : dataField.getSubfields()) {
            currentSb.append('$');
            currentSb.append(subfield.getCode());
            currentSb.append(subfield.getData());
        }
        result.add(currentSb.toString());
    }
    return result;
}
Also used : DataField(org.marc4j.marc.DataField) Subfield(org.marc4j.marc.Subfield)

Example 5 with DataField

use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.

the class MarcDSL method getTitleDisplay.

public String getTitleDisplay() {
    DataField df = getFirstDataField("245");
    if (df == null)
        return null;
    final char[] titleSubfields = new char[] { 'a', 'b', 'n', 'p' };
    final char[] sfhPunctuation = new char[] { '.', ',', ':' };
    char endCharH = ' ';
    StringBuilder sb = new StringBuilder();
    for (Subfield sf : df.getSubfields()) {
        // get last punctuation from 'h'
        if (sf.getCode() == 'h') {
            String data = sf.getData().trim();
            if (data.length() > 0) {
                if (Chars.contains(sfhPunctuation, data.charAt(data.length() - 1))) {
                    endCharH = data.charAt(data.length() - 1);
                }
            }
        } else if (Chars.contains(titleSubfields, sf.getCode())) {
            // print punctuation from h
            if (endCharH != ' ') {
                sb.append(endCharH);
                sb.append(" ");
                endCharH = ' ';
            }
            sb.append(sf.getData());
            sb.append(" ");
        } else
            endCharH = ' ';
    }
    return removeEndPunctuation(sb.toString());
}
Also used : DataField(org.marc4j.marc.DataField) Subfield(org.marc4j.marc.Subfield)

Aggregations

DataField (org.marc4j.marc.DataField)82 ArrayList (java.util.ArrayList)18 Subfield (org.marc4j.marc.Subfield)17 MarcRecord (cz.mzk.recordmanager.server.marc.MarcRecord)15 ControlField (org.marc4j.marc.ControlField)13 Record (org.marc4j.marc.Record)13 MarcRecordImpl (cz.mzk.recordmanager.server.marc.MarcRecordImpl)12 RecordImpl (cz.mzk.recordmanager.server.marc.marc4j.RecordImpl)11 List (java.util.List)11 TreeSet (java.util.TreeSet)11 Matcher (java.util.regex.Matcher)11 MarcFactory (org.marc4j.marc.MarcFactory)8 MarcFactoryImpl (cz.mzk.recordmanager.server.marc.marc4j.MarcFactoryImpl)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 NoDataException (cz.mzk.recordmanager.server.util.identifier.NoDataException)4 HarvestedRecord (cz.mzk.recordmanager.server.model.HarvestedRecord)3 IOException (java.io.IOException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 ImportConfiguration (cz.mzk.recordmanager.server.model.ImportConfiguration)2 ShortTitle (cz.mzk.recordmanager.server.model.ShortTitle)2