List of usage examples for org.springframework.batch.core JobExecution getExecutionContext
public ExecutionContext getExecutionContext()
From source file:org.jasig.ssp.util.importer.job.twodottwo.ReportExistsTest.java
@Test public void testJob() throws Exception { JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Assert.assertNotNull(jobExecution.getExecutionContext().get("report")); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.decider.ProjectFlowDecider.java
/** * {@inheritDoc}//from www . j a v a2s.c om * * @see org.springframework.batch.core.job.flow.JobExecutionDecider#decide(org.springframework.batch.core.JobExecution, org.springframework.batch.core.StepExecution) */ @Override public FlowExecutionStatus decide(final JobExecution jobExecution, final StepExecution stepExecution) { final Set<BigInteger> projectsId = (Set<BigInteger>) jobExecution.getExecutionContext() .get("mantis.loop.projects_to_process"); if (projectsId != null && !projectsId.isEmpty()) { return new FlowExecutionStatus("LOOP"); } else { return new FlowExecutionStatus("END_LOOP"); } }
From source file:org.jasig.ssp.util.importer.job.twodottwo.HeaderOnlyTest.java
@SuppressWarnings("unchecked") @Test/*from w w w .ja v a2 s .co m*/ public void testJob() throws Exception { JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext() .get("report"); Assert.assertNotNull(report); Set<Entry<String, ReportEntry>> entrySet = report.entrySet(); Assert.assertEquals(1, entrySet.size()); for (Entry<String, ReportEntry> entry : entrySet) { Assert.assertEquals(new Integer(0), entry.getValue().getNumberParsed()); Assert.assertEquals(new Integer(0), entry.getValue().getNumberSkippedOnParse()); Assert.assertEquals(new Integer(0), entry.getValue().getNumberSkippedOnDatabaseWrite()); Assert.assertEquals(new Integer(0), entry.getValue().getNumberInsertedUpdated()); } }
From source file:br.com.postalis.folhapgto.steps.consultarIncorporados.ConsultarRubIncorporadasParamDecider.java
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { LOGGER.info("Verificando se existem valores para processar..."); qtdRegProc = (Integer) jobExecution.getExecutionContext().get("qtdRegProc"); if (qtdRegProc == 0) { LOGGER.info("No h valores para processar!!!"); return FlowExecutionStatus.COMPLETED; } else {//from w w w .ja v a2 s .c om LOGGER.info("Encontrou " + qtdRegProc + " registros para processar. Continuando o processamento..."); return new FlowExecutionStatus("CONTINUAR"); } }
From source file:org.jasig.ssp.util.importer.job.twodottwo.ReportAccuracyTest.java
@SuppressWarnings("unchecked") @Test/*from ww w. j a va2s . com*/ public void testJob() throws Exception { JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext() .get("report"); Assert.assertNotNull(report); Set<Entry<String, ReportEntry>> entrySet = report.entrySet(); Assert.assertEquals(3, entrySet.size()); for (Entry<String, ReportEntry> entry : entrySet) { Assert.assertEquals(new Integer(2), entry.getValue().getNumberInsertedUpdated()); } }
From source file:br.com.postalis.folhapgto.steps.listaPosFolha.ConsultarListaDescPosFolhaDecider.java
public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { qtdErro = (Integer) jobExecution.getExecutionContext().get("qtdErro"); listaControle = (List<String>) jobExecution.getExecutionContext().get("listaControle"); if (!listaControle.isEmpty()) { LOGGER.info("Apagando os registros processados com sucesso..."); int count = 0; List<String> listaAux = new ArrayList<String>(); for (String controle : listaControle) { count++;//from w w w . ja v a 2 s. c o m listaAux.add(controle); if (count == 2000) { controleProcessamentoRepository.deleteMatriculasIn(listaAux); listaAux = new ArrayList<String>(); count = 0; } } controleProcessamentoRepository.deleteMatriculasIn(listaAux); listaControle = new ArrayList<String>(); listaAux = null; LOGGER.info("Registros de processamento apagados com sucesso!!!"); } LOGGER.info("Verificando se ainda existem registros a processar..."); long qtdFaltam = controleProcessamentoRepository.countByProcessado(0); if (qtdFaltam > 0) { loop++; if (loop <= 3) { LOGGER.warn( "Encontrou " + qtdFaltam + " registros a processar, voltando para procesar o que falta!!!"); return new FlowExecutionStatus("LOOP"); } else { LOGGER.warn("ATENO!!!ATENO!!!ATENO!!!"); LOGGER.warn("AINDA FALTAM: " + qtdFaltam + " LANAMENTOS PARA SEREM PROCESSADOS. "); LOGGER.warn("O SISTEMA RE-EXECUTA AUTOMTICAMENTE APENAS 3 VEZES. "); LOGGER.warn( "CASO QUEIRA ENVIAR OS LANAMENTOS PENDENTES, EXECUTE NOVAMENTE O SISTEMA MANUALMENTE!!! "); return FlowExecutionStatus.COMPLETED; } } else { if (qtdErro > 0) { LOGGER.warn("ATENO!!!ATENO!!!ATENO!!!"); LOGGER.warn("ALGUMAS RUBRICAS FORAM CRITICADAS PELA ECT. FAVOR, VERIFICAR NA BASE!!! "); } return FlowExecutionStatus.COMPLETED; } }
From source file:org.jasig.ssp.util.importer.job.twodottwo.RawItemHeaderFailTest.java
@SuppressWarnings("unchecked") @Test//from www .j av a2s . c o m public void testJob() throws Exception { JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext() .get("report"); Assert.assertNotNull(report); Set<Entry<String, ReportEntry>> entrySet = report.entrySet(); Assert.assertEquals(1, entrySet.size()); for (Entry<String, ReportEntry> entry : entrySet) { Assert.assertEquals(new Integer(0), entry.getValue().getNumberInsertedUpdated()); //TODO this should eventually be 1 see SSP-1919 Assert.assertEquals(new Integer(3), entry.getValue().getNumberParsed()); Assert.assertEquals(new Integer(3), entry.getValue().getNumberSkippedOnParse()); } List<ErrorEntry> errors = (List<ErrorEntry>) jobExecution.getExecutionContext().get("errors"); Assert.assertEquals(3, errors.size()); for (ErrorEntry error : errors) { Assert.assertEquals(new Integer(-1), new Integer(Integer.parseInt(error.getLineNumber()))); } }
From source file:org.jasig.ssp.util.importer.job.twodottwo.ErrorReportingTest.java
@SuppressWarnings("unchecked") @Test// ww w .j a va 2s . co m public void testJob() throws Exception { JobExecution jobExecution = jobLauncherTestUtils.launchJob(); Map<String, ReportEntry> report = (Map<String, ReportEntry>) jobExecution.getExecutionContext() .get("report"); Assert.assertNotNull(report); Set<Entry<String, ReportEntry>> entrySet = report.entrySet(); Assert.assertEquals(1, entrySet.size()); for (Entry<String, ReportEntry> entry : entrySet) { Assert.assertEquals(new Integer(0), entry.getValue().getNumberParsed()); Assert.assertEquals(new Integer(0), entry.getValue().getNumberSkippedOnParse()); Assert.assertEquals(new Integer(2), entry.getValue().getNumberSkippedOnDatabaseWrite()); Assert.assertEquals(new Integer(0), entry.getValue().getNumberInsertedUpdated()); } List<ErrorEntry> errors = (List<ErrorEntry>) jobExecution.getExecutionContext().get("errors"); Assert.assertEquals(2, errors.size()); }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.ProjectsUserWriterTest.java
public StepExecution getStepExecution() { final Map<String, JobParameter> map = new HashMap<String, JobParameter>(); final JobParameters jobParams = new JobParameters(map); final JobExecution exec = MetaDataInstanceFactory.createJobExecution("testJob", 1L, 1L, jobParams); exec.getExecutionContext().put("mantis.loop.project_id", BigInteger.ONE); final StepExecution stepExecution = exec.createStepExecution("testStep"); return stepExecution; }
From source file:org.trpr.platform.batch.impl.spring.admin.repository.MapExecutionContextDao.java
@Override public void updateExecutionContext(JobExecution jobExecution) { ExecutionContext executionContext = jobExecution.getExecutionContext(); if (executionContext != null) { contexts.put(ContextKey.job(jobExecution.getId()), copy(executionContext)); }// w w w . j a va 2 s .c o m }