public String save() { CompRule rule = loadRule(); CompRuleDao dao = new CompRuleDao(); boolean isSucess = dao.save(rule); // 保存详细的规则 if (isSucess) { saveDetailRule(rule.getSelect_type(), -1); } return ruleDetailList(); }
// 修改并保存规则 public String edit() { boolean isSucess = false; CompRule vo = loadRule(); int id = getParaIntValue("id"); vo.setId(id); CompRuleDao dao = new CompRuleDao(); isSucess = dao.update(vo); DetailCompRuleDao detailDao = new DetailCompRuleDao(); if (isSucess) { isSucess = detailDao.deleteDetailRule(vo); saveDetailRule(vo.getSelect_type(), id); } return ruleDetailList(); }
public CompRule loadRule() { String rule_name = getParaValue("rule_name"); String des = getParaValue("des"); int standard = getParaIntValue(("standard")); int level = getParaIntValue("level"); String add_des = getParaValue("add_des"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = new Date(); User user = (User) session.getAttribute(SessionConstant.CURRENT_USER); CompRule rule = new CompRule(); rule.setComprule_name(rule_name); rule.setDescription(des); rule.setSelect_type(standard); rule.setCreate_time(sdf.format(date)); rule.setLast_modified_time(sdf.format(date)); rule.setCreated_by(user.getName()); rule.setLast_modified_by(user.getName()); // 在修改时不变 rule.setViolation_severity(level); rule.setRemediation_descr(add_des); return rule; }