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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations