use of cz.mzk.recordmanager.server.jdbc.LongValueRowMapper in project RecordManager2 by moravianlibrary.
the class UniqueRecordsDedupTasklet method execute.
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
ExecutionContext ctx = chunkContext.getStepContext().getStepExecution().getExecutionContext();
long harvestedRecordId = ctx.getLong("harvestedRecordId", 0L);
Long nextHarvestedRecordId = DataAccessUtils.singleResult(jdbcTemplate.query(command, new Object[] { harvestedRecordId }, new LongValueRowMapper()));
if (nextHarvestedRecordId != null) {
ctx.putLong("harvestedRecordId", nextHarvestedRecordId);
}
logger.debug("nextHarvestedRecordId: {}", nextHarvestedRecordId);
return (nextHarvestedRecordId == null) ? RepeatStatus.FINISHED : RepeatStatus.CONTINUABLE;
}
use of cz.mzk.recordmanager.server.jdbc.LongValueRowMapper in project RecordManager2 by moravianlibrary.
the class MiscellaneousJobsConfig method generateSkatKeysReader.
@Bean(name = Constants.JOB_ID_GENERATE_SKAT_DEDUP_KEYS + ":generateSkatKeysReader")
@StepScope
public ItemReader<Long> generateSkatKeysReader(@Value("#{jobParameters[" + Constants.JOB_PARAM_FROM_DATE + "]}") Date fromDate, @Value("#{jobParameters[" + Constants.JOB_PARAM_UNTIL_DATE + "]}") Date toDate) throws Exception {
Date from = fromDate == null ? new Date(0) : fromDate;
Date to = toDate == null ? new Date() : toDate;
JdbcPagingItemReader<Long> reader = new JdbcPagingItemReader<>();
SqlPagingQueryProviderFactoryBean pqpf = new SqlPagingQueryProviderFactoryBean();
pqpf.setDataSource(dataSource);
pqpf.setSelectClause("SELECT id");
pqpf.setFromClause("FROM harvested_record");
pqpf.setWhereClause("WHERE import_conf_id = :conf_id AND updated > :updated_from AND updated < :updated_to");
pqpf.setSortKey("id");
Map<String, Object> parameterValues = new HashMap<String, Object>();
parameterValues.put("conf_id", Constants.IMPORT_CONF_ID_CASLIN);
parameterValues.put("updated_from", from);
parameterValues.put("updated_to", to);
reader.setParameterValues(parameterValues);
reader.setRowMapper(new LongValueRowMapper());
reader.setPageSize(100);
reader.setQueryProvider(pqpf.getObject());
reader.setDataSource(dataSource);
reader.afterPropertiesSet();
return reader;
}
use of cz.mzk.recordmanager.server.jdbc.LongValueRowMapper in project RecordManager2 by moravianlibrary.
the class RegenerateDedupKeysJobConfig method reader.
@Bean(name = Constants.JOB_ID_REGEN_DEDUP_KEYS + ":regenarateDedupKeysReader")
@StepScope
public ItemReader<Long> reader() throws Exception {
JdbcPagingItemReader<Long> reader = new JdbcPagingItemReader<Long>();
SqlPagingQueryProviderFactoryBean pqpf = new SqlPagingQueryProviderFactoryBean();
pqpf.setDataSource(dataSource);
pqpf.setSelectClause("SELECT id");
pqpf.setFromClause("FROM harvested_record hr");
pqpf.setWhereClause("WHERE dedup_keys_hash is null");
pqpf.setSortKey("id");
reader.setRowMapper(new LongValueRowMapper());
reader.setPageSize(100);
reader.setQueryProvider(pqpf.getObject());
reader.setDataSource(dataSource);
reader.afterPropertiesSet();
return reader;
}
use of cz.mzk.recordmanager.server.jdbc.LongValueRowMapper in project RecordManager2 by moravianlibrary.
the class IndexRecordsToSolrJobConfig method orphanedRecordsReader.
@Bean(name = "indexRecordsToSolrJob:orphanedRecordsReader")
@StepScope
public JdbcPagingItemReader<Long> orphanedRecordsReader(@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_orphaned");
if (from != null && to != null) {
pqpf.setWhereClause("WHERE orphaned BETWEEN :from AND :to");
}
pqpf.setSortKey("dedup_record_id");
JdbcPagingItemReader<Long> reader = new JdbcPagingItemReader<>();
reader.setRowMapper(new LongValueRowMapper());
reader.setPageSize(100000);
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