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

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

Introduction

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

Prototype

public String getStepName() 

Source Link

Usage

From source file:mpg.biochem.de.interbase.batch.OutputFileListener.java

@BeforeStep
public void createOutputNameFromInput(StepExecution stepExecution) {
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    String inputName = stepExecution.getStepName().replace(":", "-");
    if (executionContext.containsKey(inputKeyName)) {
        inputName = executionContext.getString(inputKeyName);
    }//from   w w  w  .j av a  2s  .c  o  m
    if (!executionContext.containsKey(outputKeyName)) {
        executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".mapped.tab");
    }
}

From source file:com.cat.ic.listener.impl.OutputFileListenerMVNO.java

@BeforeStep
public void createOutputNameFromInput(StepExecution stepExecution) {
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    String inputName = stepExecution.getStepName().replace(":", "-");

    if (executionContext.containsKey(inputKeyName)) {
        inputName = executionContext.getString(inputKeyName);
    }//from  w ww.  ja  v  a2 s.  c  o m
    if (!executionContext.containsKey(outputKeyName)) {
        executionContext.putString(outputKeyName, path + FilenameUtils.getName(inputName) + ".mvno");
    }
    log.info("[" + executionContext.getString(outputKeyName) + "]");
}

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

/**
 * skipCount  Execution ? /*  ww  w . j  a  va2s. co m*/
 */
private int getSkipCount() {
    if (stepExecution == null || stepName == null) {
        return 0;
    }
    for (StepExecution execution : stepExecution.getJobExecution().getStepExecutions()) {
        if (execution.getStepName().equals(stepName)) {
            return execution.getSkipCount();
        }
    }
    return 0;
}

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

private String getStepIdentifier() {
    StepContext stepContext = StepSynchronizationManager.getContext();
    StepExecution stepExecution = StepSynchronizationManager.getContext().getStepExecution();
    return stepContext.getJobName() + "." + stepExecution.getStepName();
}

From source file:egovframework.rte.bat.core.listener.EgovOutputFileListener.java

/**
 * stepExecutionContext? inputKeyName ? ? outputKeyName? put 
 * //from   ww w.  j a v  a  2  s. c om
 * @param stepExecution
 */
@BeforeStep
public void createOutputNameFromInput(StepExecution stepExecution) {
    ExecutionContext executionContext = stepExecution.getExecutionContext();
    String inputName = stepExecution.getStepName().replace(":", "-");
    if (executionContext.containsKey(inputKeyName)) {
        inputName = executionContext.getString(inputKeyName);
    }
    if (!executionContext.containsKey(outputKeyName)) {
        executionContext.putString(outputKeyName, path + FilenameUtils.getBaseName(inputName) + ".csv");
    }
}

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 {/* w  w w .  j  a v a2 s  .  c o  m*/
        mailSender.send(message);
    } catch (MailException e) {
        log.error("Impossible to send e-mail", e);
    }
}

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

public ExitStatus afterStep(StepExecution stepExecution) {

    SimpleMailMessage message = newSimpleMessage();
    message.setSubject("[Editor_import] Finished step: " + stepExecution.getStepName() + " Exit status: "
            + stepExecution.getExitStatus().getExitCode());
    message.setText(stepExecution.toString() + "\n" + stepExecution.getExecutionContext());
    message.setText(stepExecution.toString() + "\n" + stepExecution.getSummary() + "\n"
            + stepExecution.getJobExecution());
    message.setTo(stepExecution.getJobParameters().getString("email.recipient"));

    try {//  ww  w  .j  ava 2s .co m
        mailSender.send(message);
    } catch (MailException e) {
        log.error("Impossible to send e-mail", e);
    }

    return stepExecution.getExitStatus();
}

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

