Search in sources :

Example 1 with Cosmotron996RowMapper

use of cz.mzk.recordmanager.server.jdbc.Cosmotron996RowMapper in project RecordManager2 by moravianlibrary.

the class ExportRecordsJobConfig method exportCosmotron996Reader.

@Bean(name = Constants.JOB_ID_EXPORT_COSMOTRON_996 + ":exportCosmotron996Reader")
@StepScope
public ItemReader<Cosmotron996> exportCosmotron996Reader(@Value("#{jobParameters[" + Constants.JOB_PARAM_CONF_ID + "]}") Long configId) throws Exception {
    JdbcPagingItemReader<Cosmotron996> reader = new JdbcPagingItemReader<Cosmotron996>();
    SqlPagingQueryProviderFactoryBean pqpf = new SqlPagingQueryProviderFactoryBean();
    pqpf.setDataSource(dataSource);
    pqpf.setSelectClause("SELECT *");
    pqpf.setFromClause("FROM cosmotron_996");
    pqpf.setWhereClause("WHERE import_conf_id = :conf_id");
    pqpf.setSortKey("record_id");
    Map<String, Object> parameterValues = new HashMap<String, Object>();
    parameterValues.put("conf_id", configId);
    reader.setParameterValues(parameterValues);
    reader.setRowMapper(new Cosmotron996RowMapper());
    reader.setPageSize(20);
    reader.setQueryProvider(pqpf.getObject());
    reader.setDataSource(dataSource);
    reader.afterPropertiesSet();
    return reader;
}
Also used : SqlPagingQueryProviderFactoryBean(org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean) Cosmotron996(cz.mzk.recordmanager.server.model.Cosmotron996) HashMap(java.util.HashMap) Cosmotron996RowMapper(cz.mzk.recordmanager.server.jdbc.Cosmotron996RowMapper) JdbcPagingItemReader(org.springframework.batch.item.database.JdbcPagingItemReader) StepScope(org.springframework.batch.core.configuration.annotation.StepScope) SqlPagingQueryProviderFactoryBean(org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Cosmotron996RowMapper (cz.mzk.recordmanager.server.jdbc.Cosmotron996RowMapper)1 Cosmotron996 (cz.mzk.recordmanager.server.model.Cosmotron996)1 HashMap (java.util.HashMap)1 StepScope (org.springframework.batch.core.configuration.annotation.StepScope)1 JdbcPagingItemReader (org.springframework.batch.item.database.JdbcPagingItemReader)1 SqlPagingQueryProviderFactoryBean (org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean)1 Bean (org.springframework.context.annotation.Bean)1