Exemple #1
0
        public void Setup()
        {
            this.cache = new List <Thing>();
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.session   = new Mock <ISession>();
            this.uri       = new Uri("http://test.com");
            this.assembler = new Assembler(this.uri);
            this.panelNavigationService = new Mock <IPanelNavigationService>();

            this.sitedir = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.pt      = new TextParameterType(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.person = new Person(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.sitedir.Person.Add(this.person);
            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "TestDoE"
            };
            this.sitedir.Domain.Add(this.domain);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.model     = new EngineeringModel(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iteration = new Iteration(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.elementDef = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name      = "1",
                Owner     = this.domain,
                Container = this.iteration
            };

            this.participant = new Participant(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Person = this.person
            };
            this.participant.Domain.Add(this.domain);

            var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Container     = this.elementDef,
                ParameterType = this.pt,
                Owner         = this.elementDef.Owner
            };

            var parameterOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Owner = this.domain, Parameter = parameter
            };
            var elementUsage = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ElementDefinition = this.elementDef
            };

            elementUsage.ParameterOverride.Add(parameterOverride);
            this.elementDef.ContainedElement.Add(elementUsage);

            this.model.Iteration.Add(this.iteration);

            var iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            this.iteration.IterationSetup = iterationSetup;

            this.engineeringModelSetup = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name = "ModelSetup"
            };
            this.engineeringModelSetup.IterationSetup.Add(iterationSetup);

            this.srdl = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.srdl.ParameterType.Add(this.pt);

            this.mrdl = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };

            this.engineeringModelSetup.RequiredRdl.Add(this.mrdl);

            this.model.EngineeringModelSetup = this.engineeringModelSetup;
            this.model.EngineeringModelSetup.Participant.Add(this.participant);
            this.permissionService = new Mock <IPermissionService>();

            this.permissionService.Setup(x => x.CanRead(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <Thing>())).Returns(true);
            this.permissionService.Setup(x => x.CanWrite(It.IsAny <ClassKind>(), It.IsAny <Thing>())).Returns(true);
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> > {
                { this.iteration, new Tuple <DomainOfExpertise, Participant>(this.domain, this.participant) }
            });

            this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.assembler.Cache.TryAdd(new CacheKey(this.model.Iid, null), new Lazy <Thing>(() => this.model));

            this.session.Setup(x => x.Assembler).Returns(this.assembler);
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
        }
Exemple #2
0
 public static bool IsChoice(this ElementDefinition definition)
 {
     return(definition.Type.Where(tr => tr.Code != null).Distinct().Count() > 1);
 }
 /// <summary>
 /// Annotate the specified <see cref="ElementDefinition"/> instance in the <see cref="StructureDefinition.Differential"/> component
 /// with a reference to the associated <see cref="ElementDefinition"/> instance in the <see cref="StructureDefinition.Snapshot"/> component.
 /// </summary>
 /// <param name="diffElemDef"></param>
 /// <param name="snapElemDef"></param>
 internal static void SetSnapshotElementAnnotation(this ElementDefinition diffElemDef, ElementDefinition snapElemDef)
 {
     diffElemDef?.AddAnnotation(new SnapshotElementDefinitionAnnotation(snapElemDef));
 }
 /// <summary>Remove all <see cref="SnapshotElementDefinitionAnnotation"/> instances from the specified <see cref="ElementDefinition"/>.</summary>
 internal static void RemoveSnapshotElementAnnotations(this ElementDefinition ed)
 {
     ed?.RemoveAnnotations <SnapshotElementDefinitionAnnotation>();
 }
        internal OperationOutcome.IssueComponent addIssueInvalidSliceNameOnRootElement(ElementDefinition elementDef, StructureDefinition profile)
        {
            Debug.Assert(!string.IsNullOrEmpty(elementDef.Name));
            Debug.Assert(elementDef.IsRootElement());
            var location = elementDef.Path;

            return(addIssue(
                       PROFILE_ELEMENTDEF_INVALID_SLICENAME_ON_ROOT.ToIssueComponent(
                           $"Element {location} has an invalid non-empty sliceName '{elementDef.Name}'. Root element definitions cannot introduce slice names.",
                           location
                           ),
                       profile.Url
                       ));
        }
        internal static OperationOutcome.IssueComponent CreateIssueInvalidChoiceConstraint(ElementDefinition elementDef)
        {
            var location = elementDef.Path;

            return(PROFILE_ELEMENTDEF_INVALID_CHOICE_CONSTRAINT.ToIssueComponent(
                       $"Differential specifies constraint on choice element {location} without using type slice.",
                       location
                       ));
        }
