Search in sources :

Example 1 with NoDataException

use of cz.mzk.recordmanager.server.util.identifier.NoDataException in project RecordManager2 by moravianlibrary.

the class MetadataDublinCoreRecord method getISMNs.

@Override
public List<Ismn> getISMNs() {
    List<Ismn> results = new ArrayList<>();
    Long ismnCounter = 0L;
    Matcher matcher;
    for (String identifier : dcRecord.getIdentifiers()) {
        String rawIsmnStr = "";
        if ((matcher = DC_ISMN_PATTERN.matcher(identifier)).find())
            rawIsmnStr = matcher.group(1);
        else if (!DC_IDENTIFIER_PATTERN.matcher(identifier).matches())
            rawIsmnStr = identifier;
        Long validIsmnLong;
        try {
            validIsmnLong = ISMNUtils.toIsmn13LongThrowing(rawIsmnStr);
        } catch (NoDataException nde) {
            continue;
        } catch (NumberFormatException nfe) {
            logger.info(String.format("Invalid ISMN: %s", rawIsmnStr));
            continue;
        }
        results.add(Ismn.create(validIsmnLong, ++ismnCounter, ""));
    }
    return results;
}
Also used : Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Ismn(cz.mzk.recordmanager.server.model.Ismn) NoDataException(cz.mzk.recordmanager.server.util.identifier.NoDataException)

Example 2 with NoDataException

use of cz.mzk.recordmanager.server.util.identifier.NoDataException in project RecordManager2 by moravianlibrary.

the class MetadataMarcRecord method getISMNs.

@Override
public List<Ismn> getISMNs() {
    List<Ismn> results = new ArrayList<>();
    Long ismnCounter = 0L;
    Ismn ismn;
    for (DataField df : underlayingMarc.getDataFields("024")) {
        try {
            ismn = ISMNUtils.createIsmn(df);
        } catch (NoDataException nde) {
            continue;
        } catch (NumberFormatException nfe) {
            logger.info(String.format("Invalid ISMN: %s", nfe.getMessage()));
            continue;
        }
        ismn.setOrderInRecord(++ismnCounter);
        results.add(ismn);
    }
    return results;
}
Also used : DataField(org.marc4j.marc.DataField) ArrayList(java.util.ArrayList) Ismn(cz.mzk.recordmanager.server.model.Ismn) NoDataException(cz.mzk.recordmanager.server.util.identifier.NoDataException)

Example 3 with NoDataException

use of cz.mzk.recordmanager.server.util.identifier.NoDataException 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 4 with NoDataException

use of cz.mzk.recordmanager.server.util.identifier.NoDataException 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 5 with NoDataException

use of cz.mzk.recordmanager.server.util.identifier.NoDataException in project RecordManager2 by moravianlibrary.

the class MetadataMarcRecord method getEANs.

@Override
public List<Ean> getEANs() {
    List<Ean> results = new ArrayList<>();
    Long eanCounter = 0L;
    Ean ean;
    for (DataField df : underlayingMarc.getDataFields("024")) {
        try {
            ean = EANUtils.createEan(df);
        } catch (NoDataException nde) {
            continue;
        } catch (NumberFormatException nfe) {
            logger.info(String.format("Invalid EAN: %s", nfe.getMessage()));
            continue;
        }
        ean.setOrderInRecord(++eanCounter);
        results.add(ean);
    }
    return results;
}
Also used : Ean(cz.mzk.recordmanager.server.model.Ean) DataField(org.marc4j.marc.DataField) ArrayList(java.util.ArrayList) NoDataException(cz.mzk.recordmanager.server.util.identifier.NoDataException)

Aggregations

NoDataException (cz.mzk.recordmanager.server.util.identifier.NoDataException)7 ArrayList (java.util.ArrayList)7 DataField (org.marc4j.marc.DataField)4 Matcher (java.util.regex.Matcher)3 Isbn (cz.mzk.recordmanager.server.model.Isbn)2 Ismn (cz.mzk.recordmanager.server.model.Ismn)2 Issn (cz.mzk.recordmanager.server.model.Issn)2 Ean (cz.mzk.recordmanager.server.model.Ean)1