/// <summary>
        /// Get string with ReqIF Header Information
        /// </summary>
        /// <returns></returns>
        protected string GetHeaderInfo(ReqIF reqIf = null)
        {
            reqIf = reqIf ?? ReqIfDeserialized;
            if (reqIf == null)
            {
                return("no ReqIF found, possible SW error");
            }
            if (reqIf.TheHeader == null)
            {
                return("no ReqIF header found");
            }
            if (reqIf.TheHeader.Count == 0)
            {
                return("ReqIF header count = 0");
            }
            return($@"Title:{Tab}{Tab}'{reqIf.TheHeader[0].Title}'
ReqIFVersion:{Tab}'{reqIf.TheHeader[0].ReqIFVersion}'
ReqIFToolId:{Tab}'{reqIf.TheHeader[0].ReqIFToolId}'
RepositoryId:{Tab}'{reqIf.TheHeader[0].RepositoryId}'
SourceToolId:{Tab}'{reqIf.TheHeader[0].SourceToolId}'
CreationTime:{Tab}'{reqIf.TheHeader[0].CreationTime}'
Identifier:{Tab}'{reqIf.TheHeader[0].Identifier}'
Comment:{Tab}'{reqIf.TheHeader[0].Comment}'
");
        }
 public ReqIfRelation(ReqIF reqIf, EA.Repository rep, FileImportSettingsItem settings)
 {
     _reqIf        = reqIf;
     _rep          = rep;
     _settings     = settings;
     _requirements = new List <EA.Element>();
 }
        /// <summary>
        /// Initialize DOORS Requirement DataTable for the sub module according to subModuleIndex.
        /// It creates the table and the column names from the DOORS attributes and the standard attributes.
        /// </summary>
        /// <param name="reqIf"></param>
        private void InitializeDoorsRequirementsTable(ReqIF reqIf)
        {
            // Initialize table
            DtRequirements = new DataTable();
            DtRequirements.Columns.Add("Id", typeof(string));
            DtRequirements.Columns.Add("Object Level", typeof(int));
            DtRequirements.Columns.Add("Object Number", typeof(string));
            DtRequirements.Columns.Add("Object Type", typeof(string));
            DtRequirements.Columns.Add("Object Heading", typeof(string));
            DtRequirements.Columns.Add("Object Text", typeof(string));
            //
            DtRequirements.Columns.Add("VerificationMethod", typeof(string));
            DtRequirements.Columns.Add("RequirementID", typeof(string));
            DtRequirements.Columns.Add("LegacyID", typeof(string));

            // Get all attributes
            var blackList  = new String[] { "TableType", "TableBottomBorder", "TableCellWidth", "TableChangeBars", "TableLeftBorder", "TableLinkIndicators", "TableRightBorder", "TableShowAttrs", "TableTopBorder" };
            var attributes = (from obj in reqIf.CoreContent[0].SpecObjects
                              from attr in obj.Values
                              where !blackList.Any(bl => bl == attr.AttributeDefinition.LongName)

                              select new { name = attr.AttributeDefinition.LongName, Type = attr.AttributeDefinition.DatatypeDefinition.ToString() }).Distinct();

            foreach (var attribute in attributes)
            {
                if (
                    attribute.name == "Object Text" ||
                    attribute.name == "Object Heading")
                {
                    continue;
                }
                DtRequirements.Columns.Add(attribute.name, typeof(string));
            }
        }
示例#4
0
        public void Setup()
        {
            this.serviceLocator    = new Mock <IServiceLocator>();
            this.messageBoxService = new Mock <IMessageBoxService>();

            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
            this.serviceLocator.Setup(x => x.GetInstance <IMessageBoxService>()).Returns(this.messageBoxService.Object);

            this.pluginSettingsService = new PluginSettingsService();

            this.expectedSettingsPath =
                Path.Combine(
                    this.pluginSettingsService.AppDataFolder,
                    this.pluginSettingsService.Cdp4ConfigurationDirectoryFolder,
                    "CDP4Requirements.settings.json");

            this.iteration = new Iteration()
            {
            };

            this.uri = "http://www.rheagroup.com/";
            var credentials = new Credentials("John", "Doe", new Uri(this.uri));

            this.session = new Session(new Mock <IDal>().Object, credentials);

            var reqIfPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "Settings", "testreq.reqif");

            this.reqIf = new ReqIFDeserializer().Deserialize(reqIfPath).First();

            this.dataTypeDefinitionMapConverter = new DataTypeDefinitionMapConverter(this.reqIf, this.session);
            this.specObjectTypeMapConverter     = new SpecObjectTypeMapConverter(this.reqIf, this.session);
            this.specRelationTypeMapConverter   = new SpecRelationTypeMapConverter(this.reqIf, this.session);
            this.relationGroupTypeMapConverter  = new RelationGroupTypeMapConverter(this.reqIf, this.session);
            this.specificationTypeMapConverter  = new SpecificationTypeMapConverter(this.reqIf, this.session);
        }
