/// <summary> /// Execute the creation of a <see cref="ModellingAnnotationItem"/> /// </summary> protected void ExecuteCreateModellingAnnotation(ModellingAnnotationItem annotation, Participant participant, DomainOfExpertise owner) { if (this.SelectedThing == null) { return; } annotation.Owner = owner; annotation.Author = participant; annotation.Status = AnnotationStatusKind.OPEN; var annotatedThing = new ModellingThingReference(this.SelectedThing.Thing); annotation.RelatedThing.Add(annotatedThing); annotation.PrimaryAnnotatedThing = annotatedThing; var transactionContext = TransactionContextResolver.ResolveContext(this.Thing); var model = this.Thing.TopContainer as EngineeringModel; if (model == null) { throw new InvalidOperationException("A modelling annotation 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(annotation, transaction, this.Session, true, ThingDialogKind.Create, this.ThingDialogNavigationService, containerClone); }
/// <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); }
public void Setup() { this.session = new Mock <ISession>(); this.permissionService = new Mock <IPermissionService>(); this.assembler = new Assembler(this.uri); this.session.Setup(x => x.Assembler).Returns(this.assembler); this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri); this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri) { Surname = "surname", GivenName = "given", ShortName = "short" }; this.modelsetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri); this.iterationsetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri) { IterationNumber = 1 }; this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri) { Person = this.person }; this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri); this.model = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri) { EngineeringModelSetup = this.modelsetup }; this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri) { IterationSetup = this.iterationsetup }; this.ed = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri); this.rid = new ReviewItemDiscrepancy(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reference = new ModellingThingReference(Guid.NewGuid(), this.assembler.Cache, this.uri); this.reference.ReferencedThing = this.ed; this.rid.PrimaryAnnotatedThing = this.reference; this.sitedir.Person.Add(this.person); this.sitedir.Domain.Add(this.domain); this.sitedir.Model.Add(this.modelsetup); this.modelsetup.Participant.Add(this.participant); this.model.Iteration.Add(this.iteration); this.iteration.Element.Add(this.ed); this.model.ModellingAnnotation.Add(this.rid); this.rid.RelatedThing.Add(this.reference); this.session.Setup(x => x.ActivePerson).Returns(this.person); this.session.Setup(x => x.OpenIterations). Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > { { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) } }); this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object); this.session.Setup(x => x.Write(It.IsAny <OperationContainer>())).Returns(() => null); this.assembler.Cache.TryAdd(new CacheKey(this.model.Iid, null), new Lazy <Thing>(() => this.model)); this.assembler.Cache.TryAdd(new CacheKey(this.rid.Iid, null), new Lazy <Thing>(() => this.rid)); }
/// <summary> /// Serialize the <see cref="ModellingThingReference"/> /// </summary> /// <param name="modellingThingReference">The <see cref="ModellingThingReference"/> to serialize</param> /// <returns>The <see cref="JObject"/></returns> private JObject Serialize(ModellingThingReference modellingThingReference) { var jsonObject = new JObject(); jsonObject.Add("classKind", this.PropertySerializerMap["classKind"](Enum.GetName(typeof(CDP4Common.CommonData.ClassKind), modellingThingReference.ClassKind))); jsonObject.Add("excludedDomain", this.PropertySerializerMap["excludedDomain"](modellingThingReference.ExcludedDomain.OrderBy(x => x, this.guidComparer))); jsonObject.Add("excludedPerson", this.PropertySerializerMap["excludedPerson"](modellingThingReference.ExcludedPerson.OrderBy(x => x, this.guidComparer))); jsonObject.Add("iid", this.PropertySerializerMap["iid"](modellingThingReference.Iid)); jsonObject.Add("modifiedOn", this.PropertySerializerMap["modifiedOn"](modellingThingReference.ModifiedOn)); jsonObject.Add("referencedRevisionNumber", this.PropertySerializerMap["referencedRevisionNumber"](modellingThingReference.ReferencedRevisionNumber)); jsonObject.Add("referencedThing", this.PropertySerializerMap["referencedThing"](modellingThingReference.ReferencedThing)); jsonObject.Add("revisionNumber", this.PropertySerializerMap["revisionNumber"](modellingThingReference.RevisionNumber)); jsonObject.Add("thingPreference", this.PropertySerializerMap["thingPreference"](modellingThingReference.ThingPreference)); return(jsonObject); }
/// <summary> /// Updates the properties of this row /// </summary> private void UpdateProperties() { this.ModifiedOn = this.Thing.ModifiedOn; this.Author = this.Thing.Author; this.PrimaryAnnotatedThing = this.Thing.PrimaryAnnotatedThing; }
/// <summary> /// Add an Related Thing row view model to the list of <see cref="RelatedThing"/> /// </summary> /// <param name="relatedThing"> /// The <see cref="RelatedThing"/> that is to be added /// </param> private ModellingThingReferenceRowViewModel AddRelatedThingRowViewModel(ModellingThingReference relatedThing) { return(new ModellingThingReferenceRowViewModel(relatedThing, this.Session, this)); }