Example usage for org.springframework.batch.core StepExecution getJobExecution

List of usage examples for org.springframework.batch.core StepExecution getJobExecution

Introduction

In this page you can find the example usage for org.springframework.batch.core StepExecution getJobExecution.

Prototype

public JobExecution getJobExecution() 

Source Link

Document

Accessor for the execution context information of the enclosing job.

Usage

From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapStepExecutionDao.java

/**
 * Returns a copy of {@link StepExecution}, by adding new Objects for every field(no references are passed)
 * // ww w  . j av a2  s  .c  om
 * @param original StepExecution to be copied
 * @return StepExecution copy
 */
private static StepExecution copy(StepExecution original) {
    StepExecution copy = new StepExecution(original.getStepName(), original.getJobExecution());
    copy.setCommitCount(original.getCommitCount());
    if (original.getEndTime() != null) {
        copy.setEndTime((Date) original.getEndTime().clone());
    }
    //Warning: no deep copy
    if (original.getExitStatus() != null) {
        copy.setExitStatus(new ExitStatus(original.getExitStatus().getExitCode(),
                original.getExitStatus().getExitDescription()));
    }
    copy.setFilterCount(original.getFilterCount());
    copy.setId(original.getId());
    if (original.getLastUpdated() != null) {
        copy.setLastUpdated((Date) original.getLastUpdated().clone());
    }
    copy.setProcessSkipCount(original.getProcessSkipCount());
    copy.setReadCount(original.getReadCount());
    copy.setReadSkipCount(original.getReadSkipCount());
    copy.setRollbackCount(original.getRollbackCount());
    if (original.getStartTime() != null) {
        copy.setStartTime((Date) original.getStartTime().clone());
    }
    if (original.getStatus() != null) {
        copy.setStatus(BatchStatus.valueOf(original.getStatus().name()));
    }
    if (original.isTerminateOnly()) {
        copy.setTerminateOnly();
    }
    copy.setVersion(original.getVersion());
    copy.setWriteCount(original.getWriteCount());
    copy.setWriteSkipCount(original.getWriteSkipCount());
    return copy;
}

From source file:com.github.ffremont.MyStepExecutionListener.java

@Override
public void beforeStep(StepExecution stepExecution) {
    LOG.info("Before Step, number of steps {}", stepExecution.getJobExecution().getStepExecutions().size());
}

From source file:com.github.ffremont.MyStepExecutionListener.java

@Override
public ExitStatus afterStep(StepExecution stepExecution) {
    LOG.info("After Step, number of steps {}", stepExecution.getJobExecution().getStepExecutions().size());

    return stepExecution.getExitStatus();
}

From source file:de.codecentric.batch.listener.LoggingListener.java

@Override
public void beforeStep(StepExecution stepExecution) {
    insertValuesIntoMDC(stepExecution.getJobExecution());
}

From source file:lcn.module.batch.web.guide.support.ErrorLogTasklet.java

/**
 * Step ? ? ?,  stepName ? JobExecution? Context?  
 *//*from   ww w  . j a v  a2s  . co m*/
public void beforeStep(StepExecution stepExecution) {
    this.jobName = stepExecution.getJobExecution().getJobInstance().getJobName().trim();
    this.stepName = (String) stepExecution.getJobExecution().getExecutionContext().get("stepName");
    this.stepExecution = stepExecution;
    stepExecution.getJobExecution().getExecutionContext().remove("stepName");
}

From source file:org.cbio.portal.pipelines.foundation.FoundationStepListener.java

@Override
public void beforeStep(StepExecution stepExecution) {
    // add Foundation case list to step execution context
    ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext();
    Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap");
    stepExecution.getExecutionContext().put("fmiCaseList", new ArrayList(fmiCaseTypeMap.values()));
}

From source file:org.cbio.portal.pipelines.foundation.CnaStepListener.java

@Override
public void beforeStep(StepExecution stepExecution) {
    // add map of case id to case data to execution context
    ExecutionContext executionContext = stepExecution.getJobExecution().getExecutionContext();
    Map<String, CaseType> fmiCaseTypeMap = (Map<String, CaseType>) executionContext.get("fmiCaseTypeMap");
    stepExecution.getExecutionContext().put("fmiCaseTypeMap", fmiCaseTypeMap);
}

From source file:de.codecentric.batch.metrics.MetricsListener.java

private String getStepExecutionIdentifier(StepExecution stepExecution) {
    return stepExecution.getJobExecution().getJobInstance().getJobName() + "." + stepExecution.getStepName();
}

From source file:uk.ac.ebi.intact.editor.batch.admin.MailNotifierStepExecutionListener.java

public void beforeStep(StepExecution stepExecution) {

    SimpleMailMessage message = newSimpleMessage();
    message.setSubject("[Editor_import] Started step: " + stepExecution.getStepName() + "");
    message.setText(stepExecution.getSummary() + "\n" + stepExecution.getJobExecution());
    message.setTo(stepExecution.getJobParameters().getString("email.recipient"));

    try {//from  w w  w  .  j  a v  a 2 s. c  o  m
        mailSender.send(message);
    } catch (MailException e) {
        log.error("Impossible to send e-mail", e);
    }
}

From source file:org.seedstack.monitoring.batch.internal.rest.stepexecution.StepExecutionResource.java

/**
 * Retrieves the history by job execution id and step execution id.
 *
 * @param jobExecutionId  the job execution id
 * @param stepExecutionId the step execution id
 * @return the response//from w w  w. ja v a 2s. c o m
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{stepExecutionId}/progress")
@RequiresPermissions("seed:monitoring:batch:read")
public Response history(@PathParam("jobExecutionId") long jobExecutionId,
        @PathParam("stepExecutionId") long stepExecutionId) {

    StepExecutionProgressPresentation stepExecutionProgress;
    try {
        StepExecution stepExecution = jobService.getStepExecution(jobExecutionId, stepExecutionId);

        String stepName = stepExecution.getStepName();
        if (stepName.contains(":partition")) {
            // assume we want to compare all partitions
            stepName = stepName.replaceAll("(:partition).*", "$1*");
        }
        String jobName = stepExecution.getJobExecution().getJobInstance().getJobName();
        StepExecutionHistory stepExecutionHistory = computeHistory(jobName, stepName);
        stepExecutionProgress = new StepExecutionProgressPresentation(stepExecution, stepExecutionHistory);
    } catch (NoSuchStepExecutionException e) {
        return Response.status(Response.Status.BAD_REQUEST)
                .entity("There is no such step execution (" + stepExecutionId + ")").type(MediaType.TEXT_PLAIN)
                .build();
    } catch (NoSuchJobExecutionException e) {
        return Response.status(Response.Status.BAD_REQUEST)
                .entity("There is no such job execution (" + jobExecutionId + ")").type(MediaType.TEXT_PLAIN)
                .build();
    }

    return Response.ok(stepExecutionProgress).build();

}