use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class AbstractMeshVizFields method getEnrichingValues.
@Override
protected List<String> getEnrichingValues(String key, String enrichingField) {
if (config == null) {
List<ImportConfiguration> configs = configDao.findByIdPrefix(Constants.PREFIX_MESH);
if (configs != null && !configs.isEmpty()) {
config = configs.get(0);
}
}
Map<String, List<String>> cache = cacheMap.get(enrichingField);
if (cache.containsKey(key)) {
return new ArrayList<>(cache.get(key));
} else {
TezaurusRecord tr = tezaurusDao.findByConfigAndSourceFieldAndName(config, "1" + enrichingField.substring(1), key);
if (tr != null) {
MarcRecord mr = marcXmlParser.parseRecord(new ByteArrayInputStream(tr.getRawRecord()));
List<String> results = new ArrayList<>();
for (DataField df : mr.getDataFields(enrichingField)) {
if (df.getSubfield('a') != null && df.getSubfield('7') != null && df.getSubfield('7').getData().startsWith("cze")) {
results.add(df.getSubfield('a').getData());
}
}
if (!results.isEmpty()) {
results = Collections.unmodifiableList(results);
cache.put(key, results);
return new ArrayList<>(results);
}
}
}
return null;
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class MarcDSL method getAuthorExact.
public String getAuthorExact() {
List<DataField> list = record.getDataFields("100");
if (list.isEmpty())
return null;
DataField df = list.get(0);
String name = getNameForExact(df);
if (name != null && name.isEmpty())
return null;
else
return name;
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class MarcDSL method getAuthorFacet.
/**
* remove dot at the end of 700d
*/
public List<String> getAuthorFacet(String k) {
Set<String> results = new HashSet<>();
results.addAll(getFields("100abcdq:975abcdq"));
char[] sfCodes = new char[] { 'a', 'b', 'c', 'd', 'q' };
for (DataField df : record.getDataFields("700")) {
String author = "";
for (char c : sfCodes) {
if (df.getSubfield(c) != null) {
author += df.getSubfield(c).getData() + " ";
if (c == 'd') {
author = author.trim();
if (author.endsWith("."))
author = author.substring(0, author.length() - 1);
}
}
}
if (!author.isEmpty())
results.add(author.trim());
}
return new ArrayList<>(results);
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class MarcDSL method getISBNISSNISMN.
public Set<String> getISBNISSNISMN() {
Set<String> result = new HashSet<String>();
for (DataField df : record.getDataFields("024")) {
if (df.getIndicator1() == '2') {
result.addAll(getFields("024az"));
}
}
result.addAll(getFields("020az:022az:787xz:902a"));
return result;
}
use of org.marc4j.marc.DataField in project RecordManager2 by moravianlibrary.
the class MarcDSL method getConspectus.
public Set<String> getConspectus() throws IOException {
Set<String> result = new HashSet<>();
for (DataField df : record.getDataFields("072")) {
if ((df.getSubfield('2') != null) && (df.getSubfield('2').getData().equals("Konspekt")) && (df.getSubfield('9') != null) && (df.getSubfield('x') != null && (df.getSubfield('a') != null))) {
String subcat_code_source = df.getSubfield('a').getData().trim();
String subcat_name_source = df.getSubfield('x').getData().trim();
String cat_code_source = df.getSubfield('9').getData().trim();
boolean cat_code_exists = false;
List<String> cat_code = translate(MAP_CONSPECTUS_SUBCAT_CAT_CHANGE, subcat_code_source, null);
if (cat_code != null) {
String[] split = cat_code.get(0).split("\\|");
if (split[1].equals(cat_code_source)) {
cat_code_source = split[0];
cat_code_exists = true;
}
}
if (!cat_code_exists) {
cat_code = translate(MAP_CATEGORY_SUBCATEGORY, subcat_code_source, null);
if (cat_code == null || !cat_code.contains(cat_code_source))
continue;
}
List<String> subcat_name = translate(MAP_SUBCATEGORY_NAME, subcat_code_source, null);
if (subcat_name != null && subcat_name.contains(subcat_name_source)) {
String subcat_name_for_facet = null;
List<String> subcat_name_temp = translate(MAP_CONSPECTUS_NAMES, subcat_code_source + " - " + subcat_name_source, null);
if (subcat_name_temp != null && !subcat_name_temp.isEmpty()) {
subcat_name_for_facet = subcat_name_temp.get(0);
} else
subcat_name_for_facet = subcat_name_source;
List<String> category = translate(MAP_CONSPECTUS_CATEGORY, cat_code_source, null);
result.addAll(SolrUtils.createHierarchicFacetValues(category.get(0), subcat_name_for_facet));
}
}
}
return result;
}
Aggregations