use of cz.mzk.recordmanager.server.jdbc.DedupRecordRowMapper 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