Exemple #7
0
        public void Setup()
        {
            this.permissionService            = new Mock <IPermissionService>();
            this.panelNavigationService       = new Mock <IPanelNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.session = new Mock <ISession>();

            this.domain = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain", ShortName = "dom"
            };
            this.siteDir        = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.model          = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.modelSetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iteration      = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.participant    = new Participant(Guid.NewGuid(), this.cache, this.uri);
            this.option         = new Option(Guid.NewGuid(), this.cache, this.uri);
            this.elementDef     = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };
            this.elementDef3 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };

            this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain, Name = "Element definition 1", ShortName = "ED1"
            };
            this.elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ElementDefinition = this.elementDef2, Owner = this.domain, Name = "Element usage 1", ShortName = "EU1"
            };

            this.valueSet           = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri);
            this.valueSet.Published = new ValueArray <string>(new List <string> {
                "1"
            });
            this.valueSet.Manual = new ValueArray <string>(new List <string> {
                "1"
            });
            this.valueSet.ValueSwitch = ParameterSwitchKind.MANUAL;

            this.valueSetOverride           = new ParameterOverrideValueSet(Guid.NewGuid(), this.cache, this.uri);
            this.valueSetOverride.Published = new ValueArray <string>(new List <string> {
                "1"
            });
            this.valueSetOverride.Manual = new ValueArray <string>(new List <string> {
                "1"
            });
            this.valueSetOverride.ValueSwitch = ParameterSwitchKind.MANUAL;

            this.siteDir.Person.Add(this.person);
            this.siteDir.Model.Add(this.modelSetup);
            this.modelSetup.IterationSetup.Add(this.iterationSetup);
            this.modelSetup.Participant.Add(this.participant);
            this.participant.Person = this.person;

            this.model.Iteration.Add(this.iteration);
            this.model.EngineeringModelSetup = this.modelSetup;
            this.iteration.IterationSetup    = this.iterationSetup;
            this.iteration.Option.Add(this.option);
            this.iteration.TopElement = this.elementDef;
            this.iteration.Element.Add(this.elementDef);
            this.iteration.Element.Add(this.elementDef3);
            this.iteration.Element.Add(this.elementDef2);
            this.elementDef.ContainedElement.Add(this.elementUsage);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.QuerySelectedDomainOfExpertise(this.iteration)).Returns(this.domain);
        }
        internal static OperationOutcome.IssueComponent CreateIssueInvalidExtensionSlicingDiscriminator(ElementDefinition elementDef)
        {
            var location        = elementDef.Path;
            var discriminators  = elementDef.Slicing?.Discriminator;
            var sDiscriminators = discriminators != null && discriminators.Any() ? string.Join("|", elementDef.Slicing?.Discriminator) : "(missing)";

            return(PROFILE_ELEMENTDEF_INVALID_EXTENSION_DISCRIMINATOR.ToIssueComponent(
                       $"Extension element {location} defines an invalid slicing discriminator: '{sDiscriminators}'. Extensions are always sliced on 'url'.",
                       location
                       ));
        }
