Search in sources :

Example 61 with DataField

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

the class MetadataMarcRecord method getISSNs.

@Override
public List<Issn> getISSNs() {
    List<Issn> results = new ArrayList<>();
    Long issnCounter = 0L;
    Issn issn;
    for (DataField df : underlayingMarc.getDataFields("022")) {
        try {
            issn = ISSNUtils.createIssn(df);
        } catch (NoDataException nde) {
            continue;
        } catch (NumberFormatException nfe) {
            logger.info(String.format("Invalid ISSN: %s", nfe.getMessage()));
            continue;
        }
        issn.setOrderInRecord(++issnCounter);
        results.add(issn);
    }
    return results;
}
Also used : DataField(org.marc4j.marc.DataField) Issn(cz.mzk.recordmanager.server.model.Issn) ArrayList(java.util.ArrayList) NoDataException(cz.mzk.recordmanager.server.util.identifier.NoDataException)

Example 62 with DataField

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

the class MetadataMarcRecord method getUrls.

protected List<String> getUrls(String availability) {
    List<String> result = new ArrayList<>();
    for (DataField df : underlayingMarc.getDataFields("856")) {
        if (df.getSubfield('u') == null) {
            continue;
        }
        String link = df.getSubfield('u').getData();
        String comment = "";
        String sub3 = null, subY = null, subZ = null;
        if (df.getSubfield('3') != null) {
            sub3 = df.getSubfield('3').getData();
        }
        if (df.getSubfield('y') != null) {
            subY = df.getSubfield('y').getData();
        }
        if (df.getSubfield('z') != null) {
            subZ = df.getSubfield('z').getData();
        }
        if (sub3 != null) {
            comment = sub3;
            if (subZ != null) {
                comment += " (" + subZ + ")";
            }
        } else if (subY != null) {
            comment = subY;
            if (subZ != null) {
                comment += " (" + subZ + ")";
            }
        } else if (subZ != null) {
            comment = subZ;
        }
        result.add(availability + "|" + link + "|" + comment);
    }
    return result;
}
Also used : DataField(org.marc4j.marc.DataField) ArrayList(java.util.ArrayList)

Example 63 with DataField

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

the class MetadataMarcRecord method getISBNs.

@Override
public List<Isbn> getISBNs() {
    List<Isbn> isbns = new ArrayList<>();
    Long isbnCounter = 0L;
    Isbn isbn;
    for (DataField df : underlayingMarc.getDataFields("020")) {
        try {
            isbn = ISBNUtils.createIsbn(df);
        } catch (NoDataException nde) {
            continue;
        } catch (NumberFormatException nfe) {
            logger.info(String.format("Invalid ISBN: %s", nfe.getMessage()));
            continue;
        }
        isbn.setOrderInRecord(++isbnCounter);
        isbns.add(isbn);
    }
    return isbns;
}
Also used : Isbn(cz.mzk.recordmanager.server.model.Isbn) DataField(org.marc4j.marc.DataField) ArrayList(java.util.ArrayList) NoDataException(cz.mzk.recordmanager.server.util.identifier.NoDataException)

Example 64 with DataField

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

the class MetadataMarcRecord method getOclcs.

@Override
public List<Oclc> getOclcs() {
    List<Oclc> result = new ArrayList<>();
    if (getLanguages().contains("cze"))
        return result;
    for (DataField df : underlayingMarc.getDataFields("035")) {
        Subfield subA = df.getSubfield('a');
        if (subA == null) {
            continue;
        }
        Matcher matcher = OCLC_PATTERN.matcher(subA.getData());
        if (matcher.matches() && matcher.groupCount() >= 2) {
            Oclc oclc = new Oclc();
            oclc.setOclcStr(matcher.group(2));
            result.add(oclc);
        }
    }
    return result;
}
Also used : DataField(org.marc4j.marc.DataField) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Oclc(cz.mzk.recordmanager.server.model.Oclc) Subfield(org.marc4j.marc.Subfield)

Example 65 with DataField

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

the class MetadataMarcRecord method getCitationFormat.

@Override
public CitationRecordType getCitationFormat() {
    String ldr06 = Character.toString(underlayingMarc.getLeader().getTypeOfRecord()).toLowerCase();
    String ldr07 = Character.toString(underlayingMarc.getLeader().getImplDefined1()[0]).toLowerCase();
    // url, for electronic version
    Boolean exists85641 = false;
    for (DataField df : underlayingMarc.getDataFields("856")) {
        if (df.getIndicator1() == '4' && df.getIndicator2() == '1') {
            exists85641 = true;
        }
    }
    if (!underlayingMarc.getDataFields("502").isEmpty()) {
        return CitationRecordType.ACADEMIC_WORK;
    }
    if (CITATION_OR_AT.matcher(ldr06).matches() && CITATION_OR_CDM.matcher(ldr07).matches()) {
        if (exists85641)
            return CitationRecordType.ELECTRONIC_BOOK;
        else
            return CitationRecordType.BOOK;
    }
    if (CITATION_OR_IS.matcher(ldr07).matches()) {
        if (exists85641)
            return CitationRecordType.ELECTRONIC_PERIODICAL;
        else
            return CitationRecordType.PERIODICAL;
    }
    for (DataField df : underlayingMarc.getDataFields("773")) {
        if (CITATION_CONTRIBUTION.matcher(df.toString()).matches()) {
            if (exists85641)
                return CitationRecordType.ELECTRONIC_CONTRIBUTION_PROCEEDINGS;
            else
                return CitationRecordType.CONTRIBUTION_PROCEEDINGS;
        }
    }
    if (CITATION_OR_AB.matcher(ldr07).matches()) {
        if (exists85641)
            return CitationRecordType.ELECTRONIC_ARTICLE;
        else
            return CitationRecordType.ARTICLE;
    }
    if (CITATION_OR_EF.matcher(ldr06).matches())
        return CitationRecordType.MAPS;
    if (CITATION_OR_CDKGIJOPR.matcher(ldr06).matches())
        return CitationRecordType.OTHERS;
    return CitationRecordType.ERROR;
}
Also used : DataField(org.marc4j.marc.DataField)

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