Example usage for org.springframework.batch.repeat RepeatStatus FINISHED

List of usage examples for org.springframework.batch.repeat RepeatStatus FINISHED

Introduction

In this page you can find the example usage for org.springframework.batch.repeat RepeatStatus FINISHED.

Prototype

RepeatStatus FINISHED

To view the source code for org.springframework.batch.repeat RepeatStatus FINISHED.

Click Source Link

Document

Indicates that processing is finished (either successful or unsuccessful)

Usage

From source file:com.dst.batch.SampleBatchApplication.java

@Bean
protected Tasklet tasklet() {
    return new Tasklet() {
        @Override//from w  w  w .j a v  a  2  s.  c om
        public RepeatStatus execute(StepContribution contribution, ChunkContext context) {

            return RepeatStatus.FINISHED;
        }
    };
}

From source file:bamons.process.batch.support.SampleTasklet.java

/**
 *
 *  ? /* ww w . j a  v a 2  s .  c om*/
 *
 * @param contribution StepContribution ?
 * @param chunkContext ChunkContext ?
 * @return RepeatStatus ?
 * @throws Exception
 */
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    int count = sampleDAO.getTotalCount(targetDate);
    logger.error("Total Count : {}", count);
    return RepeatStatus.FINISHED;
}

From source file:io.spring.configuration.JobConfiguration.java

@Bean
public Job job1() {
    return jobBuilderFactory.get("job1").start(stepBuilderFactory.get("job1step1").tasklet(new Tasklet() {
        @Override/*from w ww.  j a  v a 2s .c  o m*/
        public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
            logger.info("Job1 was run");
            return RepeatStatus.FINISHED;
        }
    }).build()).build();
}

From source file:de.langmi.spring.batch.examples.complex.file.split.GetLineCountTaskletTest.java

@Test
public void testExecute() throws Exception {
    // setup//  ww w .ja  va 2 s . co m
    tasklet = new GetLineCountTasklet();
    tasklet.setResource(new FileSystemResource(INPUT));
    StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution();

    // execute
    RepeatStatus status = tasklet.execute(new StepContribution(stepExecution),
            new ChunkContext(new StepContext(stepExecution)));
    // assertions
    assertEquals(RepeatStatus.FINISHED, status);
    assertEquals(EXPECTED_COUNT, stepExecution.getExecutionContext().get("line.count"));
}

From source file:de.langmi.spring.batch.examples.complex.crosscutting.interstepcommunication.databean.ReadingDataBeanTasklet.java

/** {@inheritDoc} */
@Override//from w  w  w. ja va 2 s.co m
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    // pull variable from data bean
    String value = (String) dataMap.get("value");

    // check for the value
    if (StringUtils.trimToNull(value) != null) {
        LOG.debug("Read value from databean:" + value);
    } else {
        throw new Exception("Did not found value in data bean");
    }

    // exit the step
    return RepeatStatus.FINISHED;
}

From source file:org.motechproject.telco.couchdb.jobs.ViewIndexer.java

@Override
public RepeatStatus execute(StepContribution arg0, ChunkContext arg1) throws Exception {
    CouchDBViewIndexer couchDBViewIndexer = new CouchDBViewIndexer();
    couchDBViewIndexer.indexAllViews(masterCouchDbHost);
    couchDBViewIndexer.indexAllViews(slaveCouchDbHost);
    return RepeatStatus.FINISHED;
}

From source file:de.langmi.spring.batch.examples.complex.crosscutting.interstepcommunication.jobcontext.ReadingJobExecutionContextTasklet.java

/** {@inheritDoc} */
@Override/*  w  ww.java2 s  . com*/
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    // pull variable from JobExecutionContext, accesses a unmodifiable map
    String value = (String) chunkContext.getStepContext().getJobExecutionContext().get("value");

    // check for the value
    if (StringUtils.trimToNull(value) != null) {
        LOG.debug("Found value in JobExecutionContext:" + value);
    } else {
        throw new Exception("Did not found value in JobExecutionContext");
    }

    // exit the step
    return RepeatStatus.FINISHED;
}

From source file:org.motechproject.batch.jobs.indexing.ViewIndexer.java

@Override
public RepeatStatus execute(StepContribution arg0, ChunkContext arg1) throws Exception {
    CouchDBViewIndexer couchDBViewIndexer = new CouchDBViewIndexer();
    if (StringUtils.isNotBlank(masterCouchDbHost))
        couchDBViewIndexer.indexAllViews(masterCouchDbHost);
    if (StringUtils.isNotBlank(slaveCouchDbHost))
        couchDBViewIndexer.indexAllViews(slaveCouchDbHost);
    return RepeatStatus.FINISHED;
}

From source file:org.obiba.onyx.core.etl.participant.impl.DeleteUnreceivedParticipantsTasklet.java

public RepeatStatus execute(StepContribution stepContribution, ChunkContext context) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("e:DeleteUnreceivedParticipantsTasklet.execute() ");
    }//from  ww  w . j  a va  2s . co  m

    try {
        if (isUpdateAvailable()) {
            log.debug("About to invoke cleanUpAppointment()");
            participantService.cleanUpAppointment();
            log.debug("About to set exit status: UPDATE");
            stepContribution.setExitStatus(new ExitStatus("UPDATE"));
        } else {
            log.debug("About to set exit status: NO UPDATE");
            stepContribution.setExitStatus(new ExitStatus("NO UPDATE"));
        }
        log.debug("About to return repeat status: FINISHED");
        return RepeatStatus.FINISHED;

    } finally {

        if (log.isDebugEnabled()) {
            log.debug("x:DeleteUnreceivedParticipantsTasklet.execute() ");
        }

    }
}

From source file:com.javaetmoi.core.batch.tasklet.DeleteElasticIndexTasklet.java

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) {
    try {/*from   w  w w  .ja v a 2 s  . com*/
        DeleteIndexResponse response = esClient.admin().indices().prepareDelete(indexName).execute()
                .actionGet();

        if (!response.isAcknowledged()) {
            throw new RuntimeException("Index deletion has not been acknowledged");
        }
        LOG.info("Index {} deleted", indexName);
    } catch (IndexMissingException e) {
        LOG.info("The index {} does not exist. Thus nothing to delete.", indexName);
    }
    return RepeatStatus.FINISHED;
}