Exemple #9
0
        /// <summary>
        /// Creates The <see cref="NestedElement"/> and contained <see cref="NestedParameter"/> that represents the <paramref name="rootElement"/>
        /// </summary>
        /// <param name="rootElement">
        /// The <see cref="ElementDefinition"/> that is the root of the <see cref="NestedElement"/> tree.
        /// </param>
        /// <param name="domainOfExpertise">
        /// The <see cref="DomainOfExpertise"/> for which the <see cref="NestedElement"/> tree needs to be generated. Only the <see cref="Parameter"/>s, <see cref="ParameterOverride"/>s and
        /// <see cref="ParameterSubscription"/>s that are owned by the <see cref="DomainOfExpertise"/> will be taken into account when generating <see cref="NestedParameter"/>s
        /// </param>
        /// <param name="option">
        /// The <see cref="Option"/> for which the <see cref="NestedElement"/> tree is created. When the <see cref="Option"/>
        /// is null then none of the <see cref="ElementUsage"/>s are filtered.
        /// </param>
        /// <param name="updateOption">
        /// Value indicating whether the <see cref="Option"/> shall be updated with the created <see cref="NestedElement"/>s or not.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{NestedElement}"/> that have been created.
        /// </returns>
        private NestedElement CreateNestedElementAndNestedParametersForRootElement(ElementDefinition rootElement, DomainOfExpertise domainOfExpertise, Option option, bool updateOption)
        {
            var nestedElement = new NestedElement(Guid.NewGuid(), rootElement.Cache, rootElement.IDalUri)
            {
                RootElement   = rootElement,
                IsVolatile    = true,
                IsRootElement = true
            };

            if (updateOption)
            {
                option.NestedElement.Add(nestedElement);
            }
            else
            {
                nestedElement.Container = option;
            }

            foreach (var parameter in rootElement.Parameter)
            {
                var compoundParameterType = parameter.ParameterType as CompoundParameterType;

                if (domainOfExpertise == null || parameter.Owner == domainOfExpertise)
                {
                    var valueSets = parameter.IsOptionDependent ? parameter.ValueSet.Where(vs => vs.ActualOption == option).ToList() : parameter.ValueSet;

                    foreach (var parameterValueSet in valueSets)
                    {
                        if (compoundParameterType == null)
                        {
                            var nestedParameter = this.CreatedNestedParameter(parameter, null, parameterValueSet, option);
                            nestedElement.NestedParameter.Add(nestedParameter);
                        }
                        else
                        {
                            foreach (var component in compoundParameterType.Component)
                            {
                                var comp            = (ParameterTypeComponent)component;
                                var nestedParameter = this.CreatedNestedParameter(parameter, comp, parameterValueSet, option);
                                nestedElement.NestedParameter.Add(nestedParameter);
                            }
                        }
                    }
                }
                else
                {
                    var subscription = parameter.ParameterSubscription.SingleOrDefault(ps => ps.Owner == domainOfExpertise);

                    if (subscription != null)
                    {
                        var nestedParameters = this.CreatedNestedParameters(subscription, option, compoundParameterType);

                        foreach (var nestedParameter in nestedParameters)
                        {
                            nestedElement.NestedParameter.Add(nestedParameter);
                        }
                    }
                }
            }

            return(nestedElement);
        }
Exemple #10
0
        /// <summary>
        /// Get <see cref="NestedElement.ShortName"/> for an <see cref="ElementDefinition"/>.
        /// For the <see cref="Iteration"/>'s TopElement this is equal to the param <see cref="ElementDefinition"/>'s ShortName, that ShortName can be returned immediately.
        /// Other <see cref="ElementDefinition"/>s  shall return the value null.
        /// </summary>
        /// <param name="elementDefinition">The <see cref="ElementDefinition"/></param>
        /// <param name="option">The <see cref="Option"/></param>
        /// <returns>The <see cref="NestedElement.ShortName"/> if found, otherwise null</returns>
        public string GetNestedElementPath(ElementDefinition elementDefinition, Option option)
        {
            var iteration = (Iteration)option.Container;

            return(iteration.TopElement == elementDefinition ? elementDefinition.ShortName : null);
        }
