Example #1
0
 public CmsTask update(CmsTask bean, Map<String, String> attr) {
   Updater<CmsTask> updater = new Updater<CmsTask>(bean);
   updater.include("intervalUnit");
   updater.include("cronExpression");
   updater.include("dayOfMonth");
   updater.include("dayOfWeek");
   updater.include("hour");
   updater.include("minute");
   updater.include("repeatCount");
   updater.include("intervalHour");
   updater.include("intervalMinute");
   bean = dao.updateByUpdater(updater);
   // 更新属性表
   if (attr != null) {
     Map<String, String> attrOrig = bean.getAttr();
     attrOrig.clear();
     attrOrig.putAll(attr);
   }
   return bean;
 }
Example #2
0
 public String getCronExpressionFromDB(Integer taskId) {
   CmsTask task = findById(taskId);
   if (task.getExecycle().equals(CmsTask.EXECYCLE_CRON)) {
     return task.getCronExpression();
   } else {
     Integer execycle = task.getIntervalUnit();
     String excep = "";
     if (execycle.equals(CmsTask.EXECYCLE_MONTH)) {
       excep =
           "0  " + task.getMinute() + " " + task.getHour() + " " + task.getDayOfMonth() + " * ?";
     } else if (execycle.equals(CmsTask.EXECYCLE_WEEK)) {
       excep =
           "0  "
               + task.getMinute()
               + " "
               + task.getHour()
               + " "
               + " ? "
               + " * "
               + task.getDayOfWeek();
     } else if (execycle.equals(CmsTask.EXECYCLE_DAY)) {
       excep = "0  " + task.getMinute() + " " + task.getHour() + " " + " * * ?";
     } else if (execycle.equals(CmsTask.EXECYCLE_HOUR)) {
       excep = "0 0 */" + task.getIntervalHour() + " * * ?";
     } else if (execycle.equals(CmsTask.EXECYCLE_MINUTE)) {
       excep = "0  */" + task.getIntervalMinute() + " * * * ?";
     }
     return excep;
   }
 }