Exemplo n.º 1
0
        /// <summary>
        /// Serialize the <see cref="ContractChangeNotice"/>
        /// </summary>
        /// <param name="contractChangeNotice">The <see cref="ContractChangeNotice"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(ContractChangeNotice contractChangeNotice)
        {
            var jsonObject = new JObject();

            jsonObject.Add("approvedBy", this.PropertySerializerMap["approvedBy"](contractChangeNotice.ApprovedBy.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("author", this.PropertySerializerMap["author"](contractChangeNotice.Author));
            jsonObject.Add("category", this.PropertySerializerMap["category"](contractChangeNotice.Category.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("changeProposal", this.PropertySerializerMap["changeProposal"](contractChangeNotice.ChangeProposal));
            jsonObject.Add("classification", this.PropertySerializerMap["classification"](Enum.GetName(typeof(CDP4Common.ReportingData.AnnotationClassificationKind), contractChangeNotice.Classification)));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), contractChangeNotice.ClassKind)));
            jsonObject.Add("content", this.PropertySerializerMap["content"](contractChangeNotice.Content));
            jsonObject.Add("createdOn", this.PropertySerializerMap["createdOn"](contractChangeNotice.CreatedOn));
            jsonObject.Add("discussion", this.PropertySerializerMap["discussion"](contractChangeNotice.Discussion.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](contractChangeNotice.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](contractChangeNotice.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](contractChangeNotice.Iid));
            jsonObject.Add("languageCode", this.PropertySerializerMap["languageCode"](contractChangeNotice.LanguageCode));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](contractChangeNotice.ModifiedOn));
            jsonObject.Add("owner", this.PropertySerializerMap["owner"](contractChangeNotice.Owner));
            jsonObject.Add("primaryAnnotatedThing", this.PropertySerializerMap["primaryAnnotatedThing"](contractChangeNotice.PrimaryAnnotatedThing));
            jsonObject.Add("relatedThing", this.PropertySerializerMap["relatedThing"](contractChangeNotice.RelatedThing.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](contractChangeNotice.RevisionNumber));
            jsonObject.Add("shortName", this.PropertySerializerMap["shortName"](contractChangeNotice.ShortName));
            jsonObject.Add("sourceAnnotation", this.PropertySerializerMap["sourceAnnotation"](contractChangeNotice.SourceAnnotation.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("status", this.PropertySerializerMap["status"](Enum.GetName(typeof(CDP4Common.ReportingData.AnnotationStatusKind), contractChangeNotice.Status)));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](contractChangeNotice.ThingPreference));
            jsonObject.Add("title", this.PropertySerializerMap["title"](contractChangeNotice.Title));
            return(jsonObject);
        }
        /// <summary>
        /// Persist the <see cref="ContractChangeNotice"/> 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="contractChangeNotice">
        /// The <see cref="ContractChangeNotice"/> instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool UpsertContainment(NpgsqlTransaction transaction, string partition, ContractChangeNotice contractChangeNotice)
        {
            var results = new List <bool>();

            foreach (var approvedBy in this.ResolveFromRequestCache(contractChangeNotice.ApprovedBy))
            {
                results.Add(this.ApprovedByService.UpsertConcept(transaction, partition, approvedBy, contractChangeNotice));
            }

            foreach (var discussion in this.ResolveFromRequestCache(contractChangeNotice.Discussion))
            {
                results.Add(this.DiscussionService.UpsertConcept(transaction, partition, discussion, contractChangeNotice));
            }

            foreach (var relatedThing in this.ResolveFromRequestCache(contractChangeNotice.RelatedThing))
            {
                results.Add(this.RelatedThingService.UpsertConcept(transaction, partition, relatedThing, contractChangeNotice));
            }

            return(results.All(x => x));
        }
Exemplo n.º 3
0
        /// <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="contractChangeNotice">
        /// The contractChangeNotice instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool CreateContainment(NpgsqlTransaction transaction, string partition, ContractChangeNotice contractChangeNotice)
        {
            var results = new List <bool>();

            foreach (var relatedThing in this.ResolveFromRequestCache(contractChangeNotice.RelatedThing))
            {
                results.Add(this.ModellingThingReferenceService.CreateConcept(transaction, partition, relatedThing, contractChangeNotice));
            }

            foreach (var discussion in this.ResolveFromRequestCache(contractChangeNotice.Discussion))
            {
                results.Add(this.EngineeringModelDataDiscussionItemService.CreateConcept(transaction, partition, discussion, contractChangeNotice));
            }

            foreach (var approvedBy in this.ResolveFromRequestCache(contractChangeNotice.ApprovedBy))
            {
                results.Add(this.ApprovalService.CreateConcept(transaction, partition, approvedBy, contractChangeNotice));
            }

            return(results.All(x => x));
        }