Example usage for org.springframework.batch.core ExitStatus getExitCode

List of usage examples for org.springframework.batch.core ExitStatus getExitCode

Introduction

In this page you can find the example usage for org.springframework.batch.core ExitStatus getExitCode.

Prototype

public String getExitCode() 

Source Link

Document

Getter for the exit code (defaults to blank).

Usage

From source file:com.spring.batch.BatchMain.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("spring-batch.xml");
    JobParametersBuilder jobPara = new JobParametersBuilder(); // 

    Job job = (Job) ctx.getBean("sampleFlow");
    JobLauncher launcher = (JobLauncher) ctx.getBean("jobLauncher");

    JobExecution result = null;//from w ww  .  jav a 2  s.  c  o m

    try {
        result = launcher.run(job, jobPara.toJobParameters());
    } catch (JobExecutionAlreadyRunningException e) {
        e.printStackTrace();
    } catch (JobRestartException e) {
        e.printStackTrace();
    } catch (JobInstanceAlreadyCompleteException e) {
        e.printStackTrace();
    } catch (JobParametersInvalidException e) {
        e.printStackTrace();
    }

    ExitStatus es = result.getExitStatus();
    if (es.getExitCode().equals(ExitStatus.COMPLETED.getExitCode())) {
        System.out.println("finished");
    } else {
        System.out.println("failed");
    }
}

From source file:de.codecentric.batch.FlatFileJobIntegrationTest.java

@Test
public void testLaunchJob() throws Exception {
    // Given//  w  ww  . ja v  a 2s  .com
    String jobParameters = "pathToFile=classpath:partner-import.csv";
    // When
    ExitStatus exitStatus = runJobAndWaitForCompletion("localhost", "8090", "flatfileJob", jobParameters);
    // Then
    assertEquals(ExitStatus.COMPLETED.getExitCode(), exitStatus.getExitCode());
}

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

/**
 * Called after the step of the AppointmentUpdateList job. Persists the job resuming data.
 * @param stepExecution/* w w  w .  jav  a  2 s.  c  om*/
 * @return
 */
@AfterStep
public ExitStatus afterUpdateCompleted(StepExecution stepExecution) {
    ExitStatus status = stepExecution.getExitStatus();

    if (status.getExitCode().equals("COMPLETED")) {
        AppointmentUpdateStats appointmentUpdateStats = new AppointmentUpdateStats(
                stepExecution.getJobParameters().getDate("date"), getAddedParticipants(),
                getUpdatedParticipants(), getIgnoredParticipants(), getUnreadableParticipants());
        appointmentUpdateStats.setFileName(stepExecution.getExecutionContext().get("fileName").toString());
        appointmentManagementService.saveAppointmentUpdateStats(appointmentUpdateStats);
    }

    AppointmentUpdateLog.addErrorLog(stepExecution.getExecutionContext(),
            new AppointmentUpdateLog(new Date(), AppointmentUpdateLog.Level.INFO, "End updating appointments"));

    return status;
}

From source file:org.emonocot.job.common.GetResourceClientTest.java

/**
 *
 * @throws IOException/*from  w  w w.  jav a 2 s.c o  m*/
 *             if a temporary file cannot be created or if there is a http
 *             protocol error.
 */
