Пример #1
0
 public ConditionGroup(Guid guid, IPolicyLanguageItem name, ConditionLogic logic, bool exitOnFirstPass)
     : base(guid, name)
 {
     m_logic = logic;
     m_exitOnFirstPass = exitOnFirstPass;
     m_conditions = new PolicyObjectCollection<IPolicyObject>();
 }
Пример #2
0
		public PolicySummary(IPolicy policy)
		{
			m_policy = policy;

			foreach( IPolicyObject po in m_policy.Conditions )
			{
				//why do we have ConditionGroups within ConditionGroups?

				IConditionGroup grp = po as IConditionGroup;
				m_logic = grp.Logic;

				if (null != grp)
				{
					foreach (IPolicyObject subObject in grp.Conditions)
					{
						m_conditionSummaryList.Add(new ConditionSummary(subObject, policy.PolicySet.PolicyType));
					}
				}
			}

			foreach (IPolicyChannel channel in m_policy.Channels)
			{
				m_channelSummaryList.Add(new ChannelSummary(channel));
			}
		}
Пример #3
0
        private IPolicyObjectCollection<IPolicyObject> FilterConditions(ConditionLogic logic, IPolicyObjectCollection<IPolicyObject> conditions)
        {
            if (null == conditions)
                return null;

            IPolicyObjectCollection<IPolicyObject> reducedConditions = new PolicyObjectCollection<IPolicyObject>();

            foreach (IPolicyObject policyObject in conditions)
            {
                if (ConditionContainsFilter(policyObject as ICondition))
                {
                    reducedConditions.Add((policyObject as Condition).DeepCopy(policyObject.ReadOnly, true));
                }
                else if(policyObject is IConditionGroup)
                {
                    IConditionGroup conditionGroup = policyObject as IConditionGroup;
                    ConditionGroup reducedConditionGroup = new ConditionGroup(Guid.NewGuid(), conditionGroup.Name, conditionGroup.Logic, conditionGroup.ExitOnFirstPass);
                    reducedConditionGroup.AddConditions(FilterConditions(conditionGroup.Logic, conditionGroup.Conditions));

                    if (0 != reducedConditionGroup.Conditions.Count)
                    {
                        reducedConditions.Add(reducedConditionGroup);
                    }
                }
            }

            return reducedConditions;
        }
Пример #4
0
        public ConditionGroup(ConditionGroup conditionGroup, IPolicyObjectCollection<IPolicyObject> conditions)
            : base(conditionGroup)
		{            
            if (null == conditionGroup)
				throw new Workshare.Policy.Exceptions.ArgumentNullException("conditionGroup", "Input condition group is null");

            m_parent = conditionGroup.m_parent;
            m_logic = conditionGroup.Logic;
			m_exitOnFirstPass = conditionGroup.ExitOnFirstPass;
            m_conditions = new PolicyObjectCollection<IPolicyObject>(conditions as PolicyObjectCollection<IPolicyObject>);
		}
Пример #5
0
 public void m_conditionsPanel_Logic_Changed(object sender, ConditionLogic logic)
 {
     if (m_policy.Conditions[0] is IConditionGroup)
     {
         ConditionUnitFactory.ChangeConditionGroupLogic(m_policy.Conditions[0] as IConditionGroup, logic);
         m_conditionsPanel.Display();
         StateMachine.ChildForm.IsModified = true;
     }
     else
     {
         throw new ArgumentException("Cannot change condition logic on an object that is not a condition group");
     }
 }
Пример #6
0
        private void CopyConditionGroup(ConditionGroup conditionGroup)
        {            
            if (null == conditionGroup)
				throw new Workshare.Policy.Exceptions.ArgumentNullException("conditionGroup", "Input condition group is null");

            m_parent = conditionGroup.m_parent;
            m_logic = conditionGroup.Logic;
            m_exitOnFirstPass = conditionGroup.ExitOnFirstPass;
            m_policySetObserver = conditionGroup.PolicySetObserver;

            if (null != conditionGroup.Conditions)
            {
                m_conditions = new PolicyObjectCollection<IPolicyObject>(conditionGroup.Conditions as PolicyObjectCollection<IPolicyObject>);
                (m_conditions as PolicyObjectCollection<IPolicyObject>).PolicySetObserver = m_policySetObserver;
            }
        }
Пример #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="conditionLogic"></param>
 /// <returns></returns>
 public static string GetConditionLogic(ConditionLogic conditionLogic)
 {
     switch (conditionLogic)
     {
         case ConditionLogic.AND: return "AND";
         case ConditionLogic.OR: return "OR";
         case ConditionLogic.NOT: return "NOT";
         default: return string.Empty;
     }
 }
Пример #8
0
 /// <summary>
 /// Proxying of logic changed event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="logic"></param>
 void selectedConditionsControl1_Logic_Changed(object sender, ConditionLogic logic)
 {
     if (Logic_Changed != null)
     {
         Logic_Changed(sender, logic);
     }
 }
