public virtual void Construct(PlaceDataObject place, bool includeDirtyObjectsOnly) { if (place == null) { return; } this.PrimaryKey = place.PrimaryKey; if (place.ObjectsDataSet == null) { var dataset = ApplicationSettings.Container.Resolve <IObjectsDataSet>(); dataset.AddObject(place); } if (place.ObjectsDataSet == null) { _logEngine.LogError("Unable to set a dataset to the Entity Place", "Unable to set a dataset to the entity. Container may not be initialized", "PlaceDataObject", null); throw new PulpException("Unexpected Error : Unable to set a dataset to the entity : Place"); } if (place.InternalObjectId == null) { _logEngine.LogError("Unable to construct an object without InternalObjectId in PlaceDataObject", "The Object you are trying to construct doesn't have an InternalObjectId", "PlaceDataObject", null); throw new PulpException("Unexpected Error : Unable to construct an object without InternalObjectId in PlaceDataObject"); } this.InternalObjectId = (int)place.InternalObjectId; this.ObjectsDataSet = includeDirtyObjectsOnly ? place.ObjectsDataSet.CloneDirtyObjects() : place.ObjectsDataSet; }
public IEnumerable<VisitedPlaceDataObject> GetVisitedPlaceItemsForPlace(PlaceDataObject placeInstance) { if (placeInstance.IsNew) { return VisitedPlaceObjects.Where(o => o.Value._place_NewObjectId != null && o.Value._place_NewObjectId == placeInstance.InternalObjectId).Select(o => o.Value); } if (Place_FKIndex.ContainsKey(placeInstance.URI)) { return Place_FKIndex[placeInstance.URI].Where(e => VisitedPlaceObjects.ContainsKey(e)).Select(e => VisitedPlaceObjects[e]); } return new DataObjectCollection<VisitedPlaceDataObject>(); }
/// <summary> /// Copy Constructor /// </summary> public PlaceDataObject(PlaceDataObject template, bool deepCopy) { this.SetAbstractValue(template.Abstract, false, false); this.SetNameValue(template.Name, false, false); this.SetURIValue(template.URI, 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); } this.SetIsDirtyValue(template.IsDirty, false, false); this.SetIsMarkedForDeletionValue(template.IsMarkedForDeletion, false, false); }
public virtual void SetPlaceValue(PlaceDataObject valueToSet, bool notifyChanges, bool dirtyHandlerOn) { PlaceDataObject existing_place = null; if (!(this.PlaceURI == null || ObjectsDataSet == null)) { var key = this._place_NewObjectId == null ? new PlaceDataObject(this.PlaceURI) { IsNew = false } : new PlaceDataObject() { IsNew = true, InternalObjectId = this._place_NewObjectId }; existing_place = (PlaceDataObject)ObjectsDataSet.GetObject(key); } if (ReferenceEquals(existing_place, valueToSet)) { return; } // Give opportunity to change value before set OnBeforeSetRelationField("Place", 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.", "PlaceToLocationDataObject", null); throw new PulpException("Unable to set Relation fields, your entity doesn't have a DataSet"); } ObjectsDataSet.AddObjectIfDoesNotExist(valueToSet); if (valueToSet.IsNew) { if (_place_NewObjectId != valueToSet.InternalObjectId) { _place_NewObjectId = valueToSet.InternalObjectId; _placeURI = valueToSet.URI; OnPropertyChanged("PlaceURI", notifyChanges, dirtyHandlerOn); } } else { if (_placeURI != valueToSet.URI) { _place_NewObjectId = null; _placeURI = valueToSet.URI; OnPropertyChanged("PlaceURI", notifyChanges, dirtyHandlerOn); } } } else { _placeURI = null; OnPropertyChanged("PlaceURI", notifyChanges, dirtyHandlerOn); } if (!ReferenceEquals(existing_place, valueToSet)) { OnPropertyChanged("Place", notifyChanges, dirtyHandlerOn); } }
public virtual void SetPlaceValue(PlaceDataObject valueToSet) { SetPlaceValue(valueToSet, true, true); }
public PlaceContainer(PlaceDataObject place, bool includeDirtyObjectsOnly) { Construct(place, includeDirtyObjectsOnly); }
public PlaceContainer(PlaceDataObject place) { Construct(place, false); }
public IEnumerable <PlaceToLocationDataObject> GetPlaceToLocationItemsForPlace(PlaceDataObject placeInstance) { if (placeInstance.IsNew) { return(PlaceToLocationObjects.Where(o => o.Value._place_NewObjectId != null && o.Value._place_NewObjectId == placeInstance.InternalObjectId).Select(o => o.Value)); } if (Place_FKIndex.ContainsKey(placeInstance.URI)) { return(Place_FKIndex[placeInstance.URI].Where(e => PlaceToLocationObjects.ContainsKey(e)).Select(e => PlaceToLocationObjects[e])); } return(new DataObjectCollection <PlaceToLocationDataObject>()); }