public virtual void Construct(GOGroupDataObject gOGroup, bool includeDirtyObjectsOnly) { if (gOGroup == null) return; this.PrimaryKey = gOGroup.PrimaryKey; if (gOGroup.ObjectsDataSet == null) { var dataset = ApplicationSettings.Container.Resolve<IObjectsDataSet>(); dataset.AddObject(gOGroup); } if(gOGroup.ObjectsDataSet == null) { _logEngine.LogError("Unable to set a dataset to the Entity GOGroup", "Unable to set a dataset to the entity. Container may not be initialized", "GOGroupDataObject", null); throw new PulpException("Unexpected Error : Unable to set a dataset to the entity : GOGroup"); } if(gOGroup.InternalObjectId == null) { _logEngine.LogError("Unable to construct an object without InternalObjectId in GOGroupDataObject", "The Object you are trying to construct doesn't have an InternalObjectId", "GOGroupDataObject", null); throw new PulpException("Unexpected Error : Unable to construct an object without InternalObjectId in GOGroupDataObject"); } this.InternalObjectId = (int) gOGroup.InternalObjectId; this.ObjectsDataSet = includeDirtyObjectsOnly ? gOGroup.ObjectsDataSet.CloneDirtyObjects() : gOGroup.ObjectsDataSet; }
/// <summary> /// Copy Constructor /// </summary> public GOGroupDataObject(GOGroupDataObject template, bool deepCopy) { this.SetDescriptionValue(template.Description, false, false); this.SetDisplayNameValue(template.DisplayName, false, false); this.SetIsSpecialGroupValue(template.IsSpecialGroup, false, false); this.SetNameValue(template.Name, false, false); this.SetSpecialGroupValue(template.SpecialGroup, false, false); this.SetIsNewValue(template.IsNew, false, false); if (deepCopy) { this.ObjectsDataSet = template.ObjectsDataSet.Clone(); // Remove the template object from the dataset this.ObjectsDataSet.RemoveObject(template); // And Replace by the one we're currently constructing this.ObjectsDataSet.AddObject(this); } UpdateDisplayNameValue(); UpdateDescriptionValue(); UpdateNameValue(); this.SetIsDirtyValue(template.IsDirty, false, false); this.SetIsMarkedForDeletionValue(template.IsMarkedForDeletion, false, false); }
protected void SetProperties(GOGroupDataObject x) { x.SetNameValue(Name, false, false); x.SetDisplayNameValue(DisplayName, false, false); x.SetDescriptionValue(Description, false, false); x.SetIsSpecialGroupValue(IsSpecialGroup, false, false); x.SetSpecialGroupValue((GOSpecialGroupsEnum)SpecialGroup, false, false); }
public IEnumerable <GOGroupRoleDataObject> GetGroupRoleItemsForGroup(GOGroupDataObject groupInstance) { if (groupInstance.IsNew) { return(GOGroupRoleObjects.Where(o => o.Value._group_NewObjectId != null && o.Value._group_NewObjectId == groupInstance.InternalObjectId).Select(o => o.Value)); } if (Group_FKIndex.ContainsKey(groupInstance.Name)) { return(Group_FKIndex[groupInstance.Name].Where(e => GOGroupRoleObjects.ContainsKey(e)).Select(e => GOGroupRoleObjects[e])); } return(new DataObjectCollection <GOGroupRoleDataObject>()); }
protected void SetRelations(GOGroupDataObject x) { var prefetches = PrefetchAssociations.Get("GOGroup", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters); if (prefetches.Contains("UserGroupItems") && this.UserGroupItems.Count > 0) { var iter = this.UserGroupItems.GetEnumerator(); while (iter.MoveNext()) { var userGroupItemsItem = x.ObjectsDataSet.GetObject(new GOUserGroupDataObject((System.String)iter.Current.GOGroupName, (System.Guid)iter.Current.GOUserId) { IsNew = false }); if (userGroupItemsItem == null) { userGroupItemsItem = iter.Current.ToDataObject(x.ObjectsDataSet) as GOUserGroupDataObject; } x.UserGroupItems.Add(userGroupItemsItem); } } if (prefetches.Contains("GroupRoleItems") && this.GroupRoleItems.Count > 0) { var iter = this.GroupRoleItems.GetEnumerator(); while (iter.MoveNext()) { var groupRoleItemsItem = x.ObjectsDataSet.GetObject(new GOGroupRoleDataObject((System.String)iter.Current.GOGroupName, (System.String)iter.Current.GORoleName) { IsNew = false }); if (groupRoleItemsItem == null) { groupRoleItemsItem = iter.Current.ToDataObject(x.ObjectsDataSet) as GOGroupRoleDataObject; } x.GroupRoleItems.Add(groupRoleItemsItem); } } }
/// /// Bridge to DataObject /// public virtual IDataObject ToDataObject(IObjectsDataSet dataset) { var session = NHibernateSessionController.GetCurrentSession(); session.Evict(this); var x = new GOGroupDataObject(); SetProperties(x); x.IsDirty = x.IsNew = x.IsMarkedForDeletion = false; x.ObjectsDataSet = dataset; x.ObjectsDataSet.AddObjectIfDoesNotExist(x); // Deep-map prefetch relations if (PrefetchAssociations.HasPrefetchForEntity("GOGroup", ApplicationSettings.Resolve <IDataProviderTransaction>()?.Parameters)) { SetRelations(x); } return(x); }
public virtual void SetGroupValue(GOGroupDataObject valueToSet, bool notifyChanges, bool dirtyHandlerOn) { GOGroupDataObject existing_group = null; if (!(this.GOGroupName == null || ObjectsDataSet == null)) { var key = this._group_NewObjectId == null ? new GOGroupDataObject(this.GOGroupName) { IsNew = false } : new GOGroupDataObject() { IsNew = true, InternalObjectId = this._group_NewObjectId }; existing_group = (GOGroupDataObject)ObjectsDataSet.GetObject(key); } if (ReferenceEquals(existing_group, valueToSet)) { return; } // Give opportunity to change value before set OnBeforeSetRelationField("Group", valueToSet); // Setting the navigator desync the FK. The FK should be resync if (!ReferenceEquals(null, valueToSet)) { if (ObjectsDataSet == null) { _logEngine.LogError("Unable to set Relation Field", "Unable to set Relation Field, your entity doesn't have a DataSet.", "GOGroupRoleDataObject", null); throw new PulpException("Unable to set Relation fields, your entity doesn't have a DataSet"); } ObjectsDataSet.AddObjectIfDoesNotExist(valueToSet); if (valueToSet.IsNew) { if (_group_NewObjectId != valueToSet.InternalObjectId) { _group_NewObjectId = valueToSet.InternalObjectId; _gOGroupName = valueToSet.Name; OnPropertyChanged("GOGroupName", notifyChanges, dirtyHandlerOn); } } else { if (_gOGroupName != valueToSet.Name) { _group_NewObjectId = null; _gOGroupName = valueToSet.Name; OnPropertyChanged("GOGroupName", notifyChanges, dirtyHandlerOn); } } } else { _gOGroupName = null; OnPropertyChanged("GOGroupName", notifyChanges, dirtyHandlerOn); } if (!ReferenceEquals(existing_group, valueToSet)) { OnPropertyChanged("Group", notifyChanges, dirtyHandlerOn); } }
public virtual void SetGroupValue(GOGroupDataObject valueToSet) { SetGroupValue(valueToSet, true, true); }
public GOGroupContainer(GOGroupDataObject gOGroup, bool includeDirtyObjectsOnly) { Construct(gOGroup, includeDirtyObjectsOnly); }
public GOGroupContainer(GOGroupDataObject gOGroup) { Construct(gOGroup, false); }