예제 #1
0
  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);
    }
  }
예제 #2
0
 @Override
 public JobDescriptor createJob(
     String user, String jobName, String parentGroup, JobRunType jobType) throws ZeusException {
   GroupDescriptor parent = getGroupDescriptor(parentGroup);
   if (parent.isDirectory()) {
     throw new ZeusException("目录组下不得创建Job");
   }
   JobDescriptor job = new JobDescriptor();
   job.setOwner(user);
   job.setName(jobName);
   job.setGroupId(parentGroup);
   job.setJobType(jobType);
   job.setPreProcessers(Arrays.asList((Processer) new DownloadProcesser()));
   JobPersistence persist = PersistenceAndBeanConvert.convert(job);
   persist.setGmtCreate(new Date());
   persist.setGmtModified(new Date());
   getHibernateTemplate().save(persist);
   return PersistenceAndBeanConvert.convert(persist).getX();
 }
예제 #3
0
  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);
    }
  }