@Override public List<JobExecution> getJobExecutions(JobInstance jobInstance) throws NoSuchJobInstanceException, JobSecurityException { if(jobInstance == null) { throw new NoSuchJobInstanceException("A null JobInstance was provided"); } org.springframework.batch.core.JobInstance instance = (org.springframework.batch.core.JobInstance) jobInstance; List<org.springframework.batch.core.JobExecution> batchExecutions = jobExplorer.getJobExecutions(instance); if(batchExecutions == null || batchExecutions.size() == 0) { throw new NoSuchJobInstanceException("Unable to find JobInstance " + jobInstance.getInstanceId()); } List<JobExecution> results = new ArrayList<>(batchExecutions.size()); for (org.springframework.batch.core.JobExecution jobExecution : batchExecutions) { results.add(new JsrJobExecution(jobExecution, jobParametersConverter)); } return results; }
@Override public JobInstanceEntity getJobInstance(long jobInstanceId) throws NoSuchJobInstanceException { final JobInstanceEntity jobInstance = data.jobInstanceData.get(jobInstanceId); if (jobInstance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } return jobInstance; }
@Override public Void call() { final JobInstanceEntity instance; instance = em.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } entityMgr.remove(instance); return null; } }.runInNewOrExistingGlobalTran();
@Override public JobInstance call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } instance.setRestartOn(restartOn); return instance; } }.runInNewOrExistingGlobalTran();
@Override public JobInstanceEntityV3 call() { JobInstanceEntityV3 instance = entityMgr.find(JobInstanceEntityV3.class, jobInstanceID); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceID); } instance.setGroupNames(groupNames); entityMgr.merge(instance); return instance; } }.runInNewOrExistingGlobalTran();
@Override public JobInstance call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } instance.setRestartOn(null); return instance; } }.runInNewOrExistingGlobalTran();
@Override public JobInstance call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } instance.setJobName(jobName); instance.setJobXml(jobXml); return instance; } }.runInNewOrExistingGlobalTran();
@Override public List<JobExecution> getJobExecutions(JobInstance jobInstance) throws NoSuchJobInstanceException, JobSecurityException { if(jobInstance == null) { throw new NoSuchJobInstanceException("A null JobInstance was provided"); } org.springframework.batch.core.JobInstance instance = (org.springframework.batch.core.JobInstance) jobInstance; List<org.springframework.batch.core.JobExecution> batchExecutions = jobExplorer.getJobExecutions(instance); if(batchExecutions == null || batchExecutions.size() == 0) { throw new NoSuchJobInstanceException("Unable to find JobInstance " + jobInstance.getInstanceId()); } List<JobExecution> results = new ArrayList<JobExecution>(batchExecutions.size()); for (org.springframework.batch.core.JobExecution jobExecution : batchExecutions) { results.add(new JsrJobExecution(jobExecution, jobParametersConverter)); } return results; }
@Override public List<JobExecution> getJobExecutions(JobInstance jobInstance) throws NoSuchJobInstanceException, JobSecurityException { if(jobInstance == null) { throw new NoSuchJobInstanceException("A null JobInstance was provided"); } org.springframework.batch.core.JobInstance instance = (org.springframework.batch.core.JobInstance) jobInstance; List<org.springframework.batch.core.JobExecution> batchExecutions = jobExplorer.getJobExecutions(instance); if(batchExecutions == null || batchExecutions.size() == 0) { throw new NoSuchJobInstanceException("Unable to find JobInstance " + jobInstance.getInstanceId()); } List<JobExecution> results = new ArrayList<JobExecution>(batchExecutions.size()); for (org.springframework.batch.core.JobExecution jobExecution : batchExecutions) { results.add(new JsrJobExecution(jobExecution, jobParametersConverter)); } return results; }
@Override public List<JobExecution> getJobExecutions(JobInstance jobInstance) throws NoSuchJobInstanceException, JobSecurityException { if(jobInstance == null) { throw new NoSuchJobInstanceException("A null JobInstance was provided"); } org.springframework.batch.core.JobInstance instance = (org.springframework.batch.core.JobInstance) jobInstance; List<org.springframework.batch.core.JobExecution> batchExecutions = jobExplorer.getJobExecutions(instance); if(batchExecutions == null || batchExecutions.size() == 0) { throw new NoSuchJobInstanceException("Unable to find JobInstance " + jobInstance.getInstanceId()); } List<JobExecution> results = new ArrayList<JobExecution>(batchExecutions.size()); for (org.springframework.batch.core.JobExecution jobExecution : batchExecutions) { results.add(new JsrJobExecution(jobExecution, jobParametersConverter)); } return results; }
@Override public List<JobExecution> getJobExecutions(final JobInstance instance) throws NoSuchJobInstanceException, JobSecurityException { // Mediate between one final List<JobExecution> executions = new ArrayList<JobExecution>(); List<InternalJobExecution> executionImpls = persistenceManagerService.jobOperatorGetJobExecutions(instance.getInstanceId()); if (executionImpls.size() == 0) { throw new NoSuchJobInstanceException("Job: " + instance.getJobName() + " does not exist"); } for (InternalJobExecution e : executionImpls) { executions.add(e); } return executions; }
@Override public final NoSuchJobInstanceException noSuchJobInstance(final String jobInstanceValue) { final NoSuchJobInstanceException result = new NoSuchJobInstanceException(String.format(getLoggingLocale(), noSuchJobInstance$str(), jobInstanceValue)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String unrestartableJob = "JBERET000646: Failed to restart the job with name: %s, execution id: %s, because the job is configured not restartable";
@Override public JobInstance updateJobInstanceWithRestartOn(final long jobInstanceId, final String restartOn) { EntityManager em = getPsu().createEntityManager(); try { return new TranRequest<JobInstance>(em) { @Override public JobInstance call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } instance.setRestartOn(restartOn); return instance; } }.runInNewOrExistingGlobalTran(); } finally { em.close(); } }
@Override public JobInstanceEntity updateJobInstanceWithGroupNames(final long jobInstanceID, final Set<String> groupNames) { EntityManager em = getPsu().createEntityManager(); try { return new TranRequest<JobInstanceEntityV3>(em) { @Override public JobInstanceEntityV3 call() { JobInstanceEntityV3 instance = entityMgr.find(JobInstanceEntityV3.class, jobInstanceID); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceID); } instance.setGroupNames(groupNames); entityMgr.merge(instance); return instance; } }.runInNewOrExistingGlobalTran(); } finally { em.close(); } }
@Override public JobInstanceEntity getJobInstance(final long jobInstanceId) throws NoSuchJobInstanceException { final EntityManager em = getPsu().createEntityManager(); try { JobInstanceEntity instance = new TranRequest<JobInstanceEntity>(em) { @Override public JobInstanceEntity call() { return em.find(JobInstanceEntity.class, jobInstanceId); } }.runInNewOrExistingGlobalTran(); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } return instance; } finally { em.close(); } }
@Override public JobInstance updateJobInstanceNullOutRestartOn(final long jobInstanceId) { EntityManager em = getPsu().createEntityManager(); try { return new TranRequest<JobInstance>(em) { @Override public JobInstance call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } instance.setRestartOn(null); return instance; } }.runInNewOrExistingGlobalTran(); } finally { em.close(); } }
@Override public JobInstance updateJobInstanceWithJobNameAndJSL(final long jobInstanceId, final String jobName, final String jobXml) { EntityManager em = getPsu().createEntityManager(); try { return new TranRequest<JobInstance>(em) { @Override public JobInstance call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } instance.setJobName(jobName); instance.setJobXml(jobXml); return instance; } }.runInNewOrExistingGlobalTran(); } finally { em.close(); } }
@Override public boolean purgeJobInstanceAndRelatedData(final long jobInstanceId) { final EntityManager em = getPsu().createEntityManager(); try { new TranRequest<Void>(em) { @Override public Void call() { final JobInstanceEntity instance; instance = em.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } entityMgr.remove(instance); return null; } }.runInNewOrExistingGlobalTran(); return true; } finally { em.close(); } }
@Override public JobInstanceEntity call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } try { verifyStateTransitionIsValid(instance, state); } catch (BatchIllegalJobStatusTransitionException e) { throw new PersistenceException(e); } instance.setInstanceState(state); instance.setLastUpdatedTime(lastUpdated); return instance; } }.runInNewOrExistingGlobalTran();
@Override public JobInstance call() { JobInstanceEntity instance = entityMgr.find(JobInstanceEntity.class, jobInstanceId); if (instance == null) { throw new NoSuchJobInstanceException("No job instance found for id = " + jobInstanceId); } //Thinking a state check will be enough in this case. try { verifyStateTransitionIsValid(instance, state); } catch (BatchIllegalJobStatusTransitionException e) { throw new PersistenceException(e); } instance.setInstanceState(state); instance.setBatchStatus(batchStatus); instance.setLastUpdatedTime(lastUpdated); return instance; } }.runInNewOrExistingGlobalTran();