List of usage examples for org.springframework.batch.core StepExecution getExecutionContext
public ExecutionContext getExecutionContext()
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:org.obiba.onyx.core.etl.participant.impl.ParticipantProcessor.java
public ExitStatus afterStep(StepExecution stepExecution) { for (AppointmentUpdateLog appointmentUpdateLog : log) { AppointmentUpdateLog.addErrorLog(stepExecution.getExecutionContext(), appointmentUpdateLog); }/*from w w w .j a v a 2 s . c o m*/ return null; }
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 {/*from w w w . ja va2 s.c o m*/ mailSender.send(message); } catch (MailException e) { log.error("Impossible to send e-mail", e); } return stepExecution.getExitStatus(); }
From source file:org.springframework.batch.admin.web.StepExecutionController.java
@RequestMapping(value = "/jobs/executions/{jobExecutionId}/steps/{stepExecutionId}/execution-context", method = RequestMethod.GET) public String getStepExecutionContext(Model model, @PathVariable Long jobExecutionId, @PathVariable Long stepExecutionId, @ModelAttribute("date") Date date, Errors errors) { try {//from ww w.j a va 2s . co m StepExecution stepExecution = jobService.getStepExecution(jobExecutionId, stepExecutionId); Map<String, Object> executionMap = new HashMap<String, Object>(); for (Map.Entry<String, Object> entry : stepExecution.getExecutionContext().entrySet()) { executionMap.put(entry.getKey(), entry.getValue()); } model.addAttribute("stepExecutionContext", objectMapper.writeValueAsString(executionMap)); model.addAttribute("stepExecutionId", stepExecutionId); model.addAttribute("stepName", stepExecution.getStepName()); model.addAttribute("jobExecutionId", jobExecutionId); } catch (NoSuchJobExecutionException e) { errors.reject("no.such.job.execution", new Object[] { jobExecutionId }, "There is no such job execution (" + jobExecutionId + ")"); } catch (NoSuchStepExecutionException e) { errors.reject("no.such.step.execution", new Object[] { stepExecutionId }, "There is no such step execution (" + stepExecutionId + ")"); } catch (IOException e) { errors.reject("serialization.error", new Object[] { jobExecutionId }, "Error serializing execution context for step execution (" + stepExecutionId + ")"); } return "jobs/executions/step/execution-context"; }
From source file:de.langmi.spring.batch.examples.complex.file.split.GetLineCountTaskletTest.java
@Test public void testExecute() throws Exception { // setup/* w w w .ja va 2 s . com*/ tasklet = new GetLineCountTasklet(); tasklet.setResource(new FileSystemResource(INPUT)); StepExecution stepExecution = MetaDataInstanceFactory.createStepExecution(); // execute RepeatStatus status = tasklet.execute(new StepContribution(stepExecution), new ChunkContext(new StepContext(stepExecution))); // assertions assertEquals(RepeatStatus.FINISHED, status); assertEquals(EXPECTED_COUNT, stepExecution.getExecutionContext().get("line.count")); }
From source file:uk.ac.ebi.intact.editor.controller.dbmanager.ImportJobController.java
public List<Map.Entry<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())); }//from www.j a v a 2s. c o m } } return new ArrayList<Map.Entry<String, String>>(statistics.entrySet()); }
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 a2 s .c o m*/ * @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.seedstack.monitoring.batch.internal.rest.stepexecution.StepExecutionDetailsRepresentation.java
/** * Constructor that substitutes in null for the execution id. * * @param stepExecution the step execution *///from w w w. j av a2 s .c o m public StepExecutionDetailsRepresentation(StepExecution stepExecution) { Assert.notNull(stepExecution.getId(), "The entity Id must be provided to re-hydrate an existing StepExecution"); this.stepName = stepExecution.getStepName(); this.commitCount = stepExecution.getCommitCount(); this.endTime = stepExecution.getEndTime() == null ? "" : timeFormat.format(stepExecution.getEndTime()); this.executionContext = stepExecution.getExecutionContext(); this.statusExitCode = stepExecution.getExitStatus() != null ? stepExecution.getExitStatus().getExitCode() : ""; this.statusExitDescription = stepExecution.getExitStatus() != null ? stepExecution.getExitStatus().getExitDescription() : ""; this.failureExceptions = stepExecution.getFailureExceptions(); this.filterCount = stepExecution.getFilterCount(); this.lastUpdated = stepExecution.getLastUpdated() == null ? "" : dateFormat.format(stepExecution.getLastUpdated()); this.processSkipCount = stepExecution.getProcessSkipCount(); this.readCount = stepExecution.getReadCount(); this.readSkipCount = stepExecution.getReadSkipCount(); this.rollbackCount = stepExecution.getRollbackCount(); this.startTime = timeFormat.format(stepExecution.getStartTime()); this.status = stepExecution.getStatus(); this.stepName = stepExecution.getStepName(); this.terminateOnly = stepExecution.isTerminateOnly(); this.writeCount = stepExecution.getWriteCount(); this.writeSkipCount = stepExecution.getWriteSkipCount(); }
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"); }/*from ww w.j a va 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()); }