/* * (non-Javadoc) * * @see com.aof.service.business.rule.FlowManager#createEngineRuleForFlowRule(com.aof.model.business.rule.FlowRule) */ public EngineRule createEngineRuleForFlowRule(FlowRule fr) { Integer ruleId = fr.getRule().getId(); EngineRule er = new EngineRule(ruleId); ruleManager.updateEngineRuleForRule(ruleId, er); er.setNextSeqPass(fr.getNextSeqWhenPass() - 1); er.setNextSeqFail(fr.getNextSeqWhenFail() - 1); return er; }
public void constructEngineFlow(Integer siteId, RuleType rt) { String flowName = siteId + rt.getPrefixUrl(); Collection flowRules = null; if (ConsequenceType.NOTIFIER.equals(rt.getConsequenceType())) { flowRules = new ArrayList(); List ruleList = ruleManager.getEnabledRuleListForRuleType(siteId, rt); int i = 2; for (Iterator itorRule = ruleList.iterator(); itorRule.hasNext(); i++) { Rule r = (Rule) itorRule.next(); FlowRule fr = new FlowRule(); fr.setRule(r); if (itorRule.hasNext()) { fr.setNextSeqWhenFail(i); fr.setNextSeqWhenPass(i); } else { fr.setNextSeqWhenFail(0); fr.setNextSeqWhenPass(0); } flowRules.add(fr); } } else { Flow f = getSiteEnabledFlow(siteId, rt); if (f != null) { flowRules = dao.getRulesForFlow(f.getId()); } } if (flowRules == null || flowRules.isEmpty()) { workspace.removeFlow(flowName); return; } EngineFlow ef = workspace.getFlow(flowName); if (ef == null) { ef = workspace.createFlow(flowName); } ef.lockForUpdate(); try { ef.clearRules(); for (Iterator itor = flowRules.iterator(); itor.hasNext(); ) { ef.addRule(createEngineRuleForFlowRule((FlowRule) itor.next())); } } finally { ef.releaseLock(); } }
public void saveFlowRules(Set flowRuleSet) { if (flowRuleSet != null && flowRuleSet.size() > 0) { Flow savedFlow = null; Iterator iterator = flowRuleSet.iterator(); while (iterator.hasNext()) { FlowRule flowRule = (FlowRule) iterator.next(); if (savedFlow == null) { saveFlow(flowRule.getFlow()); savedFlow = flowRule.getFlow(); } else { flowRule.setFlow(savedFlow); } ruleManager.saveRuleAll(flowRule.getRule()); dao.saveFlowRule(flowRule); } } }