/// <summary> /// Serialize the <see cref="ChangeProposal"/> /// </summary> /// <param name="changeProposal">The <see cref="ChangeProposal"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(ChangeProposal changeProposal) { var jsonObject = new JObject(); jsonObject.Add("approvedBy", this.PropertySerializerMap["approvedBy"](changeProposal.ApprovedBy.OrderBy(x => x, this.guidComparer))); jsonObject.Add("author", this.PropertySerializerMap["author"](changeProposal.Author)); jsonObject.Add("category", this.PropertySerializerMap["category"](changeProposal.Category.OrderBy(x => x, this.guidComparer))); jsonObject.Add("changeRequest", this.PropertySerializerMap["changeRequest"](changeProposal.ChangeRequest)); jsonObject.Add("classification", this.PropertySerializerMap["classification"](Enum.GetName(typeof(CDP4Common.ReportingData.AnnotationClassificationKind), changeProposal.Classification))); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), changeProposal.ClassKind))); jsonObject.Add("content", this.PropertySerializerMap["content"](changeProposal.Content)); jsonObject.Add("createdOn", this.PropertySerializerMap["createdOn"](changeProposal.CreatedOn)); jsonObject.Add("discussion", this.PropertySerializerMap["discussion"](changeProposal.Discussion.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](changeProposal.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](changeProposal.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](changeProposal.Iid)); jsonObject.Add("languageCode", this.PropertySerializerMap["languageCode"](changeProposal.LanguageCode)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](changeProposal.ModifiedOn)); jsonObject.Add("owner", this.PropertySerializerMap["owner"](changeProposal.Owner)); jsonObject.Add("primaryAnnotatedThing", this.PropertySerializerMap["primaryAnnotatedThing"](changeProposal.PrimaryAnnotatedThing)); jsonObject.Add("relatedThing", this.PropertySerializerMap["relatedThing"](changeProposal.RelatedThing.OrderBy(x => x, this.guidComparer))); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](changeProposal.RevisionNumber)); jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](changeProposal.ShortName)); jsonObject.Add("sourceAnnotation", this.PropertySerializerMap["sourceAnnotation"](changeProposal.SourceAnnotation.OrderBy(x => x, this.guidComparer))); jsonObject.Add("status", this.PropertySerializerMap["status"](Enum.GetName(typeof(CDP4Common.ReportingData.AnnotationStatusKind), changeProposal.Status))); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](changeProposal.ThingPreference)); jsonObject.Add("title", this.PropertySerializerMap["title"](changeProposal.Title)); return(jsonObject); }
/// <summary> /// Persist the DTO composition to the ORM layer. /// </summary> /// <param name="transaction"> /// The transaction object. /// </param> /// <param name="partition"> /// The database partition (schema) where the requested resource will be stored. /// </param> /// <param name="changeProposal"> /// The changeProposal instance to persist. /// </param> /// <returns> /// True if the persistence was successful. /// </returns> private bool CreateContainment(NpgsqlTransaction transaction, string partition, ChangeProposal changeProposal) { var results = new List <bool>(); foreach (var relatedThing in this.ResolveFromRequestCache(changeProposal.RelatedThing)) { results.Add(this.ModellingThingReferenceService.CreateConcept(transaction, partition, relatedThing, changeProposal)); } foreach (var discussion in this.ResolveFromRequestCache(changeProposal.Discussion)) { results.Add(this.EngineeringModelDataDiscussionItemService.CreateConcept(transaction, partition, discussion, changeProposal)); } foreach (var approvedBy in this.ResolveFromRequestCache(changeProposal.ApprovedBy)) { results.Add(this.ApprovalService.CreateConcept(transaction, partition, approvedBy, changeProposal)); } return(results.All(x => x)); }
/// <summary> /// Persist the <see cref="ChangeProposal"/> containment tree to the ORM layer. Update if it already exists. /// This is typically used during the import of existing data to the Database. /// </summary> /// <param name="transaction"> /// The current <see cref="NpgsqlTransaction"/> to the database. /// </param> /// <param name="partition"> /// The database partition (schema) where the requested resource will be stored. /// </param> /// <param name="changeProposal"> /// The <see cref="ChangeProposal"/> instance to persist. /// </param> /// <returns> /// True if the persistence was successful. /// </returns> private bool UpsertContainment(NpgsqlTransaction transaction, string partition, ChangeProposal changeProposal) { var results = new List <bool>(); foreach (var approvedBy in this.ResolveFromRequestCache(changeProposal.ApprovedBy)) { results.Add(this.ApprovedByService.UpsertConcept(transaction, partition, approvedBy, changeProposal)); } foreach (var discussion in this.ResolveFromRequestCache(changeProposal.Discussion)) { results.Add(this.DiscussionService.UpsertConcept(transaction, partition, discussion, changeProposal)); } foreach (var relatedThing in this.ResolveFromRequestCache(changeProposal.RelatedThing)) { results.Add(this.RelatedThingService.UpsertConcept(transaction, partition, relatedThing, changeProposal)); } return(results.All(x => x)); }
/// <summary> /// Updates the properties of this row /// </summary> private void UpdateProperties() { this.ModifiedOn = this.Thing.ModifiedOn; this.ChangeProposal = this.Thing.ChangeProposal; }