Exemple #1
0
 public NxActionSet(string id, IActionMatrixCell actionMatrixCell, NxObjectWriter pow, IResourceManager resourceManager)
     : base(id)
 {
     m_Pow = pow;
     m_ActionMatrixCell = actionMatrixCell;
     m_resourceManager = resourceManager;
 }
        private void WriteActionMatrixCell(XmlNode xmlActionCellNode, IActionMatrixCell actionMatrixCell)
        {
            if (0 == actionMatrixCell.ActionConditionGroups.Count)
                return;

            XmlNode xmlConditionGroupsNode = m_xmlDocument.CreateElement("ConditionGroups");
            xmlActionCellNode.AppendChild(xmlConditionGroupsNode);
            XmlHelpers.AddReadOnlyAttribute(xmlActionCellNode, actionMatrixCell.ReadOnly);
            WriteActionConditionGroups(xmlConditionGroupsNode, actionMatrixCell.ActionConditionGroups);
        }
 private void CreateActionGroupForCell(IActionMatrixCell cell)
 {
     if (0 == cell.ActionConditionGroups.Count)
     {
         cell.ActionConditionGroups.Add(RoutingHelper.ActionConditionGroupFactory());
         if (m_CustomActionType == CustomType.ExceptionHandling)
             cell.ActionConditionGroups[0].ActionGroup.Name.Value = Properties.Resources.IDS_EXCEPTIONHANDLER_NAME;
         else
             cell.ActionConditionGroups[0].ActionGroup.Name.Value = Properties.Resources.IDS_OFFLINE_NAME;
     }
 }
        private void ReadActionMatrixConditions(XmlNode actionMatrixCellNode, IActionMatrixCell actionMatrixCell, bool readOnly)
        {
            XmlNodeList actionConditionGroupsNodeList = actionMatrixCellNode.SelectNodes("ConditionGroups/*");
            IPolicyObjectCollection<IConditionGroup> catalogueConditionGroups = m_reader.CataloguesCache.ConditionGroups;
            IPolicyObjectCollection<IPolicyObject> assignedConditions = m_policy.Conditions;
            foreach (XmlNode actionConditionGroupNode in actionConditionGroupsNodeList)
            {
                Guid conditionGroupId = new Guid(actionConditionGroupNode.Attributes.GetNamedItem("id").InnerText);
                bool conditionGroupReadOnly = PolicyUtilities.IsReadOnly(actionConditionGroupNode) || readOnly;

                ConditionGroup tmpConditionGroup = assignedConditions[conditionGroupId] as ConditionGroup;
                if (null == tmpConditionGroup)
                {
                    tmpConditionGroup = catalogueConditionGroups[conditionGroupId] as ConditionGroup;
                }
                ConditionGroup conditionGroup = new ConditionGroup(tmpConditionGroup, conditionGroupReadOnly, false);
                
                if (actionMatrixCell is ActionMatrixCell)
                {
                    ActionGroup actionGroup = ReadActions(actionMatrixCellNode, actionConditionGroupNode);
                    (actionMatrixCell as ActionMatrixCell).AddActionCondition(conditionGroup, actionGroup, conditionGroupReadOnly);
                }
                else if (actionMatrixCell is OfflineActionMatrixCell)
                {
                    ActionGroup actionGroup = ReadSpecialActionCell(actionMatrixCellNode, actionConditionGroupNode, "Offline");
                    (actionMatrixCell as OfflineActionMatrixCell).AddActionCondition(conditionGroup, actionGroup, conditionGroupReadOnly);
                }
                else if (actionMatrixCell is ActionExceptionCell)
                {
                    ActionGroup actionGroup = ReadSpecialActionCell(actionMatrixCellNode, actionConditionGroupNode, "ActionException");
                    (actionMatrixCell as ActionExceptionCell).AddActionCondition(conditionGroup, actionGroup, conditionGroupReadOnly);
                }
            }
        }
        private void ValidateActionMatrixCell(IActionMatrixCell actionMatrixCell)
        {
            IPolicyObjectCollection<IActionConditionGroup> actionConditionGroups = actionMatrixCell.ActionConditionGroups;
            Assert.IsTrue(actionConditionGroups.IsReadOnly, "Expected the action conditions group to be read only");

            Assert.AreEqual(1, actionConditionGroups.Count, "Expected action condition group to have one action group");
            IActionConditionGroup actionConditionGroup = actionConditionGroups[0];
            Assert.IsNotNull(actionConditionGroup, "Expected a valid action condition group");
            Assert.IsTrue(actionConditionGroup.ReadOnly, "Expected the action condition group to be read only");

            IActionGroup actionGroup = actionConditionGroup.ActionGroup;
            Assert.AreEqual(1, actionGroup.Precedence, "Expected the top level action group precedence to be 1");
            Assert.IsNotNull(actionGroup);
            Assert.AreEqual(1, actionGroup.ActionGroups.Count, "Expected one sub action group");

            IActionGroup subActionGroup = actionGroup.ActionGroups[0];
            Assert.IsNotNull(subActionGroup);
            Assert.AreEqual(1, subActionGroup.Precedence, "Expected the sub action group precedence to be 1");

            Assert.AreEqual(1, subActionGroup.Actions.Count, "Expected sub action group to have one sub action");
            IAction subAction = subActionGroup.Actions[0];
            Assert.IsTrue(subAction.ReadOnly, "Expected the sub action to be read only");
            Assert.IsTrue(subAction.DataElements.IsReadOnly, "Expected the sub action data element to be read only");

            Assert.AreEqual(1, actionGroup.Actions.Count, "Expected action group to have one sub action");
            IAction action = actionGroup.Actions[0];
            Assert.IsTrue(action.ReadOnly, "Expected the action to be read only");
            Assert.IsTrue(action.DataElements.IsReadOnly, "Expected the action data element to be read only");
        }
