示例#1
0
 /**
  * 构建者模式
  *
  * @return
  */
 public PolicyContext builderPolicy(EventIf eventif, PolicyObject policyObject) {
   /**
    * 在炉子里锻造PolicyContext,基本上从eventIf可以推断出必要的PolicyCondition和PolicyAction
    *
    * <p>需要根据taskid去查找对应的关联关系表
    */
   if (eventif != null) {
     List<PolicyCondition> policyConditions = policyObject.getPolicyConditionList();
     List<PolicyAction> policyActions = policyObject.getPolicyActions();
     if (eventif != null && policyConditions != null && policyActions != null) {
       PolicyContext policyContext = new PolicyContext();
       policyContext.setPolicyConditions(policyConditions);
       policyContext.setPolicyActions(policyActions);
       policyContext.setEvent(eventif);
       for (PolicyCondition policyCondition : policyConditions) {
         policyCondition.setParameters(eventif.getParameters());
       }
       for (PolicyAction policyAction : policyActions) {
         policyAction.setParameters(eventif.getParameters());
       }
       return policyContext;
     }
   }
   return null;
 }