use of cz.mzk.recordmanager.server.model.DedupRecord in project RecordManager2 by moravianlibrary.
the class UrlEnricherTest method unknownUrlTest.
@Test
public void unknownUrlTest() {
DedupRecord dr = new DedupRecord();
SolrInputDocument merged = new SolrInputDocument();
List<SolrInputDocument> local = new ArrayList<SolrInputDocument>();
local.add(newField(MZK_UNKNOWN_MZK_TEXT_URL));
local.add(newField(TRE_UNKNOWN_MZK_TEXT_URL));
local.add(newField(MZK_UNKNOWN_BRNO_URL));
local.add(newField(TRE_UNKNOWN_BRNO_URL));
local.add(newField(MZK_UNKNOWN_TRE_URL));
List<String> result = new ArrayList<>();
result.add(MZK_UNKNOWN_TRE_URL);
result.add(UNKNOWN_MZK_TEXT_URL);
result.add(UNKNOWN_BRNO_URL);
UrlDedupRecordEnricher ue = new UrlDedupRecordEnricher();
ue.enrich(dr, merged, local);
Assert.assertEquals(merged.getFieldValues(SolrFieldConstants.URL).toArray(), result.toArray());
}
use of cz.mzk.recordmanager.server.model.DedupRecord in project RecordManager2 by moravianlibrary.
the class UrlEnricherTest method onlineUrlTest.
@Test
public void onlineUrlTest() {
DedupRecord dr = new DedupRecord();
SolrInputDocument merged = new SolrInputDocument();
List<SolrInputDocument> local = new ArrayList<SolrInputDocument>();
local.add(newField(MZK_ONLINE_MZK_URL));
local.add(newField(TRE_ONLINE_MZK_URL));
local.add(newField(MZK_UNKNOWN_MZK_URL));
local.add(newField(MZK_PROTECTED_MZK_URL));
List<String> result = new ArrayList<>();
result.add(MZK_ONLINE_MZK_URL);
result.add(TRE_ONLINE_MZK_URL);
UrlDedupRecordEnricher ue = new UrlDedupRecordEnricher();
ue.enrich(dr, merged, local);
Assert.assertEquals(merged.getFieldValues(SolrFieldConstants.URL).toArray(), result.toArray());
}
use of cz.mzk.recordmanager.server.model.DedupRecord in project RecordManager2 by moravianlibrary.
the class UrlEnricherTest method unknownProtectedUrlTest.
@Test
public void unknownProtectedUrlTest() {
DedupRecord dr = new DedupRecord();
SolrInputDocument merged = new SolrInputDocument();
List<SolrInputDocument> local = new ArrayList<SolrInputDocument>();
local.add(newField(TRE_UNKNOWN_MZK_URL));
local.add(newField(MZK_PROTECTED_MZK_URL));
List<String> result = new ArrayList<>();
result.add(MZK_PROTECTED_MZK_URL);
UrlDedupRecordEnricher ue = new UrlDedupRecordEnricher();
ue.enrich(dr, merged, local);
Assert.assertEquals(merged.getFieldValues(SolrFieldConstants.URL).toArray(), result.toArray());
}
use of cz.mzk.recordmanager.server.model.DedupRecord in project RecordManager2 by moravianlibrary.
the class IndexIndividualRecordsTasklet method execute.
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
SolrServerFacade solrServer = solrServerFactory.create(solrUrl, null, LoggingSolrIndexingExceptionHandler.INSTANCE);
for (String solrId : recordIds) {
HarvestedRecord rec = harvestedRecordDao.findBySolrId(solrId);
if (rec == null) {
throw new IllegalArgumentException(String.format("Harvested record %s not found", solrId));
}
DedupRecord dedupRecord = rec.getDedupRecord();
if (dedupRecord == null) {
throw new IllegalArgumentException(String.format("Harvested record %s is not deduplicated, run dedup first.", solrId));
}
List<HarvestedRecord> records = harvestedRecordDao.getByDedupRecord(dedupRecord);
List<SolrInputDocument> documents = solrInputDocumentFactory.create(dedupRecord, records);
documents = SolrUtils.removeHiddenFields(documents);
solrServer.add(documents, commitWithinMs);
}
solrServer.commit();
return RepeatStatus.FINISHED;
}
use of cz.mzk.recordmanager.server.model.DedupRecord in project RecordManager2 by moravianlibrary.
the class IndexRecordsToSolrJobConfig method updatedRecordsReader.
@Bean(name = "indexRecordsToSolrJob:updatedRecordsReader")
@StepScope
public JdbcPagingItemReader<DedupRecord> updatedRecordsReader(@Value("#{jobParameters[" + Constants.JOB_PARAM_FROM_DATE + "]}") Date from, @Value("#{jobParameters[" + Constants.JOB_PARAM_UNTIL_DATE + "]}") Date to) throws Exception {
if (from != null && to == null) {
to = new Date();
}
SqlPagingQueryProviderFactoryBean pqpf = new SqlPagingQueryProviderFactoryBean();
pqpf.setDataSource(dataSource);
pqpf.setSelectClause("SELECT dedup_record_id");
pqpf.setFromClause("FROM dedup_record_last_update");
if (from != null && to != null) {
pqpf.setWhereClause("WHERE last_update BETWEEN :from AND :to");
}
pqpf.setSortKey("dedup_record_id");
JdbcPagingItemReader<DedupRecord> reader = new JdbcPagingItemReader<>();
reader.setRowMapper(new DedupRecordRowMapper("dedup_record_id"));
reader.setPageSize(PAGE_SIZE);
reader.setQueryProvider(pqpf.getObject());
reader.setDataSource(dataSource);
if (from != null && to != null) {
Map<String, Object> parameterValues = new HashMap<>();
parameterValues.put("from", from);
parameterValues.put("to", to);
reader.setParameterValues(parameterValues);
}
reader.setSaveState(true);
reader.afterPropertiesSet();
return reader;
}
Aggregations