示例#5
0
        /// <summary>
        /// Returns a <see cref="ReqIF"/> instance for the content of an <see cref="Iteration"/>
        /// </summary>
        /// <param name="session">The <see cref="ISession"/> containing the <see cref="Iteration"/></param>
        /// <param name="iteration">The <see cref="Iteration"/></param>
        /// <returns>The <see cref="ReqIF"/> instance</returns>
        public ReqIF BuildReqIF(ISession session, Iteration iteration)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }

            if (iteration == null)
            {
                throw new ArgumentNullException("iteration");
            }

            this.currentSession    = session;
            this.exportedIteration = iteration;

            if (iteration.Cache != this.currentSession.Assembler.Cache)
            {
                throw new InvalidOperationException("The iteration is not contained in the session's database.");
            }

            this.reqIFBuilt = new ReqIF {
                Lang = this.language
            };
            this.SetHeader();

            this.InstantiateReqIfElements();
            this.ResolveReferences();

            this.BuildCore();

            return(this.reqIFBuilt);
        }
示例#6
0
        public void Deserialize(string filepath)
        {
            ReqIFDeserializer deserializer = new ReqIFDeserializer();

            reqif           = deserializer.Deserialize(filepath).First();
            header          = reqif.TheHeader;
            content         = reqif.CoreContent;
            embeddedObjects = reqif.EmbeddedObjects;

            PropertyGrid.DataContext = header;
            specObjectsViewModel     = new SpecObjectsViewModel(content);
            specObjectsViewModel.SpecObjects.CollectionChanged += SpecObjects_CollectionChanged;
            foreach (var specObject in specObjectsViewModel.SpecObjects)
            {
                foreach (var attribute in specObject.Values)
                {
                    attribute.PropertyChanged += Attribute_PropertyChanged;
                }
                foreach (var attribute in specObject.Values)
                {
                    if (attribute.AttributeValue != null)
                    {
                        attribute.AttributeValue.PropertyChanged += AttributeValue_PropertyChanged;
                    }
                }
            }
            initializeColumns();
            MainDataGrid.ItemsSource = specObjectsViewModel.SpecObjects;
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReqIfImportMappingManager"/> class
 /// </summary>
 /// <param name="reqif">The <see cref="ReqIF"/> object to map</param>
 /// <param name="session">The <see cref="ISession"/> in which are information shall be written</param>
 /// <param name="iteration">The <see cref="Iteration"/> in which the information shall be written</param>
 /// <param name="domain">The active <see cref="DomainOfExpertise"/></param>
 /// <param name="dialogNavigationService">The <see cref="IDialogNavigationService"/></param>
 public ReqIfImportMappingManager(ReqIF reqif, ISession session, Iteration iteration, DomainOfExpertise domain, IDialogNavigationService dialogNavigationService, IThingDialogNavigationService thingDialogNavigationService)
 {
     this.reqIf     = reqif;
     this.session   = session;
     this.iteration = iteration.Clone(false);
     this.dialogNavigationService      = dialogNavigationService;
     this.thingDialogNavigationService = thingDialogNavigationService;
     this.currentDomain = domain;
 }
示例#8
0
        /// <summary>
        /// Compute all requirement related <see cref="Thing"/> from the <see cref="ReqIF"/> data
        /// </summary>
        /// <param name="reqIfData">The <see cref="ReqIF"/> data</param>
        public void ComputeRequirementThings(ReqIF reqIfData)
        {
            foreach (var specification in reqIfData.CoreContent.First().Specifications)
            {
                var reqSpec = this.CreateRequirementSpecification(specification);
                foreach (SpecHierarchy child in specification.Children)
                {
                    this.ComputeRequirementFromSpecHierarchy(child, reqSpec);
                }

                this.Iteration.RequirementsSpecification.Add(reqSpec);
            }

            // if any spec-object representing requirement left, create another RequirementSpec to contain them
            var specObjectLeft = reqIfData.CoreContent.First().SpecObjects.Except(this.specObjectMap.Keys).ToArray();
            var uncontainedReq = new List <Requirement>();

            foreach (var specObject in specObjectLeft)
            {
                var req = this.CreateRequirement(specObject);
                if (req != null)
                {
                    uncontainedReq.Add(req);
                }
            }

            if (uncontainedReq.Count != 0)
            {
                var spec = new RequirementsSpecification
                {
                    Owner     = this.Owner,
                    ShortName = unresolvedSpec,
                    Name      = unresolvedSpec
                };

                foreach (var requirement in uncontainedReq)
                {
                    spec.Requirement.Add(requirement);
                }

                this.specificationMap.Add(new Specification(), spec);
                this.Iteration.RequirementsSpecification.Add(spec);
            }

            foreach (var specRelation in reqIfData.CoreContent.First().SpecRelations)
            {
                var relationship = this.CreateBinaryRelationship(specRelation);
                this.Iteration.Relationship.Add(relationship);
            }

            foreach (var relationGroup in reqIfData.CoreContent.First().SpecRelationGroups)
            {
                var relationship = this.CreateBinaryRelationship(relationGroup);
                this.Iteration.Relationship.Add(relationship);
            }
        }
示例#9
0
        /// <summary>
        /// Initialize DoorsModule for usage with package.
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="pkg"></param>
        /// <param name="reqIfLogList"></param>
        private void Init(EA.Repository rep, EA.Package pkg, List <ReqIfLog> reqIfLogList = null)
        {
            _pkg = pkg;
            _rep = rep;
            _reqIfDeserialized = null;
            _reqIfLogList      = reqIfLogList;

            // get connection string of repository
            _connectionString = LinqUtil.GetConnectionString(_rep, out _provider);
        }
示例#10
0
 /// <summary>
 /// Initializes necessary <see cref="JsonConverter"/>  for the requirement plugin
 /// </summary>
 /// <param name="reqIf">The <see cref="ReqIF"/></param>
 /// <param name="session">The <see cref="ISession"/></param>
 /// <returns>An array of <see cref="JsonConverter"/></returns>
 public static JsonConverter[] BuildConverters(ReqIF reqIf, ISession session)
 {
     return(new JsonConverter[]
     {
         new DataTypeDefinitionMapConverter(reqIf, session),
         new SpecObjectTypeMapConverter(reqIf, session),
         new SpecRelationTypeMapConverter(reqIf, session),
         new RelationGroupTypeMapConverter(reqIf, session),
         new SpecificationTypeMapConverter(reqIf, session),
     });
 }
        /// <summary>
        /// Get types of a ReqIF module
        /// </summary>
        /// <param name="reqIf"></param>
        /// <param name="reqifContentIndex"></param>
        /// <param name="reqIfSpecIndex"></param>
        /// <returns></returns>
        protected List <ReqIFSharp.AttributeDefinition> GetTypesModule(ReqIF reqIf, int reqifContentIndex, int reqIfSpecIndex)
        {
            var specObjectTypes = new List <ReqIFSharp.AttributeDefinition>();
            var children        = reqIf.CoreContent[reqifContentIndex].Specifications[reqIfSpecIndex].Children;

            foreach (SpecHierarchy child in children)
            {
                AddModuleAttributeTypes(specObjectTypes, child.Children);
            }
            return(specObjectTypes.Select(x => x).Distinct().ToList());
        }
        public async Task SetUp()
        {
            var cts = new CancellationTokenSource();

            var reqifPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "TestData", "ProR_Traceability-Template-v1.0.reqif");

            await using var fileStream = new FileStream(reqifPath, FileMode.Open);
            var reqIfDeserializer  = new ReqIFDeserializer();
            var reqIfLoaderService = new ReqIFLoaderService(reqIfDeserializer);
            await reqIfLoaderService.Load(fileStream, cts.Token);

            this.reqIf = reqIfLoaderService.ReqIFData.Single();
        }
