/**
  * 插入规则
  *
  * @see
  *     com.yunat.workflow.development.service.DevelopmentService#insertRule(com.yunat.workflow.development.domain.RuleDomain)
  * @author: 邱路平 - [email protected]
  * @date: Created on Jul 10, 2013 5:46:02 PM
  */
 @Transactional
 public void insertRule(RuleDomain ruleDomain) {
   Rule rp = new Rule();
   rp.setRid(UUID.randomUUID().toString().replace("-", ""));
   rp.setOriginal_value(ruleDomain.getOriginal_value());
   rp.setNew_value(ruleDomain.getNew_value());
   rp.setRule_type(ruleDomain.getRule_type());
   rp.setTask_id(ruleDomain.getTask_id());
   ruleDAO.insertRule(rp);
 }
 /**
  * 查询规则
  *
  * @see
  *     com.yunat.workflow.development.service.DevelopmentService#queryRuleByTaskId(java.lang.String)
  * @author: 邱路平 - [email protected]
  * @date: Created on Jul 10, 2013 5:46:02 PM
  */
 @Transactional
 public List<RuleDomain> queryRuleByTaskId(String task_id) {
   List<Rule> attachmentPojo = ruleDAO.queryRuleList(task_id);
   List<RuleDomain> ruleDomain = new ArrayList<RuleDomain>();
   for (Rule rp : attachmentPojo) {
     RuleDomain rd = new RuleDomain();
     rd.setRid(rp.getRid());
     rd.setTask_id(rp.getTask_id());
     rd.setOriginal_value(rp.getOriginal_value());
     rd.setNew_value(rp.getNew_value());
     rd.setRule_type(rp.getRule_type());
     ruleDomain.add(rd);
   }
   return ruleDomain;
 }
 /**
  * 规则应用
  *
  * @see com.yunat.workflow.development.service.DevelopmentService#ruleApply(java.lang.String,
  *     java.lang.String)
  * @author: 邱路平 - [email protected]
  * @date: Created on Jul 11, 2013 10:16:53 AM
  */
 @Override
 public String ruleApply(String task_id, String script) {
   List<Rule> attachmentPojo = ruleDAO.queryRuleList(task_id);
   for (Rule r : attachmentPojo) {
     if (r.getRule_type().equals("contant")) {
       script = script.replaceAll(r.getOriginal_value(), r.getNew_value());
     }
     if (r.getRule_type().equals("variable")) {
       script = script.replaceAll(r.getOriginal_value(), r.getNew_value());
     }
     if (r.getRule_type().equals("regex")) {
       script = script.replaceAll(r.getOriginal_value(), r.getNew_value());
     }
   }
   return script;
 }
 /**
  * 删除规则
  *
  * @see
  *     com.yunat.workflow.development.service.DevelopmentService#deleteRule(com.yunat.workflow.development.domain.RuleDomain)
  * @author: 邱路平 - [email protected]
  * @date: Created on Jul 10, 2013 5:46:02 PM
  */
 @Transactional
 public void deleteRule(RuleDomain ruleDomain) {
   Rule rp = new Rule();
   rp.setRid(ruleDomain.getRid());
   ruleDAO.deleteRule(rp);
 }