use of org.springframework.batch.core.configuration.annotation.StepScope in project microservices by pwillhan.
the class BatchConfiguration method flatFileItemReader.
@Bean
@StepScope
FlatFileItemReader<Person> flatFileItemReader(@Value("#{jobParameters[file]}") File file) {
FlatFileItemReader<Person> r = new FlatFileItemReader<>();
r.setResource(new FileSystemResource(file));
r.setLineMapper(new DefaultLineMapper<Person>() {
{
this.setLineTokenizer(new DelimitedLineTokenizer(",") {
{
this.setNames(new String[] { "first", "last", "email" });
}
});
this.setFieldSetMapper(new BeanWrapperFieldSetMapper<Person>() {
{
this.setTargetType(Person.class);
}
});
}
});
return r;
}
use of org.springframework.batch.core.configuration.annotation.StepScope in project RecordManager2 by moravianlibrary.
the class FilterCaslinRecordsBySiglaJobConfig method caslinRecordsReader.
@Bean(name = Constants.JOB_ID_FILTER_CASLIN + ":caslinRecordsReader")
@StepScope
public synchronized ItemReader<HarvestedRecordUniqueId> caslinRecordsReader() throws Exception {
JdbcPagingItemReader<HarvestedRecordUniqueId> reader = new JdbcPagingItemReader<HarvestedRecordUniqueId>();
SqlPagingQueryProviderFactoryBean pqpf = new SqlPagingQueryProviderFactoryBean();
pqpf.setDataSource(dataSource);
pqpf.setSelectClause("SELECT import_conf_id, record_id");
pqpf.setFromClause("FROM harvested_record");
pqpf.setWhereClause("WHERE import_conf_id = :conf_id and deleted is null");
pqpf.setSortKey("record_id");
Map<String, Object> parameterValues = new HashMap<String, Object>();
parameterValues.put("conf_id", Constants.IMPORT_CONF_ID_CASLIN);
reader.setParameterValues(parameterValues);
reader.setRowMapper(new HarvestedRecordIdRowMapper());
reader.setPageSize(20);
reader.setQueryProvider(pqpf.getObject());
reader.setDataSource(dataSource);
reader.afterPropertiesSet();
return reader;
}
Aggregations