Exemple #11
0
        /// <summary>
        /// Recursively Create <see cref="NestedElement"/>s
        /// </summary>
        /// <param name="elementDefinition">
        /// The <see cref="ElementDefinition"/> that contains <see cref="ElementUsage"/>s that
        /// </param>
        /// <param name="rootElement">
        /// The <see cref="ElementDefinition"/> that is the root of the <see cref="NestedElement"/> tree.
        /// </param>
        /// <param name="domainOfExpertise">
        /// The <see cref="DomainOfExpertise"/> for which the <see cref="NestedElement"/> tree needs to be generated. Only the <see cref="Parameter"/>s, <see cref="ParameterOverride"/>s and
        /// <see cref="ParameterSubscription"/>s that are owned by the <see cref="DomainOfExpertise"/> will be taken into account when generating <see cref="NestedParameter"/>s
        /// </param>
        /// <param name="elementUsages">
        /// A <see cref="List{ElementUsage}"/> that contains the <see cref="ElementUsage"/> that define the containment tree
        /// for the <see cref="NestedElement"/>s at the level of the <paramref name="elementDefinition"/>.
        /// </param>
        /// <param name="option">
        /// The <see cref="Option"/> for which the <see cref="NestedElement"/> tree is created. When the <see cref="Option"/>
        /// is null then none of the <see cref="ElementUsage"/>s are filtered.
        /// </param>
        /// <param name="updateOption">
        /// Value indicating whether the <see cref="Option"/> shall be updated with the created <see cref="NestedElement"/>s or not.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable{NestedElement}"/> that have been created.
        /// </returns>
        private IEnumerable <NestedElement> RecursivelyCreateNestedElements(ElementDefinition elementDefinition, ElementDefinition rootElement, DomainOfExpertise domainOfExpertise, List <ElementUsage> elementUsages, Option option, bool updateOption)
        {
            var cache = elementDefinition.Cache;
            var uri   = elementDefinition.IDalUri;

            foreach (var elementUsage in elementDefinition.ContainedElement)
            {
                // comparison is done based on unique identifiers, not on object level. The provided option may be a clone
                if (elementUsage.ExcludeOption.Any(x => x.Iid == option.Iid))
                {
                    Logger.Debug($"ElementUsage {elementUsage.Iid}:{elementUsage.ShortName} is excluded from the Nested Elements.");
                    continue;
                }

                var nestedElement = new NestedElement(Guid.NewGuid(), cache, uri)
                {
                    RootElement = rootElement,
                    IsVolatile  = true
                };

                if (updateOption)
                {
                    option.NestedElement.Add(nestedElement);
                }
                else
                {
                    nestedElement.Container = option;
                }

                var nestedParameters = this.CreateNestedParameters(elementUsage, domainOfExpertise, option);

                foreach (var nestedParameter in nestedParameters)
                {
                    nestedElement.NestedParameter.Add(nestedParameter);
                }

                var containmentUsages = new List <ElementUsage>();

                foreach (var usage in elementUsages)
                {
                    nestedElement.ElementUsage.Add(usage);
                    containmentUsages.Add(usage);
                }

                nestedElement.ElementUsage.Add(elementUsage);
                containmentUsages.Add(elementUsage);

                var referencedElementDefinition = elementUsage.ElementDefinition;

                var nestedElements = this.RecursivelyCreateNestedElements(referencedElementDefinition, rootElement, domainOfExpertise, containmentUsages, option, updateOption);

                foreach (var element in nestedElements)
                {
                    yield return(element);
                }

                yield return(nestedElement);
            }
        }
