Ejemplo n.º 1
0
        /// <summary>Creates a new, empty AttributeEntity object.</summary>
        /// <returns>A new, empty AttributeEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new AttributeEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewAttribute
            // __LLBLGENPRO_USER_CODE_REGION_END
            return toReturn;
        }
        private PolicyDocumentEntity importFile(baseData vData,string title, string filepath)
        {
            AttributeCollection acoll = new AttributeCollection();
            acoll.GetMulti(AttributeFields.Name == "Literal");
            if (acoll.Count == 0)
                throw new Exception("can't find literal attribute");
            m_literalAttribute = acoll[0];

            XmlDocument doc = new XmlDocument();
            doc.Load(filepath);

            PolicyDocumentEntity pde = new PolicyDocumentEntity();
            pde.LibraryId = vData.Library.Id;
            pde.Name = title;

            PolicyLinkEntity ple = new PolicyLinkEntity();
            ple.Policy = new PolicyEntity();
            ple.Policy.LibraryId = pde.LibraryId;
            pde.PolicyLink = ple;

            XmlNode policySet = doc.SelectSingleNode("policy-set");
            if (policySet != null)
                loadPolicySet(1,title,ple,policySet);
            else
            {
                XmlNode policy = doc.SelectSingleNode("policy");
                loadPolicy(1,title,ple,policy);
            }

            pde.Save(true);

            return pde;
        }
 /// <summary> Removes the sync logic for member _attribute</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 DesetupSyncAttribute(bool signalRelatedEntity, bool resetFKFields)
 {
     base.PerformDesetupSyncRelatedEntity( _attribute, new PropertyChangedEventHandler( OnAttributePropertyChanged ), "Attribute", AttributeValueEntity.Relations.AttributeEntityUsingAttributeId, true, signalRelatedEntity, "AttributeValue", resetFKFields, new int[] { (int)AttributeValueFieldIndex.AttributeId } );
     _attribute = null;
 }
        /// <summary> Retrieves the related entity of type 'AttributeEntity', 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 'AttributeEntity' which is related to this entity.</returns>
        public virtual AttributeEntity GetSingleAttribute(bool forceFetch)
        {
            if( ( !_alreadyFetchedAttribute || forceFetch || _alwaysFetchAttribute) && !base.IsSerializing && !base.IsDeserializing  && !base.InDesignMode)
            {
                bool performLazyLoading = base.CheckIfLazyLoadingShouldOccur(AttributeValueEntity.Relations.AttributeEntityUsingAttributeId);

                AttributeEntity newEntity = new AttributeEntity();
                if(base.ParticipatesInTransaction)
                {
                    base.Transaction.Add(newEntity);
                }
                bool fetchResult = false;
                if(performLazyLoading)
                {
                    fetchResult = newEntity.FetchUsingPK(this.AttributeId.GetValueOrDefault());
                }
                if(fetchResult)
                {
                    if(base.ActiveContext!=null)
                    {
                        newEntity = (AttributeEntity)base.ActiveContext.Get(newEntity);
                    }
                    this.Attribute = newEntity;
                }
                else
                {
                    if(_attributeReturnsNewIfNotFound)
                    {
                        if(performLazyLoading || (!performLazyLoading && (_attribute == null)))
                        {
                            this.Attribute = newEntity;
                        }
                    }
                    else
                    {
                        this.Attribute = null;
                    }
                }
                _alreadyFetchedAttribute = fetchResult;
                if(base.ParticipatesInTransaction && !fetchResult)
                {
                    base.Transaction.Remove(newEntity);
                }
            }
            return _attribute;
        }
 /// <summary> setups the sync logic for member _attribute</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncAttribute(IEntity relatedEntity)
 {
     if(_attribute!=relatedEntity)
     {
         DesetupSyncAttribute(true, true);
         _attribute = (AttributeEntity)relatedEntity;
         base.PerformSetupSyncRelatedEntity( _attribute, new PropertyChangedEventHandler( OnAttributePropertyChanged ), "Attribute", AttributeValueEntity.Relations.AttributeEntityUsingAttributeId, true, ref _alreadyFetchedAttribute, new string[] {  } );
     }
 }
        /// <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> 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();
        }
        /// <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();
        }
        /// <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
        }