Search in sources :

Example 1 with DelimitedLineAggregator

use of org.springframework.batch.item.file.transform.DelimitedLineAggregator in project nixmash-blog by mintster.

the class DemoJobConfiguration method demoJobWriter.

@Bean
public ItemWriter<PostDTO> demoJobWriter() {
    FlatFileItemWriter<PostDTO> writer = new FlatFileItemWriter<>();
    writer.setResource(new FileSystemResource("/home/daveburke/web/nixmashspring/posts.csv"));
    DelimitedLineAggregator<PostDTO> delLineAgg = new DelimitedLineAggregator<>();
    delLineAgg.setDelimiter(";");
    BeanWrapperFieldExtractor<PostDTO> fieldExtractor = new BeanWrapperFieldExtractor<>();
    fieldExtractor.setNames(new String[] { "postTitle" });
    delLineAgg.setFieldExtractor(fieldExtractor);
    writer.setLineAggregator(delLineAgg);
    return writer;
}
Also used : BeanWrapperFieldExtractor(org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor) FlatFileItemWriter(org.springframework.batch.item.file.FlatFileItemWriter) PostDTO(com.nixmash.blog.jpa.dto.PostDTO) FileSystemResource(org.springframework.core.io.FileSystemResource) DelimitedLineAggregator(org.springframework.batch.item.file.transform.DelimitedLineAggregator) Bean(org.springframework.context.annotation.Bean)

Aggregations

PostDTO (com.nixmash.blog.jpa.dto.PostDTO)1 FlatFileItemWriter (org.springframework.batch.item.file.FlatFileItemWriter)1 BeanWrapperFieldExtractor (org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor)1 DelimitedLineAggregator (org.springframework.batch.item.file.transform.DelimitedLineAggregator)1 Bean (org.springframework.context.annotation.Bean)1 FileSystemResource (org.springframework.core.io.FileSystemResource)1