public Date getJobsPreviousRunTime(String jobName) { JobExplorer explorer = getBatchJobExplorer(); List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 1); if (jobInstances.size() == 0) { return new Date(0); } JobInstance jobInstance = jobInstances.get(0); long executionTimeInMillis = jobInstance.getJobParameters().getLong(MifosBatchJob.JOB_EXECUTION_TIME_KEY); return new Date(executionTimeInMillis); }
public JobParameters getLastJobParameters(String jobName) throws NoSuchJobException { Collection<JobInstance> lastInstances = listJobInstances(jobName, 0, 1); JobInstance lastInstance = null; if (!lastInstances.isEmpty()) { lastInstance = lastInstances.iterator().next(); } JobParameters oldParameters = new JobParameters(); if (lastInstance != null) { oldParameters = lastInstance.getJobParameters(); } return oldParameters; }
public JobExecution restart(Long jobExecutionId) throws NoSuchJobExecutionException, JobExecutionAlreadyRunningException, JobRestartException, JobInstanceAlreadyCompleteException, NoSuchJobException, JobParametersInvalidException { JobExecution target = getJobExecution(jobExecutionId); JobInstance lastInstance = target.getJobInstance(); Job job = jobLocator.getJob(lastInstance.getJobName()); JobExecution jobExecution = jobLauncher.run(job, lastInstance.getJobParameters()); if (jobExecution.isRunning()) { activeExecutions.add(jobExecution); } return jobExecution; }
public Date getJobsLastSuccessfulRunTime(String jobName) { JobExplorer explorer = getBatchJobExplorer(); List<JobInstance> jobInstances = explorer.getJobInstances(jobName, 0, 100); for (JobInstance job : jobInstances) { for (JobExecution execution : explorer.getJobExecutions(job)) { if (BatchStatus.COMPLETED.equals(execution.getStatus())) { long executionTimeInMillis = job.getJobParameters().getLong(MifosBatchJob.JOB_EXECUTION_TIME_KEY); return new Date(executionTimeInMillis); } } } return new Date(0); }