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

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

Introduction

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

Prototype

public ExecutionContext getExecutionContext() 

Source Link

Document

Returns the ExecutionContext for this execution

Usage

From source file:org.jasig.ssp.util.importer.job.csv.RawItemCsvWriter.java

@Override
public ExitStatus afterStep(StepExecution stepExecution) {
    logger.info("End Raw Write Step for " + stepExecution.getExecutionContext().getString("fileName")
            + " lines read: " + stepExecution.getReadCount() + " lines skipped: "
            + stepExecution.getReadSkipCount());
    logger.info(stepExecution.getSummary());
    return ExitStatus.COMPLETED;
}

From source file:org.jasig.ssp.util.importer.job.csv.RawItemCsvWriter.java

@Override
public void beforeStep(StepExecution stepExecution) {
    logger.info("Start Raw Write Step for file " + stepExecution.getExecutionContext().getString("fileName"));
}

From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsVersionsWriterTest.java

public StepExecution getStepExecution() {

    final StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution();
    stepExecution.getExecutionContext().putInt("mantis.loop.project_id", 1);

    return stepExecution;
}

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

private void set(String metricName, double value) {
    StepExecution stepExecution = getStepExecution();
    stepExecution.getExecutionContext().put(metricName, value);
}

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

private void remove(String metricName) {
    StepExecution stepExecution = getStepExecution();
    if (stepExecution.getExecutionContext().containsKey(metricName)) {
        stepExecution.getExecutionContext().remove(metricName);
    }//  w  w w .  ja va2  s .  c  o  m
}

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

@Override
public void updateExecutionContext(StepExecution stepExecution) {
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    if (executionContext != null) {
        contexts.put(ContextKey.step(stepExecution.getId()), copy(executionContext));
    }/*from   w ww. j av a2  s . co  m*/
}

From source file:org.springframework.cloud.dataflow.server.support.StepExecutionJacksonMixInTests.java

private StepExecution getStepExecution() {
    JobExecution jobExecution = new JobExecution(1L, null, "hi");
    final StepExecution stepExecution = new StepExecution("step1", jobExecution);
    jobExecution.createStepExecution("step1");
    final ExecutionContext executionContext = stepExecution.getExecutionContext();

    executionContext.putInt("counter", 1234);
    executionContext.putDouble("myDouble", 1.123456d);
    executionContext.putLong("Josh", 4444444444L);
    executionContext.putString("awesomeString", "Yep");
    executionContext.put("hello", "world");
    executionContext.put("counter2", 9999);

    return stepExecution;
}

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

synchronized private void modifyCounter(String metricName, Long value) {
    StepExecution stepExecution = getStepExecution();
    Long oldValue = 0L;/*  www . ja va 2s  . c  o m*/
    if (stepExecution.getExecutionContext().containsKey(metricName)) {
        oldValue = stepExecution.getExecutionContext().getLong(metricName);
    }
    stepExecution.getExecutionContext().put(metricName, oldValue + value);
}

From source file:org.obiba.onyx.core.service.impl.DefaultAppointmentManagementServiceImpl.java

public List<AppointmentUpdateLog> getLogListForDate(Date date) {
    List<AppointmentUpdateLog> logList = new ArrayList<AppointmentUpdateLog>();
    List<JobInstance> jobsList = jobExplorer.getJobInstances(job.getName(), 0, 10);

    JobExecution jobExecution = null;/*from w w  w.j a va 2s.  c o m*/

    for (JobInstance jobInstance : jobsList) {
        if (jobInstance.getJobParameters().getDate("date").toString().equals(date.toString())) {
            jobExecution = jobExplorer.getJobExecutions(jobInstance).get(0);
            break;
        }
    }

    if (jobExecution == null)
        return null;

    for (StepExecution stepExec : jobExecution.getStepExecutions()) {
        StepExecution stepExecution = jobExplorer.getStepExecution(jobExecution.getId(), stepExec.getId());
        if (stepExecution.getExecutionContext().get("logList") != null) {
            logList.addAll((List<AppointmentUpdateLog>) (stepExecution.getExecutionContext().get("logList")));
        }
    }

    return logList;
}

From source file:uk.ac.ebi.intact.editor.controller.admin.AdminJobController.java

public Map<String, String> getImportStatistics(JobExecution jobExecution) {
    Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions();
    Map<String, String> statistics = new HashMap<String, String>();
    if (!stepExecutions.isEmpty()) {
        StepExecution firstStep = stepExecutions.iterator().next();
        ExecutionContext stepContext = firstStep.getExecutionContext();

        for (Map.Entry<String, Object> entry : stepContext.entrySet()) {
            // persisted count
            if (entry.getKey().startsWith(AbstractIntactDbImporter.PERSIST_MAP_COUNT)) {
                statistics.put(entry.getKey().substring(entry.getKey().lastIndexOf("_") + 1),
                        Integer.toString((Integer) entry.getValue()));
            }//  w  w w.ja va  2 s . com
        }
    }
    return statistics;
}