public void updateJob(String user, JobDescriptor job, String owner, String groupId) throws ZeusException { JobPersistence orgPersist = (JobPersistence) getHibernateTemplate().get(JobPersistence.class, Long.valueOf(job.getId())); if (job.getScheduleType() == JobScheduleType.Independent) { job.setDependencies(new ArrayList<String>()); } else if (job.getScheduleType() == JobScheduleType.Dependent) { job.setCronExpression(""); } job.setOwner(owner); job.setGroupId(groupId); // 以下属性不允许修改,强制采用老的数据 JobPersistence persist = PersistenceAndBeanConvert.convert(job); persist.setGmtCreate(orgPersist.getGmtCreate()); persist.setGmtModified(new Date()); persist.setRunType(orgPersist.getRunType()); persist.setStatus(orgPersist.getStatus()); persist.setReadyDependency(orgPersist.getReadyDependency()); persist.setHost(job.getHost()); // 如果是用户从界面上更新,开始时间、统计周期等均为空,用原来的值 if (job.getStartTime() == null || "".equals(job.getStartTime())) { persist.setStartTime(orgPersist.getStartTime()); } if (job.getStartTimestamp() == 0) { persist.setStartTimestamp(orgPersist.getStartTimestamp()); } if (job.getStatisStartTime() == null || "".equals(job.getStatisStartTime())) { persist.setStatisStartTime(orgPersist.getStatisStartTime()); } if (job.getStatisEndTime() == null || "".equals(job.getStatisEndTime())) { persist.setStatisEndTime(orgPersist.getStatisEndTime()); } // 如果是周期任务,则许检查依赖周期是否正确 if (job.getScheduleType().equals(JobScheduleType.CyleJob) && job.getDependencies() != null && job.getDependencies().size() != 0) { List<JobDescriptor> list = this.getJobDescriptors(job.getDependencies()); jobValidate.checkCycleJob(job, list); } if (jobValidate.valide(job)) { getHibernateTemplate().update(persist); } }
public void updateJob(String user, JobDescriptor job, String owner, String groupId) throws ZeusException { JobPersistence orgPersist = (JobPersistence) getHibernateTemplate().get(JobPersistence.class, Long.valueOf(job.getId())); if (job.getScheduleType() == JobScheduleType.Independent) { job.setDependencies(new ArrayList<String>()); } else if (job.getScheduleType() == JobScheduleType.Dependent) { job.setCronExpression(""); } job.setOwner(owner); job.setGroupId(groupId); // 以下属性不允许修改,强制采用老的数据 JobPersistence persist = PersistenceAndBeanConvert.convert(job); persist.setGmtCreate(orgPersist.getGmtCreate()); persist.setGmtModified(new Date()); persist.setRunType(orgPersist.getRunType()); persist.setStatus(orgPersist.getStatus()); persist.setReadyDependency(orgPersist.getReadyDependency()); if (jobValidate.valide(job)) { getHibernateTemplate().update(persist); } }
@Override public Tuple<JobDescriptor, JobStatus> getJobDescriptor(String jobId) { JobPersistence persist = getJobPersistence(jobId); if (persist == null) { return null; } Tuple<JobDescriptor, JobStatus> t = PersistenceAndBeanConvert.convert(persist); JobDescriptor jd = t.getX(); // 如果是周期任务,并且依赖不为空,则需要封装周期任务的依赖 if (jd.getScheduleType() == JobScheduleType.CyleJob && jd.getDependencies() != null) { JobPersistence jp = null; for (String jobID : jd.getDependencies()) { if (StringUtils.isNotEmpty(jobID)) { jp = getJobPersistence(jobID); if (jp != null) { jd.getDepdCycleJob().put(jobID, jp.getCycle()); } } } } return t; }