/** * 查询规则 * * @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; }