示例#13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReqIfImportMappingManager"/> class
 /// </summary>
 /// <param name="reqif">The <see cref="ReqIF"/> object to map</param>
 /// <param name="session">The <see cref="ISession"/> in which are information shall be written</param>
 /// <param name="iteration">The <see cref="Iteration"/> in which the information shall be written</param>
 /// <param name="domain">The active <see cref="DomainOfExpertise"/></param>
 /// <param name="dialogNavigationService">The <see cref="IDialogNavigationService"/></param>
 /// <param name="thingDialogNavigationService">The <see cref="IThingDialogNavigationService"/></param>
 /// <param name="mappingConfiguration">The <see cref="ImportMappingConfiguration"/></param>
 public ReqIfImportMappingManager(ReqIF reqif, ISession session, Iteration iteration, DomainOfExpertise domain, IDialogNavigationService dialogNavigationService, IThingDialogNavigationService thingDialogNavigationService, ImportMappingConfiguration mappingConfiguration = null)
 {
     this.reqIf     = reqif;
     this.session   = session;
     this.iteration = iteration.Clone(false);
     this.dialogNavigationService      = dialogNavigationService;
     this.thingDialogNavigationService = thingDialogNavigationService;
     this.currentDomain        = domain;
     this.mappingConfiguration = mappingConfiguration ?? new ImportMappingConfiguration()
     {
         ReqIfName = this.reqIf.TheHeader?.Title, ReqIfId = this.reqIf.TheHeader?.Identifier
     };
 }
        public void SetUp()
        {
            this.resultFileUri = Path.Combine(TestContext.CurrentContext.TestDirectory, "result.xml");

            this.enumdatatype_id      = "enumeration";
            this.enum_value_low_id    = "enumlow";
            this.enum_value_medium_id = "enummedium";

            this.specobject_1_id = "specobject_1";
            this.specobject_2_id = "specobject_2";
            this.specobject_3_id = "specobject_3";

            this.xhtmlcontent = "<xhtml:p>XhtmlPType<xhtml:a accesskey=\"a\" charset=\"UTF-8\" href=\"http://eclipse.org/rmf\" hreflang=\"en\" rel=\"LinkTypes\" rev=\"LinkTypes\" style=\"text-decoration:underline\" tabindex=\"1\" title=\"text\" type=\"text/html\"> text before br<xhtml:br/>text after br text before span<xhtml:span>XhtmlSpanType</xhtml:span>text after span text before em<xhtml:em>XhtmlEmType</xhtml:em>text after em text before strong<xhtml:strong>XhtmlStrongType</xhtml:strong>text after strong text before dfn<xhtml:dfn>XhtmlDfnType</xhtml:dfn>text after dfn text before code<xhtml:code>XhtmlCodeType</xhtml:code>text after code text before samp<xhtml:samp>XhtmlSampType</xhtml:samp>text after samp text before kbd<xhtml:kbd>XhtmlKbdType</xhtml:kbd>text after kbd text before var<xhtml:var>XhtmlVarType</xhtml:var>text after var text before cite<xhtml:cite>XhtmlCiteType</xhtml:cite>text after cite text before abbr<xhtml:abbr>XhtmlAbbrType</xhtml:abbr>text after abbr text before acronym<xhtml:acronym>XhtmlAcronymType</xhtml:acronym>text after acronym text before q<xhtml:q>XhtmlQType</xhtml:q>text after q text before tt<xhtml:tt>XhtmlInlPresType</xhtml:tt>text after tt text before i<xhtml:i>XhtmlInlPresType</xhtml:i>text after i text before b<xhtml:b>XhtmlInlPresType</xhtml:b>text after b text before big<xhtml:big>XhtmlInlPresType</xhtml:big>text after big text before small<xhtml:small>XhtmlInlPresType</xhtml:small>text after small text before sub<xhtml:sub>XhtmlInlPresType</xhtml:sub>text after sub text before sup<xhtml:sup>XhtmlInlPresType</xhtml:sup>text after sup text before ins<xhtml:ins>XhtmlEditType</xhtml:ins>text after ins text before del<xhtml:del>XhtmlEditType</xhtml:del>text after del</xhtml:a></xhtml:p>";

            this.reqIF      = new ReqIF();
            this.reqIF.Lang = "en";

            var header = new ReqIFHeader();

            header.Comment      = "this is a comment";
            header.CreationTime = DateTime.Parse("2015-12-01");
            header.Identifier   = "reqifheader";
            header.RepositoryId = "a repos id";
            header.ReqIFToolId  = "tool - CDP4";
            header.ReqIFVersion = "1.0";
            header.SourceToolId = "source tool - CDP4";
            header.Title        = "this is a title";

            this.reqIF.TheHeader.Add(header);

            var reqIfContent = new ReqIFContent();

            this.reqIF.CoreContent.Add(reqIfContent);

            this.CreateDataTypes();
            this.CreateSpecObjectType();
            this.CreateSpecificationType();
            this.CreateSpecRelationType();
            this.CreateRelationGroupType();

            this.CreateSpecObjects();
            this.CreateSpecRelations();
            this.CreateSpecifications();
            this.CreateRelationGroup();
        }
        /// <summary>
        /// Add Tagged Values with Module Properties to Package/Object and
        /// Specification: LongName
        /// Specification: Identifier
        /// </summary>
        /// <param name="reqIf"></param>
        /// <param name="el"></param>
        private void GetModuleProperties(ReqIF reqIf, EA.Element el)
        {
            var moduleProperties = from obj in reqIf.CoreContent[0].Specifications[0].Values
                                   select new { Value = obj.ObjectValue.ToString(), Name = obj.AttributeDefinition.LongName, Type = obj.AttributeDefinition.GetType() };

            foreach (var property in moduleProperties)
            {
                // if writable don't overwrite value, only create TV
                if (_exportFields.IsWritableValue(property.Value))
                {
                    TaggedValue.CreateTaggedValue(el, property.Value); // only create TV
                }
                else
                {
                    TaggedValue.SetUpdate(el, property.Name, GetStringAttrValue(property.Value ?? ""));  // update TV
                }
            }

            TaggedValue.SetUpdate(el, "LongName", reqIf.CoreContent[0].Specifications[0].LongName);
            TaggedValue.SetUpdate(el, "Identifier", reqIf.CoreContent[0].Specifications[0].Identifier);
        }
        public void Verify_that_DatatypeDefinitionDate_can_be_serialized_and_deserialized()
        {
            var document = new ReqIF
            {
                Lang        = "en",
                TheHeader   = new ReqIFHeader(),
                CoreContent = new ReqIFContent()
            };

            var lastChange = new DateTime(1831, 07, 21);

            var dateDefinition = new DatatypeDefinitionDate
            {
                Identifier = "dateDefinition",
                LongName   = "Date",
                LastChange = lastChange
            };

            document.CoreContent.DataTypes.Add(dateDefinition);

            this.resultFileUri = Path.Combine(TestContext.CurrentContext.TestDirectory, "result.xml");

            var serializer = new ReqIFSerializer();

            Assert.That(() => serializer.Serialize(document, this.resultFileUri), Throws.Nothing);

            var deserializer = new ReqIFDeserializer();

            var reqIf = deserializer.Deserialize(this.resultFileUri).First();

            var datatypeDefinition = reqIf.CoreContent.DataTypes.Single(x => x.Identifier == "dateDefinition");

            Assert.That(datatypeDefinition, Is.TypeOf <DatatypeDefinitionDate>());
            Assert.That(datatypeDefinition.LongName, Is.EqualTo("Date"));
            Assert.That(datatypeDefinition.LastChange, Is.EqualTo(lastChange));
        }
 /// <summary>
 /// Initializes a new <see cref="ReqIfJsonConverter{T}"/>
 /// </summary>
 /// <param name="reqIf">The associated <see cref="ReqIF"/></param>
 /// <param name="session">The <see cref="ISession"/></param>
 protected ReqIfJsonConverter(ReqIF reqIf, ISession session)
 {
     this.ReqIfCoreContent = reqIf?.CoreContent;
     this.session          = session;
 }
