Exemplo n.º 1
0
        /// <summary>
        /// Execute the creation of a <see cref="ModellingAnnotationItem"/>
        /// </summary>
        protected void ExecuteCreateEngineeringModelDataNote(EngineeringModelDataNote engineeringModelDataNote, Participant participant)
        {
            if (this.SelectedThing == null)
            {
                return;
            }

            engineeringModelDataNote.Author = participant;

            var annotatedThing = new ModellingThingReference(this.SelectedThing.Thing);

            engineeringModelDataNote.PrimaryAnnotatedThing = annotatedThing;
            engineeringModelDataNote.RelatedThing.Add(annotatedThing);

            var transactionContext = TransactionContextResolver.ResolveContext(this.Thing);
            var model = this.Thing.TopContainer as EngineeringModel;

            if (model == null)
            {
                throw new InvalidOperationException("A EngineeringModelDataNote item can only be created in the context of a Engineering Model.");
            }

            var containerClone = model.Clone(false);
            var transaction    = new ThingTransaction(transactionContext, containerClone);

            this.ThingDialogNavigationService.Navigate(engineeringModelDataNote, transaction, this.Session, true, ThingDialogKind.Create, this.ThingDialogNavigationService, containerClone);
        }
        /// <summary>
        /// Serialize the <see cref="EngineeringModelDataNote"/>
        /// </summary>
        /// <param name="engineeringModelDataNote">The <see cref="EngineeringModelDataNote"/> to serialize</param>
        /// <returns>The <see cref="JObject"/></returns>
        private JObject Serialize(EngineeringModelDataNote engineeringModelDataNote)
        {
            var jsonObject = new JObject();

            jsonObject.Add("author", this.PropertySerializerMap["author"](engineeringModelDataNote.Author));
            jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), engineeringModelDataNote.ClassKind)));
            jsonObject.Add("content", this.PropertySerializerMap["content"](engineeringModelDataNote.Content));
            jsonObject.Add("createdOn", this.PropertySerializerMap["createdOn"](engineeringModelDataNote.CreatedOn));
            jsonObject.Add("discussion", this.PropertySerializerMap["discussion"](engineeringModelDataNote.Discussion.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](engineeringModelDataNote.ExcludedDomain.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](engineeringModelDataNote.ExcludedPerson.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("iid", this.PropertySerializerMap["iid"](engineeringModelDataNote.Iid));
            jsonObject.Add("languageCode", this.PropertySerializerMap["languageCode"](engineeringModelDataNote.LanguageCode));
            jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](engineeringModelDataNote.ModifiedOn));
            jsonObject.Add("primaryAnnotatedThing", this.PropertySerializerMap["primaryAnnotatedThing"](engineeringModelDataNote.PrimaryAnnotatedThing));
            jsonObject.Add("relatedThing", this.PropertySerializerMap["relatedThing"](engineeringModelDataNote.RelatedThing.OrderBy(x => x, this.guidComparer)));
            jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](engineeringModelDataNote.RevisionNumber));
            jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](engineeringModelDataNote.ThingPreference));
            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="engineeringModelDataNote">
        /// The engineeringModelDataNote instance to persist.
        /// </param>
        /// <returns>
        /// True if the persistence was successful.
        /// </returns>
        private bool CreateContainment(NpgsqlTransaction transaction, string partition, EngineeringModelDataNote engineeringModelDataNote)
        {
            var results = new List <bool>();

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

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

            return(results.All(x => x));
        }
 /// <summary>
 /// Add an Generic Note row view model to the list of <see cref="GenericNote"/>
 /// </summary>
 /// <param name="genericNote">
 /// The <see cref="GenericNote"/> that is to be added
 /// </param>
 private EngineeringModelDataNoteRowViewModel AddGenericNoteRowViewModel(EngineeringModelDataNote genericNote)
 {
     return(new EngineeringModelDataNoteRowViewModel(genericNote, this.Session, this));
 }