public string GetMatchName(DecisionNodeEntity ame) { string name = string.Empty; if (ame.Extra.Length > 0) { if (ame.Attribute.AttributeType.Name == "uri") name = string.Format("{0}.{1}", ame.Attribute.Name, ame.Extra); else name = string.Format("{0}:{1}", ame.Attribute.Name, ame.Extra); } else name = ame.Attribute.Name; return name; }
/// <summary> setups the sync logic for member _decisionNode</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncDecisionNode(IEntity relatedEntity) { if(_decisionNode!=relatedEntity) { DesetupSyncDecisionNode(true, true); _decisionNode = (DecisionNodeEntity)relatedEntity; base.PerformSetupSyncRelatedEntity( _decisionNode, new PropertyChangedEventHandler( OnDecisionNodePropertyChanged ), "DecisionNode", TargetConditionEntity.Relations.DecisionNodeEntityUsingConditionId, true, ref _alreadyFetchedDecisionNode, new string[] { } ); } }
private void loadMatch(int idx,DecisionNodeEntity ce, XmlNode node) { DecisionNodeEntity ame = new DecisionNodeEntity(); ame.Type = constants.attributeMatchType; ame.Parent = ce; ame.Order = idx; XmlNode attr = node.Attributes.GetNamedItem("attr"); if (attr == null) throw new Exception(string.Format("attr attribute missing from node: {0}", node.InnerXml)); AttributeCollection acoll = new AttributeCollection(); string attrVal; string attrExtra; resolveAttribute(attr.Value, out attrVal, out attrExtra); acoll.GetMulti(AttributeFields.Name == attrVal); if (acoll.Count == 0) throw new Exception(string.Format("unknown attribute {0} (toby please fix this)", attrVal)); ame.Attribute = acoll[0]; ame.Extra = attrExtra; attr = node.Attributes.GetNamedItem("match"); if (attr != null) { AttributeValueEntity ave = new AttributeValueEntity(); ave.Order = 0; ave.Attribute = m_literalAttribute; ave.Value = attr.Value; ave.AttributeMatch = ame; } else { int valueIdx = 0; foreach (XmlNode kid in node.ChildNodes) { switch (kid.NodeType) { case XmlNodeType.Text: { AttributeValueEntity ave = new AttributeValueEntity(); ave.Order = valueIdx; ave.Attribute = m_literalAttribute; ave.Value = kid.Value.Trim(); ave.AttributeMatch = ame; } break; case XmlNodeType.Element: { switch (kid.LocalName) { case "environment-attr": loadAttributeValue(valueIdx, ame, kid); break; case "resource-attr": loadAttributeValue(valueIdx, ame, kid); break; case "subject-attr": loadAttributeValue(valueIdx, ame, kid); break; default: throw new Exception(string.Format("unknown attribute value type: {0}", kid.LocalName)); break; } } break; default: break; } valueIdx++; } } }
private void loadSubject(TargetEntity te, XmlNode node) { DecisionNodeEntity ce = new DecisionNodeEntity(); TargetConditionEntity tce = new TargetConditionEntity(); tce.Target = te; tce.DecisionNode = ce; loadCondition(ce, node); }
/// <summary> Retrieves the related entity of type 'DecisionNodeEntity', using a relation of type 'n:1'</summary> /// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param> /// <returns>A fetched entity of type 'DecisionNodeEntity' which is related to this entity.</returns> public virtual DecisionNodeEntity GetSingleAttributeMatch(bool forceFetch) { if( ( !_alreadyFetchedAttributeMatch || forceFetch || _alwaysFetchAttributeMatch) && !base.IsSerializing && !base.IsDeserializing && !base.InDesignMode) { bool performLazyLoading = base.CheckIfLazyLoadingShouldOccur(AttributeValueEntity.Relations.DecisionNodeEntityUsingAttributeMatchId); DecisionNodeEntity newEntity = new DecisionNodeEntity(); if(base.ParticipatesInTransaction) { base.Transaction.Add(newEntity); } bool fetchResult = false; if(performLazyLoading) { fetchResult = newEntity.FetchUsingPK(this.AttributeMatchId); } if(fetchResult) { if(base.ActiveContext!=null) { newEntity = (DecisionNodeEntity)base.ActiveContext.Get(newEntity); } this.AttributeMatch = newEntity; } else { if(_attributeMatchReturnsNewIfNotFound) { if(performLazyLoading || (!performLazyLoading && (_attributeMatch == null))) { this.AttributeMatch = newEntity; } } else { this.AttributeMatch = null; } } _alreadyFetchedAttributeMatch = fetchResult; if(base.ParticipatesInTransaction && !fetchResult) { base.Transaction.Remove(newEntity); } } return _attributeMatch; }
private void loadAttributeValue(int idx,DecisionNodeEntity ame, XmlNode node) { XmlNode attr = node.Attributes.GetNamedItem("attr"); if (attr == null) throw new Exception(string.Format("attr attribute missing from node: {0}", node.InnerXml)); string attrVal; string attrExtra; resolveAttribute(attr.Value, out attrVal, out attrExtra); AttributeCollection acoll = new AttributeCollection(); acoll.GetMulti(AttributeFields.Name == attrVal); if (acoll.Count == 0) throw new Exception(string.Format("unknown attribute {0} (toby please fix this)", attrVal)); AttributeValueEntity ave = new AttributeValueEntity(); ave.Order = idx; ave.Attribute = acoll[0]; ave.Value = attr.Value.Trim(); ave.AttributeMatch = ame; }
/// <summary> Initializes the class members</summary> private void InitClassMembers() { _condition = null; _conditionReturnsNewIfNotFound = true; _alwaysFetchCondition = false; _alreadyFetchedCondition = false; _effect = null; _effectReturnsNewIfNotFound = true; _alwaysFetchEffect = false; _alreadyFetchedEffect = false; _policy = null; _policyReturnsNewIfNotFound = true; _alwaysFetchPolicy = false; _alreadyFetchedPolicy = false; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
/// <summary>Private CTor for deserialization</summary> /// <param name="info"></param> /// <param name="context"></param> protected AttributeValueEntity(SerializationInfo info, StreamingContext context) : base(info, context) { _attribute = (AttributeEntity)info.GetValue("_attribute", typeof(AttributeEntity)); if(_attribute!=null) { _attribute.AfterSave+=new EventHandler(OnEntityAfterSave); } _attributeReturnsNewIfNotFound = info.GetBoolean("_attributeReturnsNewIfNotFound"); _alwaysFetchAttribute = info.GetBoolean("_alwaysFetchAttribute"); _alreadyFetchedAttribute = info.GetBoolean("_alreadyFetchedAttribute"); _attributeMatch = (DecisionNodeEntity)info.GetValue("_attributeMatch", typeof(DecisionNodeEntity)); if(_attributeMatch!=null) { _attributeMatch.AfterSave+=new EventHandler(OnEntityAfterSave); } _attributeMatchReturnsNewIfNotFound = info.GetBoolean("_attributeMatchReturnsNewIfNotFound"); _alwaysFetchAttributeMatch = info.GetBoolean("_alwaysFetchAttributeMatch"); _alreadyFetchedAttributeMatch = info.GetBoolean("_alreadyFetchedAttributeMatch"); base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance()); // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
/// <summary>Private CTor for deserialization</summary> /// <param name="info"></param> /// <param name="context"></param> protected RuleEntity(SerializationInfo info, StreamingContext context) : base(info, context) { _condition = (DecisionNodeEntity)info.GetValue("_condition", typeof(DecisionNodeEntity)); if(_condition!=null) { _condition.AfterSave+=new EventHandler(OnEntityAfterSave); } _conditionReturnsNewIfNotFound = info.GetBoolean("_conditionReturnsNewIfNotFound"); _alwaysFetchCondition = info.GetBoolean("_alwaysFetchCondition"); _alreadyFetchedCondition = info.GetBoolean("_alreadyFetchedCondition"); _effect = (EffectEntity)info.GetValue("_effect", typeof(EffectEntity)); if(_effect!=null) { _effect.AfterSave+=new EventHandler(OnEntityAfterSave); } _effectReturnsNewIfNotFound = info.GetBoolean("_effectReturnsNewIfNotFound"); _alwaysFetchEffect = info.GetBoolean("_alwaysFetchEffect"); _alreadyFetchedEffect = info.GetBoolean("_alreadyFetchedEffect"); _policy = (PolicyEntity)info.GetValue("_policy", typeof(PolicyEntity)); if(_policy!=null) { _policy.AfterSave+=new EventHandler(OnEntityAfterSave); } _policyReturnsNewIfNotFound = info.GetBoolean("_policyReturnsNewIfNotFound"); _alwaysFetchPolicy = info.GetBoolean("_alwaysFetchPolicy"); _alreadyFetchedPolicy = info.GetBoolean("_alreadyFetchedPolicy"); base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance()); // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
/// <summary> Removes the sync logic for member _condition</summary> /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param> /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param> private void DesetupSyncCondition(bool signalRelatedEntity, bool resetFKFields) { base.PerformDesetupSyncRelatedEntity( _condition, new PropertyChangedEventHandler( OnConditionPropertyChanged ), "Condition", RuleEntity.Relations.DecisionNodeEntityUsingConditionId, true, signalRelatedEntity, "Rule", resetFKFields, new int[] { (int)RuleFieldIndex.ConditionId } ); _condition = null; }
/// <summary> Initializes the class members</summary> private void InitClassMembers() { _decisionNode = null; _decisionNodeReturnsNewIfNotFound = true; _alwaysFetchDecisionNode = false; _alreadyFetchedDecisionNode = false; _target = null; _targetReturnsNewIfNotFound = true; _alwaysFetchTarget = false; _alreadyFetchedTarget = false; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
/// <summary> Removes the sync logic for member _decisionNode</summary> /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param> /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param> private void DesetupSyncDecisionNode(bool signalRelatedEntity, bool resetFKFields) { base.PerformDesetupSyncRelatedEntity( _decisionNode, new PropertyChangedEventHandler( OnDecisionNodePropertyChanged ), "DecisionNode", TargetConditionEntity.Relations.DecisionNodeEntityUsingConditionId, true, signalRelatedEntity, "TargetCondition", resetFKFields, new int[] { (int)TargetConditionFieldIndex.ConditionId } ); _decisionNode = null; }
/// <summary>Private CTor for deserialization</summary> /// <param name="info"></param> /// <param name="context"></param> protected TargetConditionEntity(SerializationInfo info, StreamingContext context) : base(info, context) { _decisionNode = (DecisionNodeEntity)info.GetValue("_decisionNode", typeof(DecisionNodeEntity)); if(_decisionNode!=null) { _decisionNode.AfterSave+=new EventHandler(OnEntityAfterSave); } _decisionNodeReturnsNewIfNotFound = info.GetBoolean("_decisionNodeReturnsNewIfNotFound"); _alwaysFetchDecisionNode = info.GetBoolean("_alwaysFetchDecisionNode"); _alreadyFetchedDecisionNode = info.GetBoolean("_alreadyFetchedDecisionNode"); _target = (TargetEntity)info.GetValue("_target", typeof(TargetEntity)); if(_target!=null) { _target.AfterSave+=new EventHandler(OnEntityAfterSave); } _targetReturnsNewIfNotFound = info.GetBoolean("_targetReturnsNewIfNotFound"); _alwaysFetchTarget = info.GetBoolean("_alwaysFetchTarget"); _alreadyFetchedTarget = info.GetBoolean("_alreadyFetchedTarget"); base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance()); // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
/// <summary> setups the sync logic for member _parent</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncParent(IEntity relatedEntity) { if(_parent!=relatedEntity) { DesetupSyncParent(true, true); _parent = (DecisionNodeEntity)relatedEntity; base.PerformSetupSyncRelatedEntity( _parent, new PropertyChangedEventHandler( OnParentPropertyChanged ), "Parent", DecisionNodeEntity.Relations.DecisionNodeEntityUsingIdParentId, true, ref _alreadyFetchedParent, new string[] { } ); } }
/// <summary> setups the sync logic for member _condition</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncCondition(IEntity relatedEntity) { if(_condition!=relatedEntity) { DesetupSyncCondition(true, true); _condition = (DecisionNodeEntity)relatedEntity; base.PerformSetupSyncRelatedEntity( _condition, new PropertyChangedEventHandler( OnConditionPropertyChanged ), "Condition", RuleEntity.Relations.DecisionNodeEntityUsingConditionId, true, ref _alreadyFetchedCondition, new string[] { } ); } }
/// <summary> Initializes the class members</summary> private void InitClassMembers() { _attribute = null; _attributeReturnsNewIfNotFound = true; _alwaysFetchAttribute = false; _alreadyFetchedAttribute = false; _attributeMatch = null; _attributeMatchReturnsNewIfNotFound = true; _alwaysFetchAttributeMatch = false; _alreadyFetchedAttributeMatch = false; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
public ActionResult CreateSubCondition(policyData vData, int id, int linkId) { vData.PolicyLink = new PolicyLinkEntity(linkId); DecisionNodeEntity ce = new DecisionNodeEntity(id); vData.Condition = new DecisionNodeEntity(); vData.Condition.Type = constants.conditionType; vData.Condition.Parent = ce; DecisionNodeCollection maxColl = new DecisionNodeCollection(); PredicateExpression pe = new PredicateExpression(DecisionNodeFields.ParentId == id); object maxObj = maxColl.GetScalar(DecisionNodeFieldIndex.Order, null, AggregateFunction.Max, pe); if (maxObj != null && maxObj != DBNull.Value) vData.Condition.Order = (int)maxObj + 1; else vData.Condition.Order = 0; vData.Condition.Save(); ViewData["title"] = "new sub-condition"; return View("EditCondition", vData); }
/// <summary> setups the sync logic for member _attributeMatch</summary> /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param> private void SetupSyncAttributeMatch(IEntity relatedEntity) { if(_attributeMatch!=relatedEntity) { DesetupSyncAttributeMatch(true, true); _attributeMatch = (DecisionNodeEntity)relatedEntity; base.PerformSetupSyncRelatedEntity( _attributeMatch, new PropertyChangedEventHandler( OnAttributeMatchPropertyChanged ), "AttributeMatch", AttributeValueEntity.Relations.DecisionNodeEntityUsingAttributeMatchId, true, ref _alreadyFetchedAttributeMatch, new string[] { } ); } }
public ActionResult DecisionNodeOrder(policyData vData, int id, int id2, int linkId, FormCollection collection) { DecisionNodeEntity match = new DecisionNodeEntity(id2); DecisionNodeCollection coll = new DecisionNodeCollection(); PredicateExpression pe = new PredicateExpression(DecisionNodeFields.Id != match.Id); pe.Add(DecisionNodeFields.ParentId == id); SortExpression se = null; if (collection["up"] != null) { // Find all categories with display index less than ours. pe.Add(DecisionNodeFields.Order <= match.Order); // Order by display index, highest first. se = new SortExpression(DecisionNodeFields.Order | SortOperator.Descending); } else { // Find all categories with display index greater than ours. pe.Add(DecisionNodeFields.Order >= match.Order); // Order by display index, lowest first. se = new SortExpression(DecisionNodeFields.Order | SortOperator.Ascending); } // Swap with closest one. if (coll.GetMulti(pe, 1, se) && coll.Count > 0) { int temp = coll[0].Order; coll[0].Order = match.Order; match.Order = temp; match.Save(); coll.SaveMulti(); } string action = collection["backTo"]; if (action == "EditRule") { vData.Condition = new DecisionNodeEntity(id); id = vData.Condition.Rule[0].Id; } return RedirectToAction(action, new { id = id, linkId = linkId }); }
/// <summary> Removes the sync logic for member _attributeMatch</summary> /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param> /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param> private void DesetupSyncAttributeMatch(bool signalRelatedEntity, bool resetFKFields) { base.PerformDesetupSyncRelatedEntity( _attributeMatch, new PropertyChangedEventHandler( OnAttributeMatchPropertyChanged ), "AttributeMatch", AttributeValueEntity.Relations.DecisionNodeEntityUsingAttributeMatchId, true, signalRelatedEntity, "AttributeValue", resetFKFields, new int[] { (int)AttributeValueFieldIndex.AttributeMatchId } ); _attributeMatch = null; }
private static void DeleteDecisionNode(DecisionNodeEntity de) { foreach (DecisionNodeEntity child in de.Children) { DeleteDecisionNode(child); } de.AttributeValue.DeleteMulti(); de.TargetCondition.DeleteMulti(); de.Rule.DeleteMulti(); de.Delete(); }
private void loadCondition(DecisionNodeEntity ce,XmlNode node) { ce.Type = constants.conditionType; XmlNode attr = node.Attributes.GetNamedItem("combine"); if (attr == null || attr.Value == "and") ce.CombineAnd = true; else ce.CombineAnd = false; int matchIdx = 0; foreach (XmlNode child in node.ChildNodes) { if (child.NodeType != XmlNodeType.Element) continue; switch (child.LocalName) { case "condition": DecisionNodeEntity ceChild = new DecisionNodeEntity(); ceChild.Parent = ce; ceChild.Order = matchIdx++; loadCondition(ceChild,child); break; case "resource-match": case "environment-match": case "subject-match": loadMatch(matchIdx++, ce, child); break; } } }
/// <summary>Private CTor for deserialization</summary> /// <param name="info"></param> /// <param name="context"></param> protected DecisionNodeEntity(SerializationInfo info, StreamingContext context) : base(info, context) { _attributeValue = (policyDB.CollectionClasses.AttributeValueCollection)info.GetValue("_attributeValue", typeof(policyDB.CollectionClasses.AttributeValueCollection)); _alwaysFetchAttributeValue = info.GetBoolean("_alwaysFetchAttributeValue"); _alreadyFetchedAttributeValue = info.GetBoolean("_alreadyFetchedAttributeValue"); _children = (policyDB.CollectionClasses.DecisionNodeCollection)info.GetValue("_children", typeof(policyDB.CollectionClasses.DecisionNodeCollection)); _alwaysFetchChildren = info.GetBoolean("_alwaysFetchChildren"); _alreadyFetchedChildren = info.GetBoolean("_alreadyFetchedChildren"); _rule = (policyDB.CollectionClasses.RuleCollection)info.GetValue("_rule", typeof(policyDB.CollectionClasses.RuleCollection)); _alwaysFetchRule = info.GetBoolean("_alwaysFetchRule"); _alreadyFetchedRule = info.GetBoolean("_alreadyFetchedRule"); _targetCondition = (policyDB.CollectionClasses.TargetConditionCollection)info.GetValue("_targetCondition", typeof(policyDB.CollectionClasses.TargetConditionCollection)); _alwaysFetchTargetCondition = info.GetBoolean("_alwaysFetchTargetCondition"); _alreadyFetchedTargetCondition = info.GetBoolean("_alreadyFetchedTargetCondition"); _attributeCollectionViaDecisionNode = (policyDB.CollectionClasses.AttributeCollection)info.GetValue("_attributeCollectionViaDecisionNode", typeof(policyDB.CollectionClasses.AttributeCollection)); _alwaysFetchAttributeCollectionViaDecisionNode = info.GetBoolean("_alwaysFetchAttributeCollectionViaDecisionNode"); _alreadyFetchedAttributeCollectionViaDecisionNode = info.GetBoolean("_alreadyFetchedAttributeCollectionViaDecisionNode"); _attributeCollectionViaAttributeValue = (policyDB.CollectionClasses.AttributeCollection)info.GetValue("_attributeCollectionViaAttributeValue", typeof(policyDB.CollectionClasses.AttributeCollection)); _alwaysFetchAttributeCollectionViaAttributeValue = info.GetBoolean("_alwaysFetchAttributeCollectionViaAttributeValue"); _alreadyFetchedAttributeCollectionViaAttributeValue = info.GetBoolean("_alreadyFetchedAttributeCollectionViaAttributeValue"); _effectCollectionViaRule = (policyDB.CollectionClasses.EffectCollection)info.GetValue("_effectCollectionViaRule", typeof(policyDB.CollectionClasses.EffectCollection)); _alwaysFetchEffectCollectionViaRule = info.GetBoolean("_alwaysFetchEffectCollectionViaRule"); _alreadyFetchedEffectCollectionViaRule = info.GetBoolean("_alreadyFetchedEffectCollectionViaRule"); _policyCollectionViaRule = (policyDB.CollectionClasses.PolicyCollection)info.GetValue("_policyCollectionViaRule", typeof(policyDB.CollectionClasses.PolicyCollection)); _alwaysFetchPolicyCollectionViaRule = info.GetBoolean("_alwaysFetchPolicyCollectionViaRule"); _alreadyFetchedPolicyCollectionViaRule = info.GetBoolean("_alreadyFetchedPolicyCollectionViaRule"); _targetCollectionViaTargetCondition = (policyDB.CollectionClasses.TargetCollection)info.GetValue("_targetCollectionViaTargetCondition", typeof(policyDB.CollectionClasses.TargetCollection)); _alwaysFetchTargetCollectionViaTargetCondition = info.GetBoolean("_alwaysFetchTargetCollectionViaTargetCondition"); _alreadyFetchedTargetCollectionViaTargetCondition = info.GetBoolean("_alreadyFetchedTargetCollectionViaTargetCondition"); _attribute = (AttributeEntity)info.GetValue("_attribute", typeof(AttributeEntity)); if(_attribute!=null) { _attribute.AfterSave+=new EventHandler(OnEntityAfterSave); } _attributeReturnsNewIfNotFound = info.GetBoolean("_attributeReturnsNewIfNotFound"); _alwaysFetchAttribute = info.GetBoolean("_alwaysFetchAttribute"); _alreadyFetchedAttribute = info.GetBoolean("_alreadyFetchedAttribute"); _parent = (DecisionNodeEntity)info.GetValue("_parent", typeof(DecisionNodeEntity)); if(_parent!=null) { _parent.AfterSave+=new EventHandler(OnEntityAfterSave); } _parentReturnsNewIfNotFound = info.GetBoolean("_parentReturnsNewIfNotFound"); _alwaysFetchParent = info.GetBoolean("_alwaysFetchParent"); _alreadyFetchedParent = info.GetBoolean("_alreadyFetchedParent"); base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance(), PersistenceInfoProviderSingleton.GetInstance()); // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor // __LLBLGENPRO_USER_CODE_REGION_END }
private void loadRule(int idx,PolicyEntity pe, XmlNode node) { RuleEntity re = new RuleEntity(); re.Policy = pe; re.Order = idx; string effect = "permit"; XmlNode attr = node.Attributes.GetNamedItem("effect"); if (attr != null) effect = attr.Value; EffectCollection ecoll = new EffectCollection(); ecoll.GetMulti(EffectFields.Name == effect); if (ecoll.Count != 1) throw new Exception(string.Format("unrecognised rule effect {0}", effect)); re.Effect = ecoll[0]; DecisionNodeEntity ce = new DecisionNodeEntity(); re.Condition = ce; ce.Type = constants.conditionType; ce.IsDirty = true; XmlNode condition = node.SelectSingleNode("condition"); if (condition != null) loadCondition(ce, condition); }
/// <summary> Removes the sync logic for member _parent</summary> /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param> /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param> private void DesetupSyncParent(bool signalRelatedEntity, bool resetFKFields) { base.PerformDesetupSyncRelatedEntity( _parent, new PropertyChangedEventHandler( OnParentPropertyChanged ), "Parent", DecisionNodeEntity.Relations.DecisionNodeEntityUsingIdParentId, true, signalRelatedEntity, "Children", resetFKFields, new int[] { (int)DecisionNodeFieldIndex.ParentId } ); _parent = null; }
public string GetConditionString(DecisionNodeEntity ce) { Debug.Assert(ce.Type == constants.conditionType); StringBuilder sb = new StringBuilder(); ce.Children.Sort(DecisionNodeFields.Order.FieldIndex, System.ComponentModel.ListSortDirection.Ascending); foreach (DecisionNodeEntity ame in ce.Children) { if (sb.Length > 0) sb.AppendFormat(" {0} ", ce.CombineAnd ? "and" : "or"); else sb.Append("("); if (ame.Type == constants.conditionType) { sb.AppendFormat("{0}", GetConditionString(ame)); } else { if (ame.Extra.Length > 0) { if (ame.Attribute.AttributeType.Name == "uri") sb.AppendFormat("{0}.{1} = {2}", ame.Attribute.Name, ame.Extra, GetMatchString(ame)); else sb.AppendFormat("{0}:{1} = {2}", ame.Attribute.Name, ame.Extra, GetMatchString(ame)); } else sb.AppendFormat("{0} = {1}", ame.Attribute.Name, GetMatchString(ame)); } } if (sb.Length == 0) sb.Append("always"); else sb.Append(")"); return sb.ToString(); }
/// <summary> Initializes the class members</summary> private void InitClassMembers() { _attributeValue = new policyDB.CollectionClasses.AttributeValueCollection(new AttributeValueEntityFactory()); _attributeValue.SetContainingEntityInfo(this, "AttributeMatch"); _alwaysFetchAttributeValue = false; _alreadyFetchedAttributeValue = false; _children = new policyDB.CollectionClasses.DecisionNodeCollection(new DecisionNodeEntityFactory()); _children.SetContainingEntityInfo(this, "Parent"); _alwaysFetchChildren = false; _alreadyFetchedChildren = false; _rule = new policyDB.CollectionClasses.RuleCollection(new RuleEntityFactory()); _rule.SetContainingEntityInfo(this, "Condition"); _alwaysFetchRule = false; _alreadyFetchedRule = false; _targetCondition = new policyDB.CollectionClasses.TargetConditionCollection(new TargetConditionEntityFactory()); _targetCondition.SetContainingEntityInfo(this, "DecisionNode"); _alwaysFetchTargetCondition = false; _alreadyFetchedTargetCondition = false; _attributeCollectionViaDecisionNode = new policyDB.CollectionClasses.AttributeCollection(new AttributeEntityFactory()); _alwaysFetchAttributeCollectionViaDecisionNode = false; _alreadyFetchedAttributeCollectionViaDecisionNode = false; _attributeCollectionViaAttributeValue = new policyDB.CollectionClasses.AttributeCollection(new AttributeEntityFactory()); _alwaysFetchAttributeCollectionViaAttributeValue = false; _alreadyFetchedAttributeCollectionViaAttributeValue = false; _effectCollectionViaRule = new policyDB.CollectionClasses.EffectCollection(new EffectEntityFactory()); _alwaysFetchEffectCollectionViaRule = false; _alreadyFetchedEffectCollectionViaRule = false; _policyCollectionViaRule = new policyDB.CollectionClasses.PolicyCollection(new PolicyEntityFactory()); _alwaysFetchPolicyCollectionViaRule = false; _alreadyFetchedPolicyCollectionViaRule = false; _targetCollectionViaTargetCondition = new policyDB.CollectionClasses.TargetCollection(new TargetEntityFactory()); _alwaysFetchTargetCollectionViaTargetCondition = false; _alreadyFetchedTargetCollectionViaTargetCondition = false; _attribute = null; _attributeReturnsNewIfNotFound = true; _alwaysFetchAttribute = false; _alreadyFetchedAttribute = false; _parent = null; _parentReturnsNewIfNotFound = true; _alwaysFetchParent = false; _alreadyFetchedParent = false; PerformDependencyInjection(); // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers // __LLBLGENPRO_USER_CODE_REGION_END OnInitClassMembersComplete(); }
public string GetMatchString(DecisionNodeEntity ame) { StringBuilder sb = new StringBuilder(); ame.AttributeValue.Sort(AttributeValueFields.Order.FieldIndex, System.ComponentModel.ListSortDirection.Ascending); foreach (AttributeValueEntity ave in ame.AttributeValue) { if (ave.Literal) sb.Append(ave.Value); else sb.AppendFormat("[{0}]", ave.Attribute.Name); } return sb.ToString(); }
/// <summary>Creates a new, empty DecisionNodeEntity object.</summary> /// <returns>A new, empty DecisionNodeEntity object.</returns> public override IEntity Create() { IEntity toReturn = new DecisionNodeEntity(); // __LLBLGENPRO_USER_CODE_REGION_START CreateNewDecisionNode // __LLBLGENPRO_USER_CODE_REGION_END return toReturn; }