use of cz.mzk.recordmanager.server.model.ImportConfiguration 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 cz.mzk.recordmanager.server.model.ImportConfiguration in project RecordManager2 by moravianlibrary.
the class ImportConfigurationDAOTest method getNLK.
@Test
public void getNLK() {
ImportConfiguration importConf = importConfigurationDao.get(301L);
Assert.assertNotNull(importConf);
Assert.assertEquals(importConf.getHarvestFrequency(), null);
}
use of cz.mzk.recordmanager.server.model.ImportConfiguration in project RecordManager2 by moravianlibrary.
the class ImportConfigurationDAOTest method getMZK.
@Test
public void getMZK() {
ImportConfiguration importConf = importConfigurationDao.get(300L);
Assert.assertNotNull(importConf);
Assert.assertEquals(importConf.getHarvestFrequency(), HarvestFrequency.DAILY);
}
use of cz.mzk.recordmanager.server.model.ImportConfiguration in project RecordManager2 by moravianlibrary.
the class ImportConfigurationDAOTest method persist.
@Test
public void persist() {
OAIHarvestConfiguration importConf = new OAIHarvestConfiguration();
importConf.setLibrary(libraryDao.get(100L));
importConf.setContact(contactPersonDao.get(200L));
importConf.setUrl("http://aleph.mzk.cz/OAI");
importConf.setHarvestFrequency(HarvestFrequency.WEEKLY);
importConfigurationDao.persist(importConf);
ImportConfiguration importConfFromDB = importConfigurationDao.get(importConf.getId());
Assert.assertNotNull(importConfFromDB);
Assert.assertEquals(importConfFromDB.getHarvestFrequency(), HarvestFrequency.WEEKLY);
}
use of cz.mzk.recordmanager.server.model.ImportConfiguration in project RecordManager2 by moravianlibrary.
the class MarcXmlDedupKeyParserTest method parseCorrectRecord.
@Test
public void parseCorrectRecord() throws Exception {
InputStream is = this.getClass().getResourceAsStream("/records/marcxml/MZK01-001439241.xml");
ImportConfiguration ic = importConfDao.get(300L);
HarvestedRecordUniqueId id = new HarvestedRecordUniqueId(ic, "1");
HarvestedRecord record = new HarvestedRecord(id);
record.setHarvestedFrom(ic);
record.setFormat("marc21-xml");
byte[] rawRecord = ByteStreams.toByteArray(is);
record.setRawRecord(rawRecord);
record.setId(1L);
parser.parse(record);
Assert.assertTrue(record.getIsbns().size() > 0);
Assert.assertEquals(record.getIsbns().get(0).getIsbn(), EXPECTED_ISBN);
Assert.assertEquals(record.getTitles().size(), 1);
Assert.assertEquals(record.getTitles().get(0).getTitleStr(), EXPECTED_TITLE);
Assert.assertEquals(record.getPhysicalFormats().size(), 1);
Assert.assertEquals(record.getPhysicalFormats().get(0).getName(), HarvestedRecordFormatEnum.BOOKS.name());
Assert.assertEquals(record.getPublicationYear(), new Long(2014));
Assert.assertEquals(record.getAuthorAuthKey(), EXPECTED_AUTHORAUTHKEY);
Assert.assertEquals(record.getAuthorString(), EXPECTED_AUTHORSTRING);
Assert.assertEquals(record.getScale(), EXPECTED_SCALE);
Assert.assertEquals(record.getUuid(), EXPECTED_UUID);
Assert.assertEquals(record.getIssnSeries(), EXPECTED_ISSNSERIES);
Assert.assertEquals(record.getIssnSeriesOrder(), EXPECTED_ISSNSERIESORDER);
}
Aggregations