org.springframework.batch.item.support.CompositeItemProcessor Java Examples

The following examples show how to use org.springframework.batch.item.support.CompositeItemProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobConfiguration.java    From CogStack-Pipeline with Apache License 2.0 7 votes vote down vote up
@Bean
@Qualifier("compositeItemProcessorr")
public ItemProcessor<Document,Document> compositeItemProcessor() {
    CompositeItemProcessor processor = new CompositeItemProcessor<>();
    ArrayList<ItemProcessor<Document,Document>> delegates = new ArrayList<>();

    if(tikaItemProcessor !=null) delegates.add(tikaItemProcessor);
    if(pdfBoxItemProcessor !=null) delegates.add(pdfBoxItemProcessor);
    if(metadataItemProcessor !=null) delegates.add(metadataItemProcessor);
    if(dBLineFixerItemProcessor !=null) delegates.add(dBLineFixerItemProcessor);
    if(gateItemProcessor !=null) delegates.add(gateItemProcessor);
    if(deIdDocumentItemProcessor !=null) delegates.add(deIdDocumentItemProcessor);
    if(webserviceDocumentItemProcessor !=null) delegates.add(webserviceDocumentItemProcessor);
    if(pdfGenerationItemProcessor !=null) delegates.add(pdfGenerationItemProcessor);
    if(thumbnailGenerationItemProcessor !=null) delegates.add(thumbnailGenerationItemProcessor);


    delegates.add(jsonMakerItemProcessor);
    processor.setDelegates(delegates);
    return processor;
}
 
Example #2
Source File: AbstractEmployeeJobConfig.java    From batchers with Apache License 2.0 7 votes vote down vote up
protected Step wsCallAndGenerateAndSendPaycheckStep(String stepName) {
    CompositeItemProcessor<TaxCalculation, PayCheck> compositeItemProcessor = new CompositeItemProcessor<>();
    compositeItemProcessor.setDelegates(Arrays.asList(
            callWebserviceProcessor,
            sendPaycheckProcessor
    ));

    return stepBuilders.get(stepName)
            .<TaxCalculation, PayCheck>chunk(5)
            .faultTolerant()
            .skipPolicy(maxConsecutiveExceptionsSkipPolicy)
            .noRollback(TaxWebServiceNonFatalException.class)
            .noRollback(EmailSenderException.class)
            .reader(wsCallItemReader)
            .processor(compositeItemProcessor)
            .writer(wsCallItemWriter)
            .listener(createMonthlyTaxForEmployeeListener)
            .listener(maxConsecutiveExceptionsSkipPolicy)
            .listener(failedStepStepExecutionListener)
            .listener(singleJVMJobProgressListener)
            .allowStartIfComplete(true)
            .taskExecutor(taskExecutor)
            .build();
}
 
Example #3
Source File: PersonJobConfig.java    From spring-batch-rest with Apache License 2.0 5 votes vote down vote up
@Bean @StepScope
ItemProcessor personProcessor(
        @Qualifier("personNameCaseChange") ItemProcessor personNameCaseChange,
        @Value("#{jobParameters['" + LAST_NAME_PREFIX + "']}") String lastNamePrefix) {
    CompositeItemProcessor p = new CompositeItemProcessor();
    p.setDelegates(newArrayList(
            personNameFilter(Optional.ofNullable(lastNamePrefix).orElseGet(() -> environment.getProperty(LAST_NAME_PREFIX))),
            personNameCaseChange));
    return p;
}
 
Example #4
Source File: PersonJobConfig.java    From spring-batch-rest with Apache License 2.0 5 votes vote down vote up
@Bean @StepScope
ItemProcessor personProcessor(
        @Qualifier("personNameCaseChange") ItemProcessor personNameCaseChange,
        @Value("#{jobParameters['" + LAST_NAME_PREFIX + "']}") String lastNamePrefix) {
    CompositeItemProcessor p = new CompositeItemProcessor();
    p.setDelegates(newArrayList(
            personNameFilter(Optional.ofNullable(lastNamePrefix).orElseGet(() -> environment.getProperty(LAST_NAME_PREFIX))),
            personNameCaseChange));
    return p;
}
 
Example #5
Source File: CompositeItemProcessorDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private CompositeItemProcessor<TestData, TestData> compositeItemProcessor() {
    CompositeItemProcessor<TestData, TestData> processor = new CompositeItemProcessor<>();
    List<ItemProcessor<TestData, TestData>> processors = Arrays.asList(testDataFilterItemProcessor, testDataTransformItemPorcessor);
    // 代理两个processor
    processor.setDelegates(processors);
    return processor;
}