Exemple #6
0
        private void AddActionSetsForRoutingMatrixCell(NxDo routingDo, IRoutingMatrixCell routingMatrixCell, IActionMatrixCell actionMatrixCell)
        {
            if (actionMatrixCell == null)
                return;

            List<NxParameter> actionParams = NxUtils.GetAttributes(actionMatrixCell);
            string actionSetId = NxUtils.ToNxBreGuid(actionMatrixCell.Identifier);
            List<NxParameter> routingParams = FilterRoutingMatrixCell(NxUtils.GetAttributes(routingMatrixCell));
            routingParams.Add(new NxParameter("Name", routingMatrixCell.Name));
            routingParams.Add(new NxParameter("ActionSetId", actionSetId, false));
            routingDo.Append(new NxEvaluate("RoutingPath", routingParams));

            m_actionSets.Add(new NxActionSet(actionSetId, actionMatrixCell, m_objectWriter, m_resourceManager));
        }
        private IPolicyObjectCollection<IAction> ExtractTopLevelActions(IActionMatrixCell iamc)
        {
            if ((null == iamc) || (0 == iamc.ActionConditionGroups.Count))
                return null;

            IActionConditionGroup actionConditionGroup = iamc.ActionConditionGroups[0];
            if (null == actionConditionGroup)
                return null;

            IActionGroup actionGroup = actionConditionGroup.ActionGroup;
            if (null == actionGroup)
                return null;

            return actionGroup.Actions;
        }
        private void AssignExceptionIdToActions(IActionMatrix actionMatrix, IActionMatrixCell iamc)
        {
            const string exceptionHandlerPropertyName = "ExceptionHandler";
            IPolicyObjectCollection<IAction> exceptionActions = ExtractTopLevelActions(iamc);
            if ((null == exceptionActions) || (0 == exceptionActions.Count))
                return;

            // We will only use the first exception action - there should be only one anyway
            IAction exceptionAction = exceptionActions[0];

            exceptionAction[exceptionHandlerPropertyName].Value = exceptionAction.Identifier.ToString("B").ToUpper(CultureInfo.InvariantCulture);

            foreach (KeyValuePair<KeyValuePair<Guid, Guid>, IActionMatrixCell> matrixCellPair in actionMatrix)
            {
                IPolicyObjectCollection<IAction> actions = ExtractTopLevelActions(matrixCellPair.Value);
                foreach (IAction action in actions)
                {
                    action[exceptionHandlerPropertyName].Value = exceptionAction[exceptionHandlerPropertyName].Value;
                }
            }
        }