Example #1
0
        /// <summary>
        /// Returns the <see cref="DatatypeDefinitionString"/> representation of a text <see cref="ParameterType"/>
        /// </summary>
        /// <param name="definedThing">The <see cref="DefinedThing"/> the parameter type</param>
        /// <returns>The <see cref="DatatypeDefinitionString"/></returns>
        private DatatypeDefinitionString ToReqIfDatatypeDefinitionString(DefinedThing definedThing)
        {
            var datatype = new DatatypeDefinitionString();

            this.SetIdentifiableProperties(datatype, definedThing);
            return(datatype);
        }
Example #2
0
 /// <summary>
 /// Set the <see cref="Identifiable"/> properties from a <see cref="DefinedThing"/>
 /// </summary>
 /// <param name="identifiable">The <see cref="Identifiable"/></param>
 /// <param name="definedThing">The <see cref="DefinedThing"/></param>
 private void SetIdentifiableProperties(Identifiable identifiable, DefinedThing definedThing)
 {
     identifiable.Identifier  = definedThing.Iid.ToString();
     identifiable.LongName    = string.Format("{0}{1}", definedThing.ClassKind == ClassKind.RequirementsGroup ? GroupNamePrefix : string.Empty, definedThing.ShortName);
     identifiable.LastChange  = DateTime.UtcNow;
     identifiable.Description = definedThing.Name;
 }
Example #3
0
        /// <summary>
        /// Computes a row
        /// </summary>
        /// <param name="rowThing">The <see cref="Thing" /> of the current row</param>
        /// <param name="columnThings">The <see cref="Thing" />s displayed in the columns</param>
        /// <param name="relationships">The current set of <see cref="BinaryRelationship" /></param>
        /// <param name="relationshipRule">The current <see cref="BinaryRelationshipRule" /></param>
        /// <param name="displayKind">The <see cref="DisplayKind" /> of the current Row.</param>
        /// <param name="columnDefinitions">The defined columns.</param>
        /// <returns>The <see cref="IDictionary{TKey,TValue}" /> that corresponds to a row</returns>
        private IDictionary <string, MatrixCellViewModel> ComputeRow(DefinedThing rowThing,
                                                                     IReadOnlyList <DefinedThing> columnThings,
                                                                     IReadOnlyList <BinaryRelationship> relationships, BinaryRelationshipRule relationshipRule,
                                                                     DisplayKind displayKind, IList <ColumnDefinition> columnDefinitions)
        {
            var record = new Dictionary <string, MatrixCellViewModel>
            {
                { ROW_NAME_COLUMN, new MatrixCellViewModel(rowThing, null, null, relationshipRule, displayKind) }
            };

            foreach (var definedThing in columnThings)
            {
                if (columnDefinitions.All(x => !x.ThingId.Equals(definedThing.Iid)))
                {
                    continue;
                }

                var cellValue = this.ComputeCell(rowThing, definedThing, relationships, relationshipRule);
                record.Add(definedThing.ShortName, cellValue);

                this.UpdateCurrentCell(rowThing, definedThing, cellValue);

                if (cellValue.RelationshipDirection != RelationshipDirectionKind.None)
                {
                    columnDefinitions.Single(s => s.ThingId.Equals(definedThing.Iid)).RelationshipCount++;
                }
            }

            return(record);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnDefinition"/> class
 /// </summary>
 /// <param name="thing">The represented <see cref="Thing"/></param>
 /// <param name="displayKind">The <see cref="DisplayKind"/> of the column.</param>
 public ColumnDefinition(DefinedThing thing, DisplayKind displayKind)
 {
     this.RelationshipCount = 0;
     this.Header            = displayKind == DisplayKind.Name ? thing.Name : thing.ShortName;
     this.ToolTip           = thing.Tooltip();
     this.FieldName         = thing.ShortName;
     this.ThingId           = thing.Iid;
     this.IsHighlighted     = false;
 }
Example #5
0
        /// <summary>
        /// Set the <see cref="DefinedThing"/> definition
        /// </summary>
        /// <param name="definedThing">The <see cref="DefinedThing"/></param>
        /// <param name="value">The <see cref="AttributeValue"/> corresponding to the requirement text</param>
        private void SetDefinition(DefinedThing definedThing, AttributeValue value)
        {
            var theValue = this.GetAttributeValue(value);

            var definition = new Definition
            {
                Content      = theValue,
                LanguageCode = this.LanguageCode
            };

            definedThing.Definition.Add(definition);
        }
Example #6
0
        public void SetUp()
        {
            this.siteDir                = new SiteDirectory(Guid.NewGuid(), null, null);
            this.definedThing           = new DomainOfExpertise(Guid.NewGuid(), null, null);
            this.definedThing.Container = this.siteDir;
            this.alias = new Alias {
                Iid = Guid.NewGuid(), IsSynonym = true, Content = "test", LanguageCode = "test2"
            };
            this.alias.Container = this.definedThing;

            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), null, null);
            this.srdl.Container = this.siteDir;
        }
Example #7
0
        /// <summary>
        /// Computes a <see cref="MatrixViewModel" /> representing a cell
        /// </summary>
        /// <param name="rowThing">The <see cref="Thing" /> of the current row</param>
        /// <param name="columnThing">The <see cref="Thing" /> of the current column</param>
        /// <param name="relationships">The current sets of <see cref="BinaryRelationship" /></param>
        /// <param name="relationshipRule">The current <see cref="BinaryRelationshipRule" /></param>
        /// <returns>The <see cref="MatrixCellViewModel" /></returns>
        private MatrixCellViewModel ComputeCell(DefinedThing rowThing, DefinedThing columnThing,
                                                IReadOnlyList <BinaryRelationship> relationships, BinaryRelationshipRule relationshipRule)
        {
            var relationship = relationships.Where(x =>
                                                   (x.Source?.Iid == rowThing.Iid || x.Source?.Iid == columnThing.Iid) &&
                                                   (x.Target?.Iid == rowThing.Iid || x.Target?.Iid == columnThing.Iid)).ToList();

            var cellValue = relationship.Count > 0
                ? new MatrixCellViewModel(rowThing, columnThing, relationship, relationshipRule)
                : new MatrixCellViewModel(rowThing, columnThing, null, relationshipRule);

            return(cellValue);
        }
Example #8
0
        /// <summary>
        /// Update the current cell cache <see cref="currentCells" />
        /// </summary>
        /// <param name="row">The thing in the current row context</param>
        /// <param name="col">The thing in the current column context</param>
        /// <param name="cellValue">The cell object</param>
        private void UpdateCurrentCell(DefinedThing row, DefinedThing col, MatrixCellViewModel cellValue)
        {
            var cellRef = $"{row.Iid}_{col.Iid}";

            if (this.currentCells.ContainsKey(cellRef))
            {
                this.currentCells[cellRef] = cellValue;
            }
            else
            {
                this.currentCells.Add(cellRef, cellValue);
            }
        }
Example #9
0
        /// <summary>
        /// Checks if a<see cref="DefinedThing" /> is allowed to be displayed in the UI
        /// </summary>
        /// <param name="definedThing">
        /// The <see cref="DefinedThing" /> to check
        /// </param>
        /// <returns>
        /// true is display is allowed
        /// </returns>
        private bool IsDefinedThingDisplayAllowed(DefinedThing definedThing)
        {
            if (this.IsDeprecatedDisplayed)
            {
                return(true);
            }

            if (!(definedThing is IDeprecatableThing deprecatableThing))
            {
                return(true);
            }

            return(!deprecatableThing.IsDeprecated);
        }