public void afterJob(JobExecution jobExecution) {
    StringBuilder protocol = new StringBuilder();
    protocol.append("\n");
    protocol.append(createFilledLine('*'));
    protocol.append(createFilledLine('-'));
    protocol.append("Protocol for " + jobExecution.getJobInstance().getJobName() + " \n");
    protocol.append("  Started:      " + jobExecution.getStartTime() + "\n");
    protocol.append("  Finished:     " + jobExecution.getEndTime() + "\n");
    protocol.append("  Exit-Code:    " + jobExecution.getExitStatus().getExitCode() + "\n");
    protocol.append("  Exit-Descr:   " + jobExecution.getExitStatus().getExitDescription() + "\n");
    protocol.append("  Status:       " + jobExecution.getStatus() + "\n");
    protocol.append("  Content of Job-ExecutionContext:\n");
    for (Entry<String, Object> entry : jobExecution.getExecutionContext().entrySet()) {
        protocol.append("  " + entry.getKey() + "=" + entry.getValue() + "\n");
    }/* www.j  a v a  2 s  .c  o m*/
    protocol.append("  Job-Parameter: \n");
    JobParameters jp = jobExecution.getJobParameters();
    for (Iterator<Entry<String, JobParameter>> iter = jp.getParameters().entrySet().iterator(); iter
            .hasNext();) {
        Entry<String, JobParameter> entry = iter.next();
        protocol.append("  " + entry.getKey() + "=" + entry.getValue() + "\n");
    }
    protocol.append(createFilledLine('-'));
    for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
        protocol.append("Step " + stepExecution.getStepName() + " \n");
        protocol.append("  ReadCount:    " + stepExecution.getReadCount() + "\n");
        protocol.append("  WriteCount:   " + stepExecution.getWriteCount() + "\n");
        protocol.append("  Commits:      " + stepExecution.getCommitCount() + "\n");
        protocol.append("  SkipCount:    " + stepExecution.getSkipCount() + "\n");
        protocol.append("  Rollbacks:    " + stepExecution.getRollbackCount() + "\n");
        protocol.append("  Filter:       " + stepExecution.getFilterCount() + "\n");
        protocol.append("  Content of Step-ExecutionContext:\n");
        for (Entry<String, Object> entry : stepExecution.getExecutionContext().entrySet()) {
            protocol.append("  " + entry.getKey() + "=" + entry.getValue() + "\n");
        }
        protocol.append(createFilledLine('-'));
    }
    protocol.append(createFilledLine('*'));
    LOGGER.info(protocol.toString());
}

From source file:com.javaetmoi.core.batch.listener.LogStepListener.java

@Override
public ExitStatus afterStep(StepExecution pStepExecution) {
    if (LOG.isInfoEnabled()) {
        StringBuilder msg = new StringBuilder();
        msg.append("Step ").append(pStepExecution.getStepName());
        msg.append(" - Read count: ").append(pStepExecution.getReadCount());
        msg.append(" - Write count: ").append(pStepExecution.getWriteCount());
        msg.append(" - Commit count: ").append(pStepExecution.getCommitCount());
        LOG.info(msg.toString());/*from   ww w . j a v  a 2s .  co  m*/
    }
    return super.afterStep(pStepExecution);
}

From source file:com.example.listener.CustomJobExecutionListener.java

public void afterJob(org.springframework.batch.core.JobExecution jobExecution) {
    StringBuilder protocol = new StringBuilder();
    protocol.append("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
    protocol.append("Protocol for " + jobExecution.getJobInstance().getJobName() + " \n");
    protocol.append("  Started     : " + jobExecution.getStartTime() + "\n");
    protocol.append("  Finished    : " + jobExecution.getEndTime() + "\n");
    protocol.append("  Exit-Code   : " + jobExecution.getExitStatus().getExitCode() + "\n");
    protocol.append("  Exit-Descr. : " + jobExecution.getExitStatus().getExitDescription() + "\n");
    protocol.append("  Status      : " + jobExecution.getStatus() + "\n");
    protocol.append("+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");

    protocol.append("Job-Parameter: \n");
    JobParameters jp = jobExecution.getJobParameters();
    for (Iterator<Map.Entry<String, JobParameter>> iter = jp.getParameters().entrySet().iterator(); iter
            .hasNext();) {//from w  ww .  j  a  v  a  2s  .c o m
        Map.Entry<String, JobParameter> entry = iter.next();
        protocol.append("  " + entry.getKey() + "=" + entry.getValue() + "\n");
    }
    protocol.append("+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");

    for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
        protocol.append("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
        protocol.append("Step " + stepExecution.getStepName() + " \n");
        protocol.append("ReadCount " + stepExecution.getReadCount() + " \n");
        protocol.append("WriteCount: " + stepExecution.getWriteCount() + "\n");
        protocol.append("Commits: " + stepExecution.getCommitCount() + "\n");
        protocol.append("SkipCount: " + stepExecution.getSkipCount() + "\n");
        protocol.append("Rollbacks: " + stepExecution.getRollbackCount() + "\n");
        protocol.append("Filter: " + stepExecution.getFilterCount() + "\n");
        protocol.append("+++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n");
    }
    log.info("{}", protocol.toString());
}