示例#18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReqIfImportResult"/> class
 /// </summary>
 /// <param name="reqIfObject">The <see cref="ReqIF"/> object</param>
 /// <param name="iteration">The selected <see cref="Iteration"/></param>
 /// <param name="mappingConfiguration">The Selected <see cref="ImportMappingConfiguration"/></param>
 /// <param name="res">A value indicating whether the task in the </param>
 public ReqIfImportResult(ReqIF reqIfObject, Iteration iteration, ImportMappingConfiguration mappingConfiguration, bool?res) : base(res)
 {
     this.ReqIfObject          = reqIfObject;
     this.Iteration            = iteration;
     this.MappingConfiguration = mappingConfiguration;
 }
示例#19
0
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.assembler = new Assembler(this.uri);

            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            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.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);
            this.sitedir.Domain.Add(this.domain);
            this.model.Iteration.Add(this.iteration);

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

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

            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.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.assembler.Cache.TryAdd(new CacheKey(this.sitedir.Iid, null), new Lazy <Thing>(() => this.sitedir));
            this.reqIf      = new ReqIF();
            this.reqIf.Lang = "en";
            var corecontent = new ReqIFContent();

            this.reqIf.CoreContent.Add(corecontent);
            this.stringDatadef = new DatatypeDefinitionString();
            this.spectype      = new RelationGroupType();
            this.attribute     = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.spectype.SpecAttributes.Add(this.attribute);

            corecontent.DataTypes.Add(this.stringDatadef);

            this.dialog = new RelationGroupTypeMappingDialogViewModel(new List <RelationGroupType> {
                this.spectype
            }, null, new Dictionary <DatatypeDefinition, DatatypeDefinitionMap> {
                { this.stringDatadef, new DatatypeDefinitionMap(this.stringDatadef, this.pt, null) }
            }, this.iteration, this.session.Object, this.thingDialogNavigationService.Object, "en");
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }
示例#20
0
        /// <summary>
        /// Import according to a list element / file. An item contains a file reference.
        /// </summary>
        /// <param name="listNumber"></param>
        /// <param name="item"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        private bool ImportByFile(int listNumber, FileImportSettingsItem item, ref bool result)
        {
            if (item.PackageGuidList.Count == 0)
            {
                return(true);
            }
            string guid = item.PackageGuidList[0].Guid;

            _pkg = _rep.GetPackageByGuid(guid);
            if (_pkg == null)
            {
                MessageBox.Show(
                    $@"Package of import list {listNumber} with GUID='{guid}' not available.
{item.Description}
{item.Name}

Check Import settings in Settings.Json.",
                    @"Package to import into isn't available, break!");
                return(false);
            }


            string eaObjectType = item.ObjectType;
            string eaStereotype = item.Stereotype;
            string eaStatusNew  = String.IsNullOrEmpty(item.StatusNew) || item.StatusNew == "None"
                    ? ""
                    : item.StatusNew;
            string eaStatusChanged = String.IsNullOrEmpty(item.StatusChanged) || item.StatusChanged == "None"
                    ? ""
                    : item.StatusChanged;


            switch (item.ImportType)
            {
            case FileImportSettingsItem.ImportTypes.DoorsCsv:
                var doorsCsv = new DoorsCsv(_rep, _pkg, item.InputFile, item);
                result = result && doorsCsv.ImportForFile(eaObjectType, eaStereotype, eaStatusNew,
                                                          eaStatusChanged);
                //await Task.Run(() =>
                //     doorsCsv.ImportForFile(eaObjectType, eaStereotype, eaStatusNew, eaStatusChanged));
                break;

            case FileImportSettingsItem.ImportTypes.DoorsReqIf:
            case FileImportSettingsItem.ImportTypes.ReqIf:
                var doorsReqIf = new ReqIfs.ReqIfImport(_rep, _pkg, item.InputFile, item, _reqIfLogList);
                result = result && doorsReqIf.ImportForFile(eaObjectType, eaStereotype,
                                                            eaStatusNew);
                _reqIfDeserialized = doorsReqIf.ReqIfDeserialized;
                if (doorsReqIf.CountPackage > 1)
                {
                    return(result);
                }
                //await Task.Run(() =>
                //    doorsReqIf.ImportForFile(eaObjectType, eaStereotype, eaStatusNew, eaStatusChanged));
                break;



            case FileImportSettingsItem.ImportTypes.XmlStruct:
                var xmlStruct = new XmlStruct(_rep, _pkg, item.InputFile, item);
                result = result && xmlStruct.ImportForFile(eaObjectType, eaStereotype, eaStatusNew,
                                                           eaStatusChanged);
                //await Task.Run(() =>
                //    reqIf.ImportForFile(eaObjectType, eaStereotype, eaStatusNew, eaStatusChanged));
                break;
            }
            return(true);
        }
        private void SetupReqIf()
        {
            this.reqIf             = new ReqIF();
            this.reqIf.Lang        = "en";
            this.corecontent       = new ReqIFContent();
            this.reqIf.CoreContent = this.corecontent;
            this.stringDatadef     = new DatatypeDefinitionString();
            this.specificationtype = new SpecificationType();
            this.specobjecttype    = new SpecObjectType();
            this.specrelationtype  = new SpecRelationType();
            this.relationgrouptype = new RelationGroupType();

            this.specAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.reqAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };
            this.specRelationAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };
            this.relationgroupAttribute = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.specificationtype.SpecAttributes.Add(this.specAttribute);
            this.specobjecttype.SpecAttributes.Add(this.reqAttribute);
            this.specrelationtype.SpecAttributes.Add(this.specRelationAttribute);
            this.relationgrouptype.SpecAttributes.Add(this.relationgroupAttribute);

            this.specification1 = new Specification()
            {
                Type = this.specificationtype
            };
            this.specification2 = new Specification()
            {
                Type = this.specificationtype
            };

            this.specobject1 = new SpecObject()
            {
                Type = this.specobjecttype
            };
            this.specobject2 = new SpecObject()
            {
                Type = this.specobjecttype
            };

            this.specrelation = new SpecRelation()
            {
                Type = this.specrelationtype, Source = this.specobject1, Target = this.specobject2
            };
            this.relationgroup = new RelationGroup()
            {
                Type = this.relationgrouptype, SourceSpecification = this.specification1, TargetSpecification = this.specification2
            };

            this.specValue1 = new AttributeValueString()
            {
                AttributeDefinition = this.specAttribute, TheValue = "spec1"
            };
            this.specValue2 = new AttributeValueString()
            {
                AttributeDefinition = this.specAttribute, TheValue = "spec2"
            };
            this.objectValue1 = new AttributeValueString()
            {
                AttributeDefinition = this.reqAttribute, TheValue = "req1"
            };
            this.objectValue2 = new AttributeValueString()
            {
                AttributeDefinition = this.reqAttribute, TheValue = "req2"
            };
            this.relationgroupValue = new AttributeValueString()
            {
                AttributeDefinition = this.relationgroupAttribute, TheValue = "group"
            };
            this.specrelationValue = new AttributeValueString()
            {
                AttributeDefinition = this.specRelationAttribute, TheValue = "specrelation"
            };

            this.specification1.Values.Add(this.specValue1);
            this.specification2.Values.Add(this.specValue2);
            this.specobject1.Values.Add(this.objectValue1);
            this.specobject2.Values.Add(this.objectValue2);
            this.specrelation.Values.Add(this.specrelationValue);
            this.relationgroup.Values.Add(this.relationgroupValue);

            this.corecontent.DataTypes.Add(this.stringDatadef);
            this.corecontent.SpecTypes.AddRange(new SpecType[] { this.specobjecttype, this.specificationtype, this.specrelationtype, this.relationgrouptype });
            this.corecontent.SpecObjects.AddRange(new SpecObject[] { this.specobject1, this.specobject2 });
            this.corecontent.Specifications.AddRange(new Specification[] { this.specification1, this.specification2 });
            this.corecontent.SpecRelations.Add(this.specrelation);
            this.corecontent.SpecRelationGroups.Add(this.relationgroup);

            this.specification1.Children.Add(new SpecHierarchy()
            {
                Object = this.specobject1
            });
            this.specification2.Children.Add(new SpecHierarchy()
            {
                Object = this.specobject2
            });
        }
        public void Setup()
        {
            RxApp.MainThreadScheduler = Scheduler.CurrentThread;
            this.session = new Mock <ISession>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.path = Path.Combine(TestContext.CurrentContext.TestDirectory, "ReqIf", "testreq.reqif");
            this.fileDialogService = new Mock <IOpenSaveFileDialogService>();
            this.fileDialogService.Setup(x => x.GetOpenFileDialog(true, true, false, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), 1)).Returns(new string[] { this.path });
            this.reqIf = new ReqIF {
                Lang = "en"
            };
            this.reqIf.TheHeader = new ReqIFHeader()
            {
                Identifier = Guid.NewGuid().ToString()
            };
            var corecontent = new ReqIFContent();

            this.reqIf.CoreContent = corecontent;
            this.stringDatadef     = new DatatypeDefinitionString();
            this.spectype          = new SpecificationType();
            this.attribute         = new AttributeDefinitionString()
            {
                DatatypeDefinition = this.stringDatadef
            };

            this.spectype.SpecAttributes.Add(this.attribute);

            corecontent.DataTypes.Add(this.stringDatadef);

            this.settings = new RequirementsModuleSettings()
            {
                SavedConfigurations =
                {
                    new ImportMappingConfiguration()
                    {
                        ReqIfId = this.reqIf.TheHeader.Identifier, Name = "Test"
                    }
                }
            };

            this.pluginSettingService = new Mock <IPluginSettingsService>();
            this.pluginSettingService.Setup(x => x.Read <RequirementsModuleSettings>(true, It.IsAny <JsonConverter[]>())).Returns(this.settings);
            this.pluginSettingService.Setup(x => x.Read <RequirementsModuleSettings>(false)).Returns(this.settings);

            this.reqIfSerialiser = new Mock <IReqIFDeSerializer>();
            this.reqIfSerialiser.Setup(x => x.Deserialize(It.IsAny <string>(), It.IsAny <bool>(), null)).Returns(new[] { this.reqIf });
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.session.Setup(x => x.DataSourceUri).Returns(this.uri.ToString());
            this.assembler = new Assembler(this.uri);

            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            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.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);
            this.sitedir.Domain.Add(this.domain);
            this.model.Iteration.Add(this.iteration);

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

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

            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.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));

            this.dialog = new ReqIfImportDialogViewModel(new[] { this.session.Object }, new[] { this.iteration }, this.fileDialogService.Object, this.pluginSettingService.Object, this.reqIfSerialiser.Object);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }
 /// <summary>
 /// Initializes a new <see cref="SpecObjectTypeMapConverter"/>
 /// </summary>
 /// <param name="reqIf">The associated <see cref="ReqIF"/></param>
 /// <param name="session">The <see cref="ISession"/></param>
 public SpecObjectTypeMapConverter(ReqIF reqIf, ISession session) : base(reqIf, session)
 {
 }
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.assembler = new Assembler(this.uri);

            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            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.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);
            this.sitedir.Domain.Add(this.domain);
            this.model.Iteration.Add(this.iteration);

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

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

            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.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.reqIf      = new ReqIF();
            this.reqIf.Lang = "en";
            var corecontent = new ReqIFContent();

            this.reqIf.CoreContent = corecontent;
            this.stringDatadef     = new DatatypeDefinitionString();
            this.boolDatadef       = new DatatypeDefinitionBoolean();
            this.intDatadef        = new DatatypeDefinitionInteger();
            this.realDatadef       = new DatatypeDefinitionReal();
            this.enumDatadef       = new DatatypeDefinitionEnumeration();
            this.enumDatadef.SpecifiedValues.Add(new EnumValue {
                Properties = new EmbeddedValue {
                    Key = 1, OtherContent = "enum1"
                }
            });

            this.dateDatadef = new DatatypeDefinitionDate();

            corecontent.DataTypes.Add(this.stringDatadef);
            corecontent.DataTypes.Add(this.boolDatadef);
            corecontent.DataTypes.Add(this.dateDatadef);
            corecontent.DataTypes.Add(this.enumDatadef);
            corecontent.DataTypes.Add(this.intDatadef);
            corecontent.DataTypes.Add(this.realDatadef);

            this.dialog = new ParameterTypeMappingDialogViewModel(this.reqIf.Lang, corecontent.DataTypes, null, this.iteration, this.session.Object, this.thingDialogNavigationService.Object);
            this.session.Setup(x => x.RetrieveSiteDirectory()).Returns(this.sitedir);
        }