@Test
public final void testGetResourceNotModified() throws IOException {
    File tempFile = File.createTempFile("test", "zip");
    tempFile.deleteOnExit();
    httpResponse.setStatusLine(
            new BasicStatusLine(HttpVersion.HTTP_1_0, HttpStatus.SC_NOT_MODIFIED, "Not Modified"));

    EasyMock.expect(httpClient.getParams()).andReturn(new BasicHttpParams());
    EasyMock.expect(httpClient.execute(EasyMock.isA(HttpGet.class))).andReturn(httpResponse);
    EasyMock.replay(httpClient);

    ExitStatus exitStatus = getResourceClient.getResource(testzip, Long.toString(new Date().getTime()),
            tempFile.getAbsolutePath());

    EasyMock.verify(httpClient);

    assertNotNull("ExitStatus should not be null", exitStatus);
    assertEquals("ExitStatus should be NOT_MODIFIED", exitStatus.getExitCode(), "NOT_MODIFIED");
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void btnExportarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExportarActionPerformed
    carregarParametros();//w  ww  .j a  v a  2  s.  c  o  m
    int confirmacao = JOptionPane.showConfirmDialog(null,
            "Exportar folha de pagamento para a referncia: " + txtMesAno + "?",
            "Exportao da folha de pagamento", JOptionPane.OK_CANCEL_OPTION);
    if (confirmacao == JOptionPane.OK_OPTION) {
        new Thread() {
            public void run() {
                try {
                    txtStatusProc.setText("Executando exportao para a referncia: " + txtMesAno + "...");
                    btnExportar.setEnabled(false);
                    ExitStatus retorno = new SvcFolhaPgtoImpl().exportarFolhaPgto(usuario, anoMesRef, dtRef);
                    if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) {
                        txtStatusProc
                                .setText("No exitem lanamentos a exportar na referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) {
                        txtStatusProc.setText(
                                "Exportao concluida com sucesso para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else {
                        throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode());
                    }
                } catch (Exception ex) {
                    String msg = "Erro ao executar a exportao da folha para a referncia: " + txtMesAno
                            + ": ";
                    LOGGER.error(msg + ex.getMessage());
                    txtStatusProc.setText(msg);
                } finally {
                    preencherTabela();
                    btnExportar.setEnabled(true);
                }

            }
        }.start();
    }
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void btnImportarLogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportarLogActionPerformed
    carregarParametros();/*  www .  ja v  a 2 s. co m*/
    int confirmacao = JOptionPane.showConfirmDialog(null,
            "Importar Log de processamento ECT para a referncia: " + txtMesAno + "?",
            "Importao do log de processamento", JOptionPane.OK_CANCEL_OPTION);
    if (confirmacao == JOptionPane.OK_OPTION) {
        new Thread() {
            public void run() {
                try {
                    txtStatusProc
                            .setText("Executando importao do log de processamento ECT para a referncia: "
                                    + txtMesAno + "...");
                    btnImportarLog.setEnabled(false);
                    ExitStatus retorno = new SvcFolhaPgtoImpl().consultarLogImportacao(usuario, anoMesRef,
                            dtRef);
                    if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) {
                        txtStatusProc
                                .setText("No exitem lanamentos a importar na referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) {
                        txtStatusProc.setText(
                                "Importao concluida com sucesso para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else {
                        throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode());
                    }
                } catch (Exception ex) {
                    String msg = "Erro ao executar a importao do log de processamento para a referncia: "
                            + txtMesAno + ":";
                    LOGGER.error(msg + ex.getMessage());
                    txtStatusProc.setText(msg);
                } finally {
                    btnImportarLog.setEnabled(true);
                }

            }
        }.start();
    }
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void btnPosFolhaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPosFolhaActionPerformed
    carregarParametros();//  w  w w.  ja  va  2 s .c  om
    int confirmacao = JOptionPane.showConfirmDialog(null,
            "Deseja importar os descontos efetuados ps folha para a referncia: " + txtMesAno + "?",
            "Importao ps folha", JOptionPane.OK_CANCEL_OPTION);
    if (confirmacao == JOptionPane.OK_OPTION) {
        new Thread() {
            public void run() {
                try {
                    txtStatusProc
                            .setText("Executando importao ps folha para a referncia: " + txtMesAno + "...");
                    btnPosFolha.setEnabled(false);
                    ExitStatus retorno = new SvcFolhaPgtoImpl().consultarDescPosFolha(usuario, anoMesRef,
                            dtRef);
                    if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) {
                        txtStatusProc.setText(
                                "A importao ps folha no disponvel para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) {
                        txtStatusProc.setText(
                                "Importao concluida com sucesso para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else {
                        throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode());
                    }
                } catch (Exception ex) {
                    String msg = "Erro ao executar a importao ps folha para a referncia: " + txtMesAno
                            + ": ";
                    LOGGER.error(msg + ex.getMessage());
                    txtStatusProc.setText(msg);
                } finally {
                    btnPosFolha.setEnabled(true);
                }
            }
        }.start();
    }
}

From source file:br.com.postalis.folhapgto.proc.TelaPrincipal.java

private void btnImportarIncorporadasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportarIncorporadasActionPerformed
    carregarParametros();/*from   w w  w .  java  2 s . co  m*/
    int confirmacao = JOptionPane.showConfirmDialog(null,
            "Importar rubricas incorporadas na ECT para a referncia: " + txtMesAno + "?",
            "Importao de incorporadas", JOptionPane.OK_CANCEL_OPTION);
    if (confirmacao == JOptionPane.OK_OPTION) {
        new Thread() {
            public void run() {
                try {
                    txtStatusProc
                            .setText("Executando importao de rubricas incorporadas na ECT para a referncia: "
                                    + txtMesAno + "...");
                    btnImportarIncorporadas.setEnabled(false);
                    ExitStatus retorno = new SvcFolhaPgtoImpl().consultarRubricasIncorporadas(usuario,
                            anoMesRef, dtRef);
                    if (retorno.equals(EnumExistStatus.VAZIO.getStatus())) {
                        txtStatusProc
                                .setText("No exitem lanamentos a importar na referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else if (retorno.equals(EnumExistStatus.SUCESSO.getStatus())) {
                        txtStatusProc.setText(
                                "Importao concluida com sucesso para a referncia: " + txtMesAno + ".");
                        Thread.sleep(10000);
                        txtStatusProc.setText("");
                    } else {
                        throw new Exception("O tipo de resultado no esperado: " + retorno.getExitCode());
                    }
                } catch (Exception ex) {
                    String msg = "Erro ao executar a importao das rubricas incorporadas para a referncia: "
                            + txtMesAno + ": ";
                    LOGGER.error(msg + ex.getMessage());
                    txtStatusProc.setText(msg);
                } finally {
                    btnImportarIncorporadas.setEnabled(true);
                    preencherTabela();
                }

            }
        }.start();
    }
}