当前位置: 首页>>代码示例>>Java>>正文


Java BeanWrapperFieldSetMapper类代码示例

本文整理汇总了Java中org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper的典型用法代码示例。如果您正苦于以下问题:Java BeanWrapperFieldSetMapper类的具体用法?Java BeanWrapperFieldSetMapper怎么用?Java BeanWrapperFieldSetMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BeanWrapperFieldSetMapper类属于org.springframework.batch.item.file.mapping包,在下文中一共展示了BeanWrapperFieldSetMapper类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createReader

import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; //导入依赖的package包/类
public ItemStreamReader<Ticket> createReader(final Resource source) {

        final FlatFileItemReader<Ticket> reader = new FlatFileItemReader<>();
        reader.setResource(source);
        final DefaultLineMapper<Ticket> lineMapper = new DefaultLineMapper<>();
        final DelimitedLineTokenizer lineTokenizer = new DelimitedLineTokenizer();
        lineTokenizer.setNames(TICKET_FILE_CSV_FIELDS);
        lineMapper.setLineTokenizer(lineTokenizer);
        final BeanWrapperFieldSetMapper<Ticket> fieldMapper = new BeanWrapperFieldSetMapper<>();
        fieldMapper.setTargetType(Ticket.class);
        final DateFormat df = new SimpleDateFormat(DATE_FORMAT);
        final Map<Class, PropertyEditor> customEditors = Stream.of(
                new AbstractMap.SimpleEntry<>(Date.class, new CustomDateEditor(df, false)))
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        fieldMapper.setCustomEditors(customEditors);
        lineMapper.setFieldSetMapper(fieldMapper);
        reader.setLineMapper(lineMapper);
        return reader;
    }
 
开发者ID:create1st,项目名称:spring-batch,代码行数:20,代码来源:TicketReaderFactory.java

示例2: orderReader

import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; //导入依赖的package包/类
@Bean
@StepScope
protected OrderImportItemReader orderReader(@Value("#{jobParameters['resource']}") final Resource orderCsvResource) {

    FlatFileItemReader flatFileItemReader = new FlatFileItemReader<>();
    flatFileItemReader.setLineMapper(new DefaultLineMapper<OrderCsvLineValue>() {{
        setLineTokenizer(new DelimitedLineTokenizer() {{
            setNames(ORDER_CSV_HEADER_NAMES);

        }});
        setFieldSetMapper(new BeanWrapperFieldSetMapper<OrderCsvLineValue>() {{
            setTargetType(OrderCsvLineValue.class);
        }});
    }});
    flatFileItemReader.setLinesToSkip(1);
    flatFileItemReader.setResource(orderCsvResource);

    SingleItemPeekableItemReader singleItemPeekableItemReader = new SingleItemPeekableItemReader();
    singleItemPeekableItemReader.setDelegate(flatFileItemReader);

    OrderImportItemReader reader = new OrderImportItemReader();
    reader.setDelegate(singleItemPeekableItemReader);

    return reader;
}
 
开发者ID:commercetools,项目名称:commercetools-sunrise-data,代码行数:26,代码来源:OrdersImportJobConfiguration.java

示例3: flatFileItemReader

import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; //导入依赖的package包/类
@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;
}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:22,代码来源:BatchConfiguration.java

示例4: reader

import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; //导入依赖的package包/类
/**
 * maps CSV data into rows of fields, which are then
 * mapped to Customer.class instances based on conventions:
 * <p/>
 * <CODE>col 1 => firstName => customer.setFirstName(String)</CODE>
 */
@Bean(name = readCsvFileIntoTableStepReader)
@StepScope
public FlatFileItemReader<Customer> reader(@Value("#{jobParameters['input.file']}") Resource resource) throws Exception {

    log.debug(String.format("building FlatFileItemReader to read in the file %s", resource.getFile().getAbsolutePath()));

    FlatFileItemReader<Customer> csvFileReader = new FlatFileItemReader<Customer>();
    csvFileReader.setResource(resource);

    DelimitedLineTokenizer delimitedLineTokenizer = new DelimitedLineTokenizer(DelimitedLineTokenizer.DELIMITER_COMMA);
    delimitedLineTokenizer.setNames(new String[]{"lastName", "firstName"});

    BeanWrapperFieldSetMapper<Customer> beanWrapperFieldSetMapper = new BeanWrapperFieldSetMapper<Customer>();
    beanWrapperFieldSetMapper.setTargetType(Customer.class);

    DefaultLineMapper<Customer> defaultLineMapper = new DefaultLineMapper<Customer>();
    defaultLineMapper.setLineTokenizer(delimitedLineTokenizer);
    defaultLineMapper.setFieldSetMapper(beanWrapperFieldSetMapper);

    csvFileReader.setLineMapper(defaultLineMapper);
    return csvFileReader;
}
 
开发者ID:joshlong,项目名称:javaconfig-ftw,代码行数:29,代码来源:BatchConfiguration.java

示例5: mobilePhoneProductFieldSetMapper

import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; //导入依赖的package包/类
@Bean
public FieldSetMapper<Product> mobilePhoneProductFieldSetMapper() throws Exception {
	BeanWrapperFieldSetMapper<Product> mapper =
			new BeanWrapperFieldSetMapper<Product>();

	mapper.setPrototypeBeanName("mobilePhoneProduct");
	mapper.afterPropertiesSet();
	return mapper;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:10,代码来源:JobStructureDelimitedMultiFlatFileConfig.java

示例6: productFieldSetMapper

import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; //导入依赖的package包/类
@Bean
public FieldSetMapper<Product> productFieldSetMapper() {
	BeanWrapperFieldSetMapper<Product> mapper = new BeanWrapperFieldSetMapper<Product>();
	mapper.setTargetType(Product.class);
	return mapper;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:7,代码来源:FlatFileReaderConfiguration.java

示例7: bookProductFieldSetMapper

import org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper; //导入依赖的package包/类
@Bean
public FieldSetMapper<Product> bookProductFieldSetMapper() throws Exception {
	BeanWrapperFieldSetMapper<Product> mapper =
			new BeanWrapperFieldSetMapper<Product>();

	mapper.setPrototypeBeanName("bookProduct");
	mapper.afterPropertiesSet();
	return mapper;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:10,代码来源:JobStructureDelimitedMultiFlatFileConfig.java


注:本文中的org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。