示例#25
0
 /// <summary>
 /// Initializes a new <see cref="SpecRelationTypeMapConverter"/>
 /// </summary>
 /// <param name="reqIf">The associated <see cref="ReqIF"/></param>
 /// <param name="session">The <see cref="ISession"/></param>
 public SpecRelationTypeMapConverter(ReqIF reqIf, ISession session) : base(reqIf, session)
 {
 }
 /// <summary>
 /// Initializes a new <see cref="RelationGroupTypeMapConverter"/>
 /// </summary>
 /// <param name="reqIf">The associated <see cref="ReqIF"/></param>
 /// <param name="session">The <see cref="ISession"/></param>
 public RelationGroupTypeMapConverter(ReqIF reqIf, ISession session) : base(reqIf, session)
 {
 }
        public void Setup()
        {
            this.session = new Mock <ISession>();
            this.dialogNavigationService      = new Mock <IDialogNavigationService>();
            this.thingDialogNavigationService = new Mock <IThingDialogNavigationService>();
            this.permissionService            = new Mock <IPermissionService>();
            this.pluginSettingsService        = new Mock <IPluginSettingsService>();
            this.session.Setup(x => x.PermissionService).Returns(this.permissionService.Object);
            this.assembler = new Assembler(this.uri);

            this.sitedir        = new SiteDirectory(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.modelsetup     = new EngineeringModelSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.iterationSetup = new IterationSetup(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.domain         = new DomainOfExpertise(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.srdl           = new SiteReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri);
            this.mrdl           = new ModelReferenceDataLibrary(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                RequiredRdl = this.srdl
            };
            this.sitedir.SiteReferenceDataLibrary.Add(this.srdl);
            this.modelsetup.RequiredRdl.Add(this.mrdl);

            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.sitedir.Model.Add(this.modelsetup);
            this.modelsetup.IterationSetup.Add(this.iterationSetup);
            this.sitedir.Domain.Add(this.domain);
            this.model.Iteration.Add(this.iteration);

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

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

            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.Assembler).Returns(this.assembler);

            this.assembler.Cache.TryAdd(new CacheKey(this.iteration.Iid, null), new Lazy <Thing>(() => this.iteration));
            this.reqIf           = new ReqIF();
            this.reqIf.TheHeader = new ReqIFHeader()
            {
                Title = "test"
            };
            this.reqIf.Lang = "en";
            var corecontent = new ReqIFContent();

            this.reqIf.CoreContent = corecontent;
            this.datatypedef       = new DatatypeDefinitionString();
            this.spectype          = new SpecificationType();
            this.specobjecttype    = new SpecObjectType();

            corecontent.DataTypes.Add(this.datatypedef);
            corecontent.SpecTypes.Add(this.spectype);
            corecontent.SpecTypes.Add(this.specobjecttype);

            this.importMappingManager = new ReqIfImportMappingManager(
                this.reqIf,
                this.session.Object,
                this.iteration,
                this.domain,
                this.dialogNavigationService.Object,
                this.thingDialogNavigationService.Object);

            this.serviceLocator = new Mock <IServiceLocator>();
            this.serviceLocator.Setup(x => x.GetInstance <IPluginSettingsService>()).Returns(this.pluginSettingsService.Object);
            ServiceLocator.SetLocatorProvider(() => this.serviceLocator.Object);
        }
示例#28
0
 /// <summary>
 /// Initializes a new <see cref="DataTypeDefinitionMapConverter"/>
 /// </summary>
 /// <param name="reqIf">The associated <see cref="ReqIF"/></param>
 /// <param name="session">The <see cref="ISession"/></param>
 public DataTypeDefinitionMapConverter(ReqIF reqIf, ISession session) : base(reqIf, session)
 {
 }
示例#29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ReqIfImportResult"/> class
 /// </summary>
 /// <param name="reqIfObject">The <see cref="ReqIF"/> object</param>
 /// <param name="iteration">The selected <see cref="Iteration"/></param>
 /// <param name="res">A value indicating whether the task in the </param>
 public ReqIfImportResult(ReqIF reqIfObject, Iteration iteration, bool?res) : base(res)
 {
     this.ReqIfObject = reqIfObject;
     this.Iteration   = iteration;
 }