Exemple #12
0
        /// <summary>
        /// Generates the <see cref="NestedElement"/>s starting at the <paramref name="rootElement"/>
        /// </summary>
        /// <param name="option">
        /// The <see cref="Option"/> for which the <see cref="NestedElement"/> tree is created. When the <see cref="Option"/>
        /// is null then none of the <see cref="ElementUsage"/>s are filtered.
        /// </param>
        /// <param name="domainOfExpertise">
        /// The <see cref="DomainOfExpertise"/> for which the <see cref="NestedElement"/> tree needs to be generated. Only the <see cref="Parameter"/>s, <see cref="ParameterOverride"/>s and
        /// <see cref="ParameterSubscription"/>s that are owned by the <see cref="DomainOfExpertise"/> will be taken into account when generating <see cref="NestedParameter"/>s
        /// </param>
        /// <param name="rootElement">
        /// The <see cref="ElementDefinition"/> that serves as the root of the generated <see cref="NestedElement"/> tree.
        /// </param>
        /// <param name="updateOption">
        /// Value indicating whether the <see cref="Option"/> shall be updated with the created <see cref="NestedElement"/>s or not.
        /// </param>
        /// <returns>
        /// An <see cref="IEnumerable{NestedElement}"/> that contains the generated <see cref="NestedElement"/>s
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// thrown when the <paramref name="option"/> is null
        /// thrown when the <paramref name="rootElement"/> is null
        /// </exception>
        private IEnumerable <NestedElement> GenerateNestedElements_Impl(Option option, DomainOfExpertise domainOfExpertise, ElementDefinition rootElement, bool updateOption = false)
        {
            if (option == null)
            {
                throw new ArgumentNullException(nameof(option), "The option may not be null");
            }

            if (rootElement == null)
            {
                throw new ArgumentNullException(nameof(rootElement), "The rootElement may not be null");
            }

            var nestedElements = new List <NestedElement>();

            var rootNestedElement = this.CreateNestedElementAndNestedParametersForRootElement(rootElement, domainOfExpertise, option, updateOption);

            nestedElements.Add(rootNestedElement);

            var elementUsages          = new List <ElementUsage>();
            var recursedNestedElements = this.RecursivelyCreateNestedElements(rootElement, rootElement, domainOfExpertise, elementUsages, option, updateOption);

            nestedElements.AddRange(recursedNestedElements);

            return(nestedElements);
        }
Exemple #13
0
 /// <summary>
 /// Generates the <see cref="NestedElement"/>s starting at the <paramref name="rootElement"/>
 /// </summary>
 /// <param name="option">
 /// The <see cref="Option"/> for which the <see cref="NestedElement"/> tree is created. When the <see cref="Option"/>
 /// is null then none of the <see cref="ElementUsage"/>s are filtered.
 /// </param>
 /// <param name="rootElement">
 /// The <see cref="ElementDefinition"/> that serves as the root of the generated <see cref="NestedElement"/> tree.
 /// </param>
 /// <param name="updateOption">
 /// Value indicating whether the <see cref="Option"/> shall be updated with the created <see cref="NestedElement"/>s or not.
 /// </param>
 /// <returns>
 /// An <see cref="IEnumerable{NestedElement}"/> that contains the generated <see cref="NestedElement"/>s
 /// </returns>
 /// <exception cref="ArgumentNullException">
 /// thrown when the <paramref name="option"/> is null
 /// thrown when the <paramref name="rootElement"/> is null
 /// </exception>
 public IEnumerable <NestedElement> GenerateNestedElements(Option option, ElementDefinition rootElement, bool updateOption = false)
 {
     return(this.GenerateNestedElements_Impl(option, null, rootElement, updateOption));
 }
Exemple #14
0
        /// <summary>
        /// Generates the <see cref="NestedElement"/>s starting at the <paramref name="rootElement"/>
        /// </summary>
        /// <param name="option">
        /// The <see cref="Option"/> for which the <see cref="NestedElement"/> tree is created. When the <see cref="Option"/>
        /// is null then none of the <see cref="ElementUsage"/>s are filtered.
        /// </param>
        /// <param name="domainOfExpertise">
        /// The <see cref="DomainOfExpertise"/> for which the <see cref="NestedElement"/> tree needs to be generated. Only the <see cref="Parameter"/>s, <see cref="ParameterOverride"/>s and
        /// <see cref="ParameterSubscription"/>s that are owned by the <see cref="DomainOfExpertise"/> will be taken into account when generating <see cref="NestedParameter"/>s
        /// </param>
        /// <param name="rootElement">
        /// The <see cref="ElementDefinition"/> that serves as the root of the generated <see cref="NestedElement"/> tree.
        /// </param>
        /// <param name="updateOption">
        /// Value indicating whether the <see cref="Option"/> shall be updated with the created <see cref="NestedElement"/>s or not.
        /// </param>
        /// <returns>
        /// An <see cref="IEnumerable{NestedElement}"/> that contains the generated <see cref="NestedElement"/>s
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// thrown when the <paramref name="domainOfExpertise"/> is null
        /// thrown when the <paramref name="option"/> is null
        /// thrown when the <paramref name="rootElement"/> is null
        /// </exception>
        public IEnumerable <NestedElement> GenerateNestedElements(Option option, DomainOfExpertise domainOfExpertise, ElementDefinition rootElement, bool updateOption = false)
        {
            if (domainOfExpertise == null)
            {
                throw new ArgumentNullException(nameof(domainOfExpertise), "The domainOfExpertise may not be null");
            }

            return(this.GenerateNestedElements_Impl(option, domainOfExpertise, rootElement, updateOption));
        }