Пример #9
0
		/// <summary>
		/// Recursively changes the condition logic on all condition groups
		/// </summary>
		/// <param name="conditionGroup">Condition group to change</param>
		/// <param name="logic">Condition Group logic</param>
		public static void ChangeConditionGroupLogic(IConditionGroup conditionGroup, ConditionLogic logic)
		{
			foreach (IPolicyObject policyObject in conditionGroup.Conditions)
			{
				if (policyObject is IConditionGroup)
				{
					ChangeConditionGroupLogic((IConditionGroup) policyObject, logic);
				}
			}
			conditionGroup.Logic = logic;
		}
Пример #10
0
 private void SetDefaults()
 {
     m_logic = ConditionLogic.AND;
     m_exitOnFirstPass = false;
     m_conditions = new PolicyObjectCollection<IPolicyObject>();
 }
Пример #11
0
        public void WriteCondition(IPolicySet policySet, IPolicyObject parent, ICondition condition, ConditionLogic cdnlogic)
        {
            NxLogic logic = new NxLogic();
            NxIf iF = new NxIf();
            NxOperator conditionTest = null;
            if (condition.IsNegated)
                conditionTest = new NxNot();
            else
                conditionTest = new NxAnd();

            IDataElement lhs = condition.DataLeft;
            IDataElement rhs = condition.DataRight;

            WriteDataElement(lhs);
            WriteDataElement(rhs);

            string incrementId = Guid.NewGuid().ToString();
            List<NxParameter> parameters = NxUtils.GetAttributes(condition);

            NxSet currentPolicy = m_policysets.PolicySets[0].CurrentPolicy;

            string lhsId = lhs.Identifier.ToString();
            string rhsId = rhs.Identifier.ToString();
            if (condition.Class == "IDataLengthComparer")
            {
                if ((lhs.Type == DataType.Object) || (NxUtils.IsArray(lhs.Type)))
                {
                    lhsId = Guid.NewGuid().ToString();
                    foreach (NxPolicySet policyset in m_policysets.PolicySets)
                    {
                        policyset.CurrentPolicy.Append(new NxObjectLookup(lhsId, lhs.Identifier.ToString(), "Length"));
                    }
                    parameters.Add(new NxParameter("Properties", lhs.Identifier.ToString(), true));
                }

                if ((rhs.Type == DataType.Object) || (NxUtils.IsArray(rhs.Type)))
                {
                    rhsId = Guid.NewGuid().ToString();
                    foreach (NxPolicySet policyset in m_policysets.PolicySets)
                    {
                        policyset.CurrentPolicy.Append(new NxObjectLookup(rhsId, rhs.Identifier.ToString(), "Length"));
                    }
                    parameters.Add(new NxParameter("Properties", rhs.Identifier.ToString(), true));
                }
            }
            conditionTest.Append(lhsId, rhsId, condition.Operator);

            NxDo dO = new NxDo();

            foreach (NxPolicySet policyset in m_policysets.PolicySets)
            {
                policyset.AppendIncrementer(new NxIncrement(incrementId));
                policyset.AppendIncrementer(new NxIncrementStep(incrementId));
            }
           
            dO.Append(new NxIncrementStep(incrementId));
            bool ignored = NxUtils.IsIgnored(condition);
            iF.Append(conditionTest);
            iF.Append(dO);
            logic.Append(iF);
            if (!ignored)
            {
                parameters.Add(new NxParameter("Name", condition));
                dO.Append(new NxEvaluate("ConditionLineFired", new List<NxParameter>(parameters.ToArray())));
                NxElse eLse = new NxElse();
                eLse.Append(new NxEvaluate("ConditionLinePassed", new List<NxParameter>(parameters.ToArray())));
                logic.Append(eLse);
            }
            foreach (NxPolicySet policyset in m_policysets.PolicySets)
            {
                policyset.Policies[policyset.Policies.Count - 1].AppendLogic(logic);
                policyset.Policies[policyset.Policies.Count - 1].AppendIncrementId(incrementId, parent.Identifier, cdnlogic); //IConditionGroup
            }
        }
Пример #12
0
		public void WriteCondition(IPolicySet policySet, IPolicyObject parent, ICondition condition, ConditionLogic logic)
		{
			ICataloguePolicy parentCataloguePolicy = parent as ICataloguePolicy;
			if (null == parentCataloguePolicy)
				return;

			IPolicy policy = new P5Policy(policySet, parentCataloguePolicy.Identifier, parentCataloguePolicy.Name, parentCataloguePolicy.Status);
			policy.Conditions.Add(condition);
			WriteChildCollection(policySet, policy, parentCataloguePolicy.Name.Value, policy.Conditions);
		}