예제 #1
0
 /*
  * (non-Javadoc)
  *
  * @see com.aof.service.business.rule.FlowManager#removeFlow(java.lang.Integer)
  */
 public void removeFlow(Integer id) {
   Flow f = getFlow(id, true);
   for (Iterator itor = f.getRules().iterator(); itor.hasNext(); ) {
     dao.removeFlowRule((FlowRule) itor.next());
   }
   dao.removeFlow(id);
   if (EnabledDisabled.ENABLED.equals(f.getEnabled())) {
     Site s = f.getSite();
     RuleType rt = f.getType();
     workspace.removeFlow(s.getId() + rt.getPrefixUrl());
   }
 }
예제 #2
0
  /*
   * (non-Javadoc)
   *
   * @see com.aof.service.business.rule.FlowManager#saveFlow(com.aof.model.business.rule.Flow,
   *      java.util.Set)
   */
  public Flow[] saveFlow(Flow f, Set flowRules) {
    Flow[] result = null;
    boolean needUpdateWorkspace = false;

    Flow f2 = getSiteEnabledFlow(f.getSite().getId(), f.getType());
    if (f.equals(f2)) {
      f2.setDescription(f.getDescription());
      f2.setEnabled(f.getEnabled());
      f = f2;
      needUpdateWorkspace = true;
    } else {
      if (EnabledDisabled.ENABLED.equals(f.getEnabled())) {
        if (f2 != null) {
          result = new Flow[2];
          f2.setEnabled(EnabledDisabled.DISABLED);
          result[1] = dao.saveFlow(f2);
        }
        needUpdateWorkspace = true;
      }
    }

    if (result == null) result = new Flow[1];
    result[0] = dao.saveFlow(f);
    if (flowRules != null) {
      for (Iterator itor = dao.getRulesForFlow(f.getId()).iterator(); itor.hasNext(); ) {
        dao.removeFlowRule((FlowRule) itor.next());
      }
      for (Iterator itor = flowRules.iterator(); itor.hasNext(); ) {
        dao.saveFlowRule((FlowRule) itor.next());
      }
    }
    if (needUpdateWorkspace) {
      constructEngineFlow(f.getSite().getId(), f.getType());
    }
    return result;
  }
예제 #3
0
  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();
    }
  }
예제 #4
0
  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);
      }
    }
  }
예제 #5
0
 /*
  * (non-Javadoc)
  *
  * @see com.aof.service.business.rule.FlowManager#getFlowList(java.util.Map,
  *      int, int, com.aof.model.business.rule.query.FlowQueryOrder, boolean)
  */
 public List getFlowList(
     Map conditions, int pageNo, int pageSize, FlowQueryOrder order, boolean descend) {
   return dao.getFlowList(conditions, pageNo, pageSize, order, descend);
 }
예제 #6
0
 /*
  * (non-Javadoc)
  *
  * @see com.aof.service.business.rule.FlowManager#getFlowListCount(java.util.Map)
  */
 public int getFlowListCount(Map conditions) {
   return dao.getFlowListCount(conditions);
 }
예제 #7
0
 /*
  * (non-Javadoc)
  *
  * @see com.aof.service.business.rule.FlowManager#getFlow(java.lang.Integer,
  *      boolean)
  */
 public Flow getFlow(Integer id, boolean loadLazyProperties) {
   return dao.getFlow(id, loadLazyProperties);
 }