Exemple #15
0
 public abstract bool InsertFirstChild(ElementDefinition child);
 void addIssueMissingSliceEntry(ElementDefinition elementDef)
 {
     addIssue(CreateIssueMissingSliceEntry(elementDef));
 }
Exemple #17
0
//----------------------------------
//
// Methods that alter the list of elements
//
//----------------------------------

        public abstract bool InsertBefore(ElementDefinition sibling);
        internal static OperationOutcome.IssueComponent CreateIssueTypeSliceWithoutType(ElementDefinition elementDef)
        {
            var location = elementDef.Path;

            return(PROFILE_ELEMENTDEF_TYPESLICE_WITHOUT_TYPE.ToIssueComponent(
                       $"Element {location} is part of a @type slice group, but the element itself has no type.",
                       location
                       ));
        }
Exemple #19
0
 public abstract bool InsertAfter(ElementDefinition sibling);
 void addIssueInvalidChoiceConstraint(ElementDefinition elementDef)
 {
     addIssue(CreateIssueInvalidChoiceConstraint(elementDef));
 }
        // Snapshot's element turns out not to be expandable, so we can't move to the desired path
        // "Differential has nested constraints for node '{0}', but this is a leaf node in base"
        // Differential specifies constraint on child element of a leaf node in the base, i.e. node without child elements
        //public static readonly Issue PROFILE_ELEMENTDEF_INVALID_CHILD_CONSTRAINT = Issue.Create(10001, OperationOutcome.IssueSeverity.Error, OperationOutcome.IssueType.Invalid);

        //void addIssueInvalidChildConstraint(ElementDefinition elementDef) { addIssueInvalidChildConstraint(ToNamedNode(elementDef)); }
        //void addIssueInvalidChildConstraint(INamedNode location)
        //{
        //    addIssue(
        //        PROFILE_ELEMENTDEF_INVALID_CHOICE_CONSTRAINT,
        //        $"Differential specifies invalid child constraints on leaf element {location}.",
        //        location
        //    );
        //}

        void addIssueInvalidNameReference(ElementDefinition elementDef)
        {
            addIssue(CreateIssueInvalidNameReference(elementDef));
        }
 /// <summary>
 /// Annotate the root <see cref="ElementDefinition"/> instance in the <see cref="StructureDefinition.Differential"/> component
 /// with a reference to the associated root <see cref="ElementDefinition"/> instance in the <see cref="StructureDefinition.Snapshot"/> component.
 /// </summary>
 internal static void SetSnapshotRootElementAnnotation(this StructureDefinition sd, ElementDefinition rootElemDef)
 {
     sd?.Differential?.Element[0]?.SetSnapshotElementAnnotation(rootElemDef);
 }
        internal static OperationOutcome.IssueComponent CreateIssueInvalidNameReference(ElementDefinition elementDef)
        {
            var location = elementDef.Path;
            var nameRef  = elementDef.NameReference;

            return(PROFILE_ELEMENTDEF_INVALID_TYPEPROFILE_NAMEREF.ToIssueComponent(
                       $"Element {location} has a nameReference to '{nameRef}', which cannot be found in the StructureDefinition.",
                       location
                       ));
        }
 /// <summary>
 /// Return the annotated reference to the associated <see cref="ElementDefinition"/> instance
 /// in the <see cref="StructureDefinition.Snapshot"/> component, if it exists, or <c>null</c> otherwise.
 /// </summary>
 internal static ElementDefinition GetSnapshotElementAnnotation(this ElementDefinition ed) => ed?.Annotation <SnapshotElementDefinitionAnnotation>()?.SnapshotElement;
 void addIssueNoTypeOrNameReference(ElementDefinition elementDef)
 {
     addIssueNoTypeOrNameReference(elementDef.Path);
 }
Exemple #26
0
        public void VerifyThatContextMenuIsPopulated()
        {
            var group = new ParameterGroup(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var parameter = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ParameterType = this.pt
            };

            var def2       = new ElementDefinition(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var parameter2 = new Parameter(Guid.NewGuid(), this.assembler.Cache, this.uri);
            var usage      = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri);

            var paramOverride = new ParameterOverride(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Parameter = parameter2
            };

            parameter2.ParameterType = this.pt;

            var usage2 = new ElementUsage(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                ElementDefinition = def2
            };

            def2.Parameter.Add(parameter2);
            usage.ParameterOverride.Add(paramOverride);
            usage.ElementDefinition = def2;

            this.elementDef.Parameter.Add(parameter);
            this.elementDef.ParameterGroup.Add(group);
            this.elementDef.ContainedElement.Add(usage);
            this.elementDef.ContainedElement.Add(usage2);

            this.iteration.Element.Add(this.elementDef);
            this.iteration.Element.Add(def2);

            var vm = new ElementDefinitionsBrowserViewModel(this.iteration, this.session.Object, null, null, null, null);

            vm.PopulateContextMenu();

            Assert.AreEqual(2, vm.ContextMenu.Count);

            var defRow = vm.ElementDefinitionRowViewModels.Last();

            vm.SelectedThing = defRow;
            vm.PopulateContextMenu();
            Assert.AreEqual(14, vm.ContextMenu.Count);

            vm.SelectedThing = defRow.ContainedRows[0];
            vm.PopulateContextMenu();
            Assert.AreEqual(10, vm.ContextMenu.Count);

            vm.SelectedThing = defRow.ContainedRows[1];
            vm.PopulateContextMenu();
            Assert.AreEqual(9, vm.ContextMenu.Count);

            var usageRow  = defRow.ContainedRows[2];
            var usage2Row = defRow.ContainedRows[3];

            vm.SelectedThing = usageRow;
            vm.PopulateContextMenu();
            Assert.AreEqual(8, vm.ContextMenu.Count);

            vm.SelectedThing = usageRow.ContainedRows.Single();
            vm.PopulateContextMenu();
            Assert.AreEqual(10, vm.ContextMenu.Count);

            vm.SelectedThing = usage2Row.ContainedRows.Single();
            vm.PopulateContextMenu();
            Assert.AreEqual(10, vm.ContextMenu.Count);

            vm.Dispose();
        }
 void addIssueInvalidProfileNameReference(ElementDefinition elementDef, string name, string profileRef)
 {
     addIssueInvalidProfileNameReference(elementDef.Path, name, profileRef);
 }
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.domain  = new DomainOfExpertise(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "domain"
            };

            this.siteDir        = new SiteDirectory(Guid.NewGuid(), this.cache, this.uri);
            this.person         = new Person(Guid.NewGuid(), this.cache, this.uri);
            this.model          = new EngineeringModel(Guid.NewGuid(), this.cache, this.uri);
            this.modelSetup     = new EngineeringModelSetup(Guid.NewGuid(), this.cache, this.uri);
            this.iteration      = new Iteration(Guid.NewGuid(), this.cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.cache, this.uri);
            this.participant    = new Participant(Guid.NewGuid(), this.cache, this.uri);
            this.option         = new Option(Guid.NewGuid(), this.cache, this.uri);
            this.elementDef     = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };
            this.type = new EnumerationParameterType(Guid.NewGuid(), this.cache, this.uri)
            {
                Name = "a"
            };
            this.valueSet = new ParameterValueSet(Guid.NewGuid(), this.cache, this.uri)
            {
                Published = new ValueArray <string>(new List <string> {
                    "1"
                }),
                Manual = new ValueArray <string>(new List <string> {
                    "1"
                }),
                ValueSwitch = ParameterSwitchKind.MANUAL
            };

            this.elementDef2 = new ElementDefinition(Guid.NewGuid(), this.cache, this.uri)
            {
                Owner = this.domain
            };
            this.elementUsage = new ElementUsage(Guid.NewGuid(), this.cache, this.uri)
            {
                ElementDefinition = this.elementDef2, Owner = this.domain
            };

            this.siteDir.Person.Add(this.person);
            this.siteDir.Model.Add(this.modelSetup);
            this.modelSetup.IterationSetup.Add(this.iterationSetup);
            this.modelSetup.Participant.Add(this.participant);
            this.participant.Person = this.person;

            this.model.Iteration.Add(this.iteration);
            this.model.EngineeringModelSetup = this.modelSetup;
            this.iteration.IterationSetup    = this.iterationSetup;
            this.iteration.Option.Add(this.option);
            this.iteration.TopElement = this.elementDef;
            this.iteration.Element.Add(this.elementDef);
            this.iteration.Element.Add(this.elementDef2);
            this.elementDef.ContainedElement.Add(this.elementUsage);

            this.session.Setup(x => x.ActivePerson).Returns(this.person);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString);
            this.session.Setup(x => x.OpenIterations).Returns(new Dictionary <Iteration, Tuple <DomainOfExpertise, Participant> >());
        }
 void addIssueInvalidSlice(ElementDefinition elementDef)
 {
     addIssueInvalidSlice(elementDef.Path);
 }
Exemple #30
0
 public static List <FHIRDefinedType> ChoiceTypes(this ElementDefinition definition)
 {
     return(definition.Type.Where(tr => tr.Code != null).Select(tr => tr.Code.Value).Distinct().ToList());
 }
Exemple #31
0
        /// <summary>
        /// Populates the main menu. Elements are visible based on which definitions and styles are loaded, and whether
        /// actions on a specifically pointed element are possible.
        /// </summary>
        private void MainMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            this.mnuSaveDefinition.Enabled = GlobalSettings.CurrentDefinition != null;
            if (GlobalSettings.CurrentDefinition != null)
            {
                this.mnuSaveDefinitionAsName.Text =
                    $"Save &To '{GlobalSettings.CurrentDefinition.Category}/{GlobalSettings.CurrentDefinition.Name}'";

                var mousePos = this.PointToClient(Cursor.Position);
                this.elementUnderCursor =
                    GlobalSettings.CurrentDefinition.Elements.FirstOrDefault(x => x.Inside(mousePos));
                this.mnuEditElementStyle.Enabled = this.elementUnderCursor != null;
            }

            this.mnuEditKeyboardStyle.Enabled = GlobalSettings.CurrentDefinition != null;

            this.mnuSaveStyleToName.Text = $"Save &To '{GlobalSettings.CurrentStyle.Name}'";
            this.mnuSaveStyleToName.Visible = !GlobalSettings.Settings.LoadedGlobalStyle;
            this.mnuSaveToGlobalStyleName.Text = $"Save To &Global '{GlobalSettings.CurrentStyle.Name}'";
            this.mnuSaveToGlobalStyleName.Enabled = GlobalSettings.CurrentStyle.IsGlobal;
            this.mnuSaveToGlobalStyleName.Visible = GlobalSettings.Settings.LoadedGlobalStyle;

            this.mnuToggleEditMode.Enabled = false; // TODO: Implement edit mode.

            if (this.latestVersion != null)
            {
                this.MainMenu.Items.Add(
                    $"New version available: {this.latestVersion.Format()}.",
                    null,
                    (s, ea) =>
                    {
                        Process.Start("https://github.com/ThoNohT/NohBoard/releases");
                    });
            }
        }