Пример #1
0
        /// <summary>
        /// Adds version info to version info package
        /// </summary>
        /// <param name="elUseCase"></param>
        private int ProcessVersionInfo(string strUseCasePath, string strPackageName, EA.Package eAMainPackage, XElement elUseCase, EA.Diagram diagram)
        {
            int iErrorCount = 0;

            EA.Package eaPackageVersions = EAImporter.m_Packages.Add(strUseCasePath, strPackageName, "");
            if (eaPackageVersions == null)
            {
                iErrorCount++;
            }
            ;

            if (eaPackageVersions != null)
            {
                IEnumerable <XElement> elVersions = elUseCase.Elements("VersionInformation");

                foreach (XElement elVersionInformation in elVersions)
                {
                    ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                    oFieldsValidator.Add(new FieldInfo("approvalStatus", elVersionInformation));
                    oFieldsValidator.Add(new FieldInfo("areaOfExpertise", elVersionInformation));
                    oFieldsValidator.Add(new FieldInfo("changes", elVersionInformation, "", true, false, true));
                    oFieldsValidator.Add(new FieldInfo("date", elVersionInformation, "", true, true, false));
                    oFieldsValidator.Add(new FieldInfo("domainExpert", elVersionInformation));
                    oFieldsValidator.Add(new FieldInfo("name", elVersionInformation, "", false));
                    oFieldsValidator.Add(new FieldInfo("title", elVersionInformation));

                    int iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageVersions, diagram, oFieldsValidator, EAImporter.m_iVersionInfoBaseClsID, "VersionInformation");

                    iErrorCount = iErrorCount + iErrCnt;
                }
            }

            return(iErrorCount);
        }
Пример #2
0
        private int ProcessAdditionalDomains(string strUseCasePath, string strPackageName, EA.Package eAMainPackage, XElement elUseCase, EA.Diagram diagram)
        {
            int iErrorCount = 0;

            EA.Package eaPackageVersions = EAImporter.m_Packages.Add(strUseCasePath, strPackageName, "");
            if (eaPackageVersions == null)
            {
                iErrorCount++;
            }
            ;

            if (eaPackageVersions != null)
            {
                IEnumerable <XElement> elVersions = elUseCase.Elements("AdditionalDomain");

                foreach (XElement elVersionInformation in elVersions)
                {
                    ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                    oFieldsValidator.Add(new FieldInfo("name", elVersionInformation, "", true, true, false));

                    int iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageVersions, diagram, oFieldsValidator, EAImporter.m_iRef_DomainBaseClsID, "AdditionalDomain");

                    iErrorCount = iErrorCount + iErrCnt;
                }
            }

            return(iErrorCount);
        }
Пример #3
0
        /// <summary>
        /// Adds version info to version info package
        /// </summary>
        /// <param name="elUseCase"></param>
        private int ProcessReferenceInfo(string strUseCasePath, string strPackageName, EA.Package eAMainPackage, XElement elUseCase, EA.Diagram diagram)
        {
            int iErrorCount = 0;

            EA.Package eaPackageReferences = EAImporter.m_Packages.Add(strUseCasePath, strPackageName, "");
            if (eaPackageReferences == null)
            {
                iErrorCount++;
            }
            ;

            if (eaPackageReferences != null)
            {
                IEnumerable <XElement> elReferneces = elUseCase.Elements("Reference");

                foreach (XElement elReference in elReferneces)
                {
                    ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                    oFieldsValidator.Add(new FieldInfo("description", elReference, "", true, false, true));
                    oFieldsValidator.Add(new FieldInfo("id", elReference, "", true, true, false));
                    oFieldsValidator.Add(new FieldInfo("impact", elReference));
                    oFieldsValidator.Add(new FieldInfo("originatorOrganisation", elReference));
                    oFieldsValidator.Add(new FieldInfo("status", elReference, "", false));
                    oFieldsValidator.Add(new FieldInfo("type", elReference));
                    oFieldsValidator.Add(new FieldInfo("URI", elReference));

                    int iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageReferences, diagram, oFieldsValidator, EAImporter.m_iReferenceInfoBaseClsID, "ReferenceInformation");

                    iErrorCount = iErrorCount + iErrCnt;
                }
            }

            return(iErrorCount);
        }
Пример #4
0
        /// <summary>
        /// ProcessInformationClasses
        /// </summary>
        /// <param name="el"></param>
        public int Import(XElement el, EA.Package eaInfoClassPackage)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                return(iErrorCount);
            }

            IEnumerable <XElement> elInfoClasses = el.Elements("InformationModel");

            foreach (XElement elInfoClass in elInfoClasses)
            {
                Application.DoEvents();

                ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                oFieldsValidator.Add(new FieldInfo("name", elInfoClass));
                oFieldsValidator.Add(new FieldInfo("description", elInfoClass, "", false, false, true));


                string strRequirements = "";

                EA.Package oRequirements = EAImporter.m_Packages.Add("UseCaseRepository", "RequirementLibrary");

                IEnumerable <XElement> elRequirements = elInfoClass.Elements("referencedRequirement");
                foreach (XElement elRequirement in elRequirements)
                {
                    string strID = elRequirement.Element("id").Value;

                    strRequirements = strRequirements + "," + strID;

                    EAImporter.m_Requirements.AddInformationClass(oRequirements, strID, "");
                }

                if (strRequirements != "")
                {
                    strRequirements = strRequirements.Remove(0, 1);
                }

                int iErrCnt = oFieldsValidator.ParseAndValidateFields("Information Class");

                if (iErrCnt == 0)
                {
                    oFieldsValidator.ReplaceImageLinks("UseCaseRepository/InformationModelLibrary/" + oFieldsValidator["name"].Value);

                    iErrorCount = iErrorCount + AddInformationClass(eaInfoClassPackage, oFieldsValidator["name"].Value, oFieldsValidator["description"].Value, strRequirements);
                }
                else
                {
                    iErrorCount = iErrorCount + iErrCnt;
                }
            }

            return(iErrorCount);
        }
Пример #5
0
        /// <summary>
        /// Import
        /// </summary>
        /// <param name="el"></param>
        public int Import(XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "No actors to import ");
                return(iErrorCount);
            }

            foreach (XElement elDomain in el.Elements("Domain"))
            {
                ImportFieldsValidator oFieldsValidatorDomain = new ImportFieldsValidator();
                oFieldsValidatorDomain.Add(new FieldInfo("name", elDomain));

                int iErrCnt = oFieldsValidatorDomain.ParseAndValidateFields("Actor Category");
                if (iErrCnt != 0)
                {
                    iErrorCount = iErrorCount + iErrCnt;
                }
                else
                {
                    IEnumerable <XElement> elActors = elDomain.Elements("Actor");

                    foreach (XElement elActor in elActors)
                    {
                        Application.DoEvents();

                        ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                        oFieldsValidator.Add(new FieldInfo("name", elActor));
                        oFieldsValidator.Add(new FieldInfo("type", elActor));
                        oFieldsValidator.Add(new FieldInfo("description", elActor, "", false, false, true));
                        oFieldsValidator.Add(new FieldInfo("furtherInformation", elActor, "", false));

                        iErrCnt = oFieldsValidator.ParseAndValidateFields("Actor");

                        if (iErrCnt == 0)
                        {
                            oFieldsValidator.ReplaceImageLinks("UseCaseRepository/ActorLibrary" + "/" + oFieldsValidatorDomain["name"].Value + "/" + oFieldsValidator["name"].Value);

                            AddStereotype(elActor.Element("type").Value);

                            iErrorCount = iErrorCount + AddActor(EAImporter.m_Packages["UseCaseRepository/ActorLibrary" + "/" + oFieldsValidatorDomain["name"].Value], oFieldsValidator);
                        }
                        else
                        {
                            iErrorCount = iErrorCount + iErrCnt;
                        }
                    }
                }
            }

            return(iErrorCount);
        }
Пример #6
0
        /// <summary>
        /// ImportDomains
        /// </summary>
        /// <param name="el"></param>
        public int Import(XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "No domains to import");
                return(0);
            }

            IEnumerable <XElement> elDomains = el.Elements("Domain");

            foreach (XElement elDomain in elDomains)
            {
                Application.DoEvents();

                ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                oFieldsValidator.Add(new FieldInfo("name", elDomain, "name"));
                oFieldsValidator.Add(new FieldInfo("description", elDomain, "description", false, false, true));

                int iErrCnt = oFieldsValidator.ParseAndValidateFields("Actor Grouping/Domain");

                if (iErrCnt == 0)
                {
                    oFieldsValidator.ReplaceImageLinks("UseCaseRepository/DomainLibrary" + "/" + oFieldsValidator["name"].Value);

                    EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Importing domain: " + oFieldsValidator["name"].Value);
                    if (EAImporter.m_Packages.Add("UseCaseRepository/DomainLibrary", oFieldsValidator["name"].Value, oFieldsValidator["description"].Value, elDomain) == null)
                    {
                        iErrorCount++;
                    }
                    ;
                    if (EAImporter.m_Packages.Add("UseCaseRepository/ActorLibrary", oFieldsValidator["name"].Value, "", elDomain) == null)
                    {
                        iErrorCount++;
                    }
                    ;
                }

                iErrorCount = iErrorCount + iErrCnt;
            }

            return(iErrorCount);
        }
Пример #7
0
        private int AddActor(EA.Package eaPackage, ImportFieldsValidator oFieldsValidator)
        {
            string strName       = oFieldsValidator["name"].Value;
            string strStereotype = oFieldsValidator["type"].Value;
            string strNotes      = oFieldsValidator["description"].Value;

            string strLogInfo = "Actor: " + strName;

            int iErrorCount = 0;

            EA.Element element1 = null;
            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            if (m_ActorsStruct[strName] != null)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
                return(0);
            }

            if (eaPackage == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, "cannot add actor- package does not exist " + strName);
                return(1);
            }

            try
            {
                element1 = eaPackage.Elements.GetByName(strName);
            }
            catch (Exception ex)
            {
                EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
            }

            if (element1 == null)
            {
                element1 = eaPackage.Elements.AddNew(strName, "Actor");
                eaPackage.Update();
                eaPackage.Elements.Refresh();
                element1.Notes        = strNotes;
                element1.StereotypeEx = strStereotype;

                //EA.Element eIntfc = element1.Elements.AddNew(strName, "Interface");
                EA.Element eIntfc = element1.Elements.AddNew(strName, "Class");
                eIntfc.Update();
                element1.Update();
                element1.Elements.Refresh();

                EA.Element source = eIntfc;
                EA.Element target = element1;

                EA.Connector con = source.Connectors.AddNew("realizes", "Realization");

                con.SupplierID = target.ElementID;
                con.Update();
                source.Connectors.Refresh();

                EA.Connector con2 = source.Connectors.AddNew("", "Generalization");

                con2.SupplierID = EAImporter.m_iActorBaseClsID;
                con2.Update();
                source.Connectors.Refresh();

                ActorInformation oActorInfo = new ActorInformation();
                oActorInfo.m_eaEl             = element1;
                oActorInfo.m_oFieldsValidator = oFieldsValidator;

                m_ActorsStruct[strName] = oActorInfo;

                element1.Update();
                eIntfc.Update();

                EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            }
            else
            {
                ActorInformation oActorInfo = new ActorInformation();
                oActorInfo.m_eaEl             = element1;
                oActorInfo.m_oFieldsValidator = oFieldsValidator;
                m_ActorsStruct[strName]       = oActorInfo;

                EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo);
            }
            return(iErrorCount);
        }
Пример #8
0
        /// <summary>
        /// Adds new package for use case and populates all children
        /// </summary>
        /// <param name="elUseCase"></param>
        public int ProcessUseCase(XElement elUseCase)
        {
            int iErrorCount = 0;

            // check if use case node exists --

            if (elUseCase == null)
            {
                return(iErrorCount);
            }

            ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

            // Only Process Use Case "flat Elements" here
            oFieldsValidator.Add(new FieldInfo("id", elUseCase));
            oFieldsValidator.Add(new FieldInfo("name", elUseCase));
            oFieldsValidator.Add(new FieldInfo("classification", elUseCase));
            oFieldsValidator.Add(new FieldInfo("keywords", elUseCase));
            oFieldsValidator.Add(new FieldInfo("levelOfDepth", elUseCase));
            oFieldsValidator.Add(new FieldInfo("prioritisation", elUseCase));
            oFieldsValidator.Add(new FieldInfo("scope", elUseCase, "", false, false, true));
            oFieldsValidator.Add(new FieldInfo("viewPoint", elUseCase));
            // Narrative
            oFieldsValidator.Add(new FieldInfo("completeDescription", elUseCase.Element("Narrative"), "", true, false, true));
            oFieldsValidator.Add(new FieldInfo("shortDescription", elUseCase.Element("Narrative")));
            // PrimaryDomain
            oFieldsValidator.Add(new FieldInfo("PrimaryDomain", elUseCase.Element("PrimaryDomain"), "name"));

            iErrorCount = iErrorCount + oFieldsValidator.ParseAndValidateFields("general use case information");

            //if (iErrCnt == 0)
            //{
            string strPrimaryDomain = "";
            string strID            = "";
            string strName          = "";

            if (oFieldsValidator["PrimaryDomain"].Value == "")
            {
                strPrimaryDomain = "STUB";
            }
            else
            {
                strPrimaryDomain = oFieldsValidator["PrimaryDomain"].Value;
            }

            if (oFieldsValidator["id"].Value == "")
            {
                strID = "STUB";
            }
            else
            {
                strID = oFieldsValidator["id"].Value;
            }

            if (oFieldsValidator["name"].Value == "")
            {
                strName = "STUB";
            }
            else
            {
                strName = oFieldsValidator["name"].Value;
            }

            string strUseCasePath = "UseCaseRepository/UseCaseLibrary/ImportedUseCase/" + strPrimaryDomain + "/" + strID + " " + strName;

            oFieldsValidator.ReplaceImageLinks(strUseCasePath);

            if (EAImporter.m_Packages.Add("UseCaseRepository/UseCaseLibrary", "ImportedUseCase") == null)
            {
                iErrorCount++;
            }
            ;

            if (EAImporter.m_Packages.Add("UseCaseRepository/UseCaseLibrary/ImportedUseCase", strPrimaryDomain) == null)
            {
                iErrorCount++;
            }
            ;

            // see if use case package already exists
            try
            {
                EA.Package oPackage = ((EA.Package)EAImporter.m_Packages["UseCaseRepository/UseCaseLibrary/ImportedUseCase/" + strPrimaryDomain]).Packages.GetByName(strID + " " + strName);
                if (oPackage != null)
                {
                    EAImporter.LogError(EAImporter.LogErrorLevel.A, "Use case package " + "UseCaseRepository/UseCaseLibrary/ImportedUseCase/" + strPrimaryDomain + "/" + strID + " " + strName + " already exists.");
                    strName        = "STUB"; // allow processing to continue
                    strUseCasePath = "UseCaseRepository/UseCaseLibrary/ImportedUseCase/" + strPrimaryDomain + "/" + strID + " " + strName;
                    iErrorCount++;
                }
            }
            catch (Exception ex)
            {
                //EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message);
            }

            EA.Package eaPackageUseCase = EAImporter.m_Packages.Add("UseCaseRepository/UseCaseLibrary/ImportedUseCase/" + strPrimaryDomain, strID + " " + strName);
            if (eaPackageUseCase == null)
            {
                iErrorCount++;
            }
            ;

            EA.Package eaPackageEnterprise = EAImporter.m_Packages.Add(strUseCasePath, "Enterprise", "");
            if (eaPackageEnterprise == null)
            {
                iErrorCount++;
            }
            ;

            if (EAImporter.m_Packages.Add(strUseCasePath, "Computation", "") == null)
            {
                iErrorCount++;
            }
            ;

            if (EAImporter.m_Packages.Add(strUseCasePath, "Technology", "") == null)
            {
                iErrorCount++;
            }
            ;

            if (EAImporter.m_Packages.Add(strUseCasePath, "Engineering", "") == null)
            {
                iErrorCount++;
            }
            ;

            if (EAImporter.m_Packages.Add(strUseCasePath, "Information", "") == null)
            {
                iErrorCount++;
            }
            ;


            // the following commented code was used prototyping artifacts and notes as attached rtf files.

            //EA.Element eaArtifact = m_Packages["UseCaseRepository/UseCaseLibrary/ImportedUseCase"].Elements.AddNew("Notes", "Artifact");
            //string strTemp = oFieldsValidator["completeDescription"].Value;
            ///*strTemp.Replace("&lt;", "<");
            //strTemp.Replace("&gt;", ">");*/
            ////strTemp.Replace("\n", Convert.ToString(13)+Convert.ToString(10));
            //eaArtifact.Notes = strTemp;

            // // Create/import rtf linked document
            ////string strHTMLHead = File.ReadAllText(@"D:\_project\EPRI\C18322-EPRIUseCaseRepository\Source\Template\ArtifactFragmentTemplateHead.html");
            ////string strHTMLTail = File.ReadAllText(@"D:\_project\EPRI\C18322-EPRIUseCaseRepository\Source\Template\ArtifactFragmentTemplateTail.html");

            ////string strFullHTML = strHTMLHead + oFieldsValidator["Description"].Value + strHTMLTail;

            ////File.WriteAllText(@"D:\_project\EPRI\C18322-EPRIUseCaseRepository\Source\Template\Artifact1.html", strFullHTML);

            ////m_oWord.Visible = false;
            ////m_oWord.Documents.Open(@"D:\_project\EPRI\C18322-EPRIUseCaseRepository\Source\Template\Artifact1.html");
            ////m_oWord.Documents[1].SaveAs(@"D:\_project\EPRI\C18322-EPRIUseCaseRepository\Source\Template\Artifact1.rtf", Word.WdSaveFormat.wdFormatRTF);
            ////m_oWord.Documents.Close();
            ////m_oWord.Visible = false;
            ////eaArtifact.LoadLinkedDocument(@"D:\_project\EPRI\C18322-EPRIUseCaseRepository\Source\Template\Artifact1.rtf");
            //eaArtifact.Update();

            // create diagram for all UC elements to display attribute values
            EA.Diagram diagram = EAImporter.AddDiagram(eaPackageUseCase, "Use Case Components", "Object");

            // process sequences here
            iErrorCount = iErrorCount + m_Sequences.Import(strUseCasePath + "/Computation", elUseCase);

            // process Activities here
            iErrorCount = iErrorCount + m_Activities.Import(strUseCasePath + "/Computation", elUseCase);

            // process Use Case Elements
            EA.Element elUCClassElement = null;
            iErrorCount = iErrorCount + ProcessUseCaseFlatAttributes(eaPackageEnterprise, eaPackageUseCase, oFieldsValidator, diagram, ref elUCClassElement);

            // Process Narrative
            iErrorCount = iErrorCount + ProcessNarrative(eaPackageEnterprise, eaPackageUseCase, oFieldsValidator, diagram);

            // Process Version Information
            iErrorCount = iErrorCount + ProcessVersionInfo(strUseCasePath + "/Enterprise", "Versions", eaPackageEnterprise, elUseCase, diagram);

            // Process References Information
            iErrorCount = iErrorCount + ProcessReferenceInfo(strUseCasePath + "/Enterprise", "References", eaPackageEnterprise, elUseCase, diagram);

            // Conditions
            iErrorCount = iErrorCount + ProcessConditions(strUseCasePath + "/Enterprise", "Conditions", eaPackageEnterprise, elUseCase, diagram);

            // General Remarks
            iErrorCount = iErrorCount + ProcessRemarks(strUseCasePath + "/Enterprise", "GeneralRemarks", eaPackageEnterprise, elUseCase, diagram);

            // RelatedObjectives
            iErrorCount = iErrorCount + ProcessObjectives(strUseCasePath + "/Enterprise", "RelatedObjectives", eaPackageEnterprise, elUseCase, diagram);

            // RelatedBusinessCases
            iErrorCount = iErrorCount + ProcessBusinessCases(strUseCasePath + "/Enterprise", "RelatedBusinessCases", eaPackageEnterprise, elUseCase, diagram);

            // Additional Domains
            iErrorCount = iErrorCount + ProcessAdditionalDomains(strUseCasePath + "/Enterprise", "AdditionalDomains", eaPackageEnterprise, elUseCase, diagram);

            // UseCaseRelation
            iErrorCount = iErrorCount + ProcessRelations(strUseCasePath + "/Enterprise", "UseCaseRelations", eaPackageEnterprise, elUseCase, diagram);

            // UseCase Diagram
            iErrorCount = iErrorCount + CreateUseCaseDigram(strID + " " + strName, eaPackageEnterprise, elUseCase, elUCClassElement);

            EAImporter.m_Packages["UseCaseRepository/UseCaseLibrary/ImportedUseCase"].Elements.Refresh();
            //}

            //iErrorCount = iErrorCount + iErrCnt;

            return(iErrorCount);
        }
Пример #9
0
        private int ProcessSequenceStep(EA.Package theStepsPackage, EA.Diagram diagram, XElement elStep, ref int iSeqNo, ref int iDiagObjNo)
        {
            int    iErrorCount      = 0;
            string strOperationName = "";
            string strFirstStep     = "";
            string strLastStep      = "";

            ImportFieldsValidator oFieldsValidator = SequenceStepGetFields(elStep, ref strOperationName, ref strFirstStep, ref strLastStep);

            if (oFieldsValidator.ErrorCount == 0)
            {
                if (strOperationName == "REPEAT")
                {
                    EA.Element theFragment = theStepsPackage.Elements.AddNew("RepeatSteps", "InteractionFragment");
                    theFragment.Stereotype = "loop";
                    theFragment.Notes      = oFieldsValidator["event"].Value;
                    theFragment.Update();
                    theStepsPackage.Elements.Refresh();

                    int iFirstObject = 0;
                    int iLastObject  = iDiagObjNo - 1;
                    int iFirstStep   = int.Parse(strFirstStep) - 1;
                    int iLastStep    = int.Parse(strLastStep) - 1;

                    AddDiagramInteractionFragment(diagram, theFragment.ElementID, iFirstObject, iLastObject, iFirstStep, iLastStep);
                }
                else if (strOperationName == "TIMER")
                {
                    bool       bValid = true;
                    EA.Element eActorIntfc_Producer_Source = EAImporter.m_Actors.GetActorInterface(oFieldsValidator["Producer"].Value);
                    if (eActorIntfc_Producer_Source == null)
                    {
                        EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information producer \"" + oFieldsValidator["Producer"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                        iErrorCount++;
                        bValid = false;
                    }

                    if (bValid)
                    {
                        // add operation to target actor interface
                        AddOperation(eActorIntfc_Producer_Source, strOperationName, oFieldsValidator["InformationExchanged"].Value);

                        EA.Element eElObjProducer = null;

                        eElObjProducer = AddObjIntfcInstance(diagram, theStepsPackage, oFieldsValidator["Producer"].Value, eActorIntfc_Producer_Source.ElementID, ref iDiagObjNo);

                        string strFullOpName = strOperationName + "(" + oFieldsValidator["InformationExchanged"].Value + ")";

                        AddConnector(diagram, eElObjProducer, strFullOpName, oFieldsValidator["event"].Value, eElObjProducer.ElementID, iSeqNo, oFieldsValidator["description"].Value);

                        EAImporter.m_Actors.MarkActorUseCaseRef(oFieldsValidator["Producer"].Value);
                    }
                }
                else
                {
                    bool       bValid = true;
                    EA.Element eActorIntfc_Producer_Source = EAImporter.m_Actors.GetActorInterface(oFieldsValidator["Producer"].Value);
                    if (eActorIntfc_Producer_Source == null)
                    {
                        EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information producer \"" + oFieldsValidator["Producer"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                        iErrorCount++;
                        bValid = false;
                    }

                    EA.Element eActorIntfc_Receiver_Target = EAImporter.m_Actors.GetActorInterface(oFieldsValidator["Receiver"].Value);
                    if (eActorIntfc_Receiver_Target == null)
                    {
                        EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information receiver \"" + oFieldsValidator["Receiver"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                        iErrorCount++;
                        bValid = false;
                    }
                    if (bValid)
                    {
                        // check if info objec exists:
                        if (EAImporter.m_InfoModels.Get(oFieldsValidator["InformationExchanged"].Value) == null)
                        {
                            EAImporter.LogError(EAImporter.LogErrorLevel.A, "Invalid information exchanged \"" + oFieldsValidator["InformationExchanged"].Value + "\" for element:" + EAImporter.Recurse(elStep));
                            iErrorCount++;
                        }
                        else
                        {
                            // add operation to target actor interface
                            AddOperation(eActorIntfc_Receiver_Target, strOperationName, oFieldsValidator["InformationExchanged"].Value);

                            EA.Element eElObjProducer = null;
                            EA.Element eElObjReceiver = null;

                            eElObjProducer = AddObjIntfcInstance(diagram, theStepsPackage, oFieldsValidator["Producer"].Value, eActorIntfc_Producer_Source.ElementID, ref iDiagObjNo);

                            eElObjReceiver = AddObjIntfcInstance(diagram, theStepsPackage, oFieldsValidator["Receiver"].Value, eActorIntfc_Receiver_Target.ElementID, ref iDiagObjNo);

                            string strFullOpName = strOperationName + "(" + oFieldsValidator["InformationExchanged"].Value + ")";

                            AddConnector(diagram, eElObjProducer, strFullOpName, oFieldsValidator["event"].Value, eElObjReceiver.ElementID, iSeqNo, oFieldsValidator["description"].Value);

                            EAImporter.m_Actors.MarkActorUseCaseRef(oFieldsValidator["Producer"].Value);
                            EAImporter.m_Actors.MarkActorUseCaseRef(oFieldsValidator["Receiver"].Value);
                        }
                    }
                }

                diagram.Update();

                theStepsPackage.Diagrams.Refresh();
                diagram.DiagramObjects.Refresh();

                iSeqNo++;
            }
            else
            {
                iErrorCount = iErrorCount + oFieldsValidator.ErrorCount;
            }

            return(iErrorCount);
        }
        private ImportFieldsValidator LoadFields(XElement elStep, ref string strOperationName, ref string strPrimaryActor, ref string strSecondaryActor, ref string strFirstStep, ref string strLastStep)
        {
            ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

            oFieldsValidator.Add(new FieldInfo("service", elStep));
            oFieldsValidator.Add(new FieldInfo("number", elStep));
            // oFieldsValidator.Add(new FieldInfo("Requirement", elStep.Element("Requirement"),"id",false));

            string strRequirements = "";

            EA.Package oRequirements = EAImporter.m_Packages.Add("UseCaseRepository", "RequirementLibrary");

            IEnumerable <XElement> elRequirements = elStep.Elements("Requirement");

            foreach (XElement elRequirement in elRequirements)
            {
                string strID = elRequirement.Element("id").Value;

                strRequirements = strRequirements + "," + strID;

                EAImporter.m_Requirements.AddInformationClass(oRequirements, strID, "");
            }

            if (strRequirements != "")
            {
                strRequirements = strRequirements.Remove(0, 1);
            }

            oFieldsValidator.Add(new FieldInfo("requirements", strRequirements));

            if (oFieldsValidator.ParseAndValidateFields("Scenario") != 0)
            {
                // "Service" is required
                return(oFieldsValidator);
            }

            if (oFieldsValidator["service"].Value.StartsWith("REPEAT"))
            {
                strOperationName = "REPEAT";
                string strServiceStripped = oFieldsValidator["service"].Value;
                strServiceStripped = strServiceStripped.Replace("REPEAT", "");
                strServiceStripped = strServiceStripped.Replace("(", "");
                strServiceStripped = strServiceStripped.Replace(")", "");

                string[] strSteps = strServiceStripped.Split('-');

                if (strSteps.Length != 2)
                {
                    EAImporter.LogError(EAImporter.LogErrorLevel.A, "REPEAT invalid arguments : " + oFieldsValidator["service"].Value);
                    return(oFieldsValidator);
                }
                else
                {
                    strFirstStep = strSteps[0];
                    strLastStep  = strSteps[1];
                }
            }
            else
            {
                strOperationName = oFieldsValidator["service"].Value;
            }

            oFieldsValidator.Add(new FieldInfo("event", elStep, "", false));
            oFieldsValidator.Add(new FieldInfo("description", elStep));

            if (strOperationName == "REPEAT")
            {
                // no other fields required
            }
            else if (strOperationName == "TIMER")
            {
                oFieldsValidator.Add(new FieldInfo("name", elStep));
                oFieldsValidator.Add(new FieldInfo("Producer", elStep.Element("InformationProducer"), "name"));
                oFieldsValidator.Add(new FieldInfo("InformationExchanged", elStep.Element("InformationModel"), "name"));
                oFieldsValidator.Add(new FieldInfo("Step", elStep, "number"));
                //    oFieldsValidator.Add(new FieldInfo("TechRequirementsID", elStep.Element("Requirement"), "name", false));
            }
            else
            {
                oFieldsValidator.Add(new FieldInfo("name", elStep));
                oFieldsValidator.Add(new FieldInfo("Producer", elStep.Element("InformationProducer"), "name"));
                oFieldsValidator.Add(new FieldInfo("Receiver", elStep.Element("InformationReceiver"), "name"));
                oFieldsValidator.Add(new FieldInfo("InformationExchanged", elStep.Element("InformationModel"), "name"));
                oFieldsValidator.Add(new FieldInfo("Step", elStep, "number"));
                //    oFieldsValidator.Add(new FieldInfo("TechRequirementsID", elStep.Element("Requirement"), "name", false));
            }


            if (oFieldsValidator.ParseAndValidateFields("Scenario") == 0)
            {
                if (strOperationName == "CREATE")
                {
                    strPrimaryActor   = oFieldsValidator["Producer"].Value;
                    strSecondaryActor = oFieldsValidator["Receiver"].Value;
                }
                else if ((strOperationName == "READ") || (strOperationName == "GET"))
                {
                    strPrimaryActor   = oFieldsValidator["Receiver"].Value;
                    strSecondaryActor = oFieldsValidator["Producer"].Value;
                }
                else if ((strOperationName == "UPDATE") || (strOperationName == "CHANGE"))
                {
                    strPrimaryActor   = oFieldsValidator["Producer"].Value;
                    strSecondaryActor = oFieldsValidator["Receiver"].Value;
                }
                else if (strOperationName == "EXECUTE")
                {
                    strPrimaryActor   = oFieldsValidator["Producer"].Value;
                    strSecondaryActor = oFieldsValidator["Receiver"].Value;
                }
                else if (strOperationName == "DELETE")
                {
                    strPrimaryActor   = oFieldsValidator["Producer"].Value;
                    strSecondaryActor = oFieldsValidator["Receiver"].Value;
                }
                else if ((strOperationName == "REPORT") || (strOperationName == "REPLY"))
                {
                    strPrimaryActor   = oFieldsValidator["Producer"].Value;
                    strSecondaryActor = oFieldsValidator["Receiver"].Value;
                }
                else if (strOperationName == "TIMER")
                {
                    strPrimaryActor = oFieldsValidator["Producer"].Value;
                    //strSecondaryActor = oFieldsValidator["Receiver"].Value;
                }
                else if (strOperationName == "REPEAT")
                {
                    strPrimaryActor = "";
                }
            }

            return(oFieldsValidator);
        }
Пример #11
0
        private int ProcessConditions(string strUseCasePath, string strPackageName, EA.Package eAMainPackage, XElement elUseCase, EA.Diagram diagram)
        {
            int iErrorCount = 0;

            EA.Package eaPackageConditions = EAImporter.m_Packages.Add(strUseCasePath, strPackageName, "");
            if (eaPackageConditions == null)
            {
                iErrorCount++;
            }
            ;

            if (eaPackageConditions != null)
            {
                IEnumerable <XElement> elConditions = elUseCase.Elements("Condition");
                int idx = 1;
                foreach (XElement elCondition in elConditions)
                {
                    ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();
                    oFieldsValidator.Add(new FieldInfo("assumption", elCondition, "", false));
                    oFieldsValidator.Add(new FieldInfo("trigerringEvent", elCondition, "", false));

                    int iErrCnt = oFieldsValidator.ParseAndValidateFields("Use Case Conditions");

                    if (iErrCnt == 0)
                    {
                        string strConditionName = "Condition_" + idx;

                        EA.Package eaPackageCondition = EAImporter.m_Packages.Add(strUseCasePath + "/Conditions", strConditionName, "");
                        if (eaPackageCondition == null)
                        {
                            iErrorCount++;
                        }
                        ;

                        if (eaPackageCondition != null)
                        {
                            //                           iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName,eAMainPackage, eaPackageCondition, diagram, oFieldsValidator, EAImporter.m_iConditionBaseClsID, "Condition", strConditionName);
                            iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageCondition, diagram, oFieldsValidator, EAImporter.m_iConditionBaseClsID, "Condition", "Condition");

                            iErrorCount = iErrorCount + iErrCnt;
                        }

                        IEnumerable <XElement> elPreConditions = elCondition.Elements("PreCondition");
                        int idx2 = 1;
                        foreach (XElement elPreCondition in elPreConditions)
                        {
                            ImportFieldsValidator oFieldsValidator2 = new ImportFieldsValidator();
                            oFieldsValidator2.Add(new FieldInfo("content", elPreCondition));

                            string strPreConditionName = "PreCondition_" + idx2;

                            //iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageCondition, diagram, oFieldsValidator2, EAImporter.m_iPreConditionBaseClsID, "PreCondition", strPreConditionName);
                            iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageCondition, diagram, oFieldsValidator2, EAImporter.m_iPreConditionBaseClsID, "PreCondition", "PreCondition");

                            iErrorCount = iErrorCount + iErrCnt;

                            idx2++;
                        }

                        IEnumerable <XElement> elRefActors = elCondition.Elements("referencedActor");
                        int idx3 = 1;
                        foreach (XElement elRefActor in elRefActors)
                        {
                            ImportFieldsValidator oFieldsValidator3 = new ImportFieldsValidator();
                            oFieldsValidator3.Add(new FieldInfo("name", elRefActor));

                            string strRefActorName = "ReferencedActor_" + idx3;

                            //iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageCondition, diagram, oFieldsValidator3, EAImporter.m_iRef_ActorClsID, "ReferencedActor", strRefActorName);
                            iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageCondition, diagram, oFieldsValidator3, EAImporter.m_iRef_ActorClsID, "ReferencedActor", "ReferencedActor");

                            iErrorCount = iErrorCount + iErrCnt;

                            idx3++;
                        }
                    }

                    iErrorCount = iErrorCount + iErrCnt;

                    idx++;
                }
            }

            return(iErrorCount);
        }
Пример #12
0
        private int ProcessRelations(string strUseCasePath, string strPackageName, EA.Package eAMainPackage, XElement elUseCase, EA.Diagram diagram)
        {
            int iErrorCount = 0;

            EA.Package eaPackageUseCaseRelations = EAImporter.m_Packages.Add(strUseCasePath, strPackageName, "");
            if (eaPackageUseCaseRelations == null)
            {
                iErrorCount++;
            }
            ;

            if (eaPackageUseCaseRelations != null)
            {
                IEnumerable <XElement> elUseCaseRelations = elUseCase.Elements("UseCaseRelation");
                int idx = 1;
                foreach (XElement elUseCaseRelation in elUseCaseRelations)
                {
                    ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();
                    oFieldsValidator.Add(new FieldInfo("type", elUseCaseRelation, "", false));

                    int iErrCnt = oFieldsValidator.ParseAndValidateFields("Use Case Relations");

                    if (iErrCnt == 0)
                    {
                        string strRelationName = "UseCaseRelation_" + idx;

                        EA.Package eaPackageRelation = EAImporter.m_Packages.Add(strUseCasePath + "/UseCaseRelations", strRelationName, "");
                        if (eaPackageRelation == null)
                        {
                            iErrorCount++;
                        }
                        ;

                        if (eaPackageRelation != null)
                        {
                            iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageRelation, diagram, oFieldsValidator, EAImporter.m_iUseCaseRelationsClsID, "UseCaseRelation", strRelationName);

                            iErrorCount = iErrorCount + iErrCnt;
                        }

                        IEnumerable <XElement> elRelatedUseCases = elUseCaseRelation.Elements("RelatedUseCase");
                        int idx2 = 1;
                        foreach (XElement elRelatedUseCase in elRelatedUseCases)
                        {
                            ImportFieldsValidator oFieldsValidator2 = new ImportFieldsValidator();
                            oFieldsValidator2.Add(new FieldInfo("name", elRelatedUseCase, "", true, true));

                            iErrCnt = ProcessModelObject(strUseCasePath + "/" + strPackageName, eAMainPackage, eaPackageRelation, diagram, oFieldsValidator2, EAImporter.m_iRefUseCaseClsID, "RelatedUseCase");

                            iErrorCount = iErrorCount + iErrCnt;

                            idx2++;
                        }
                    }

                    iErrorCount = iErrorCount + iErrCnt;

                    idx++;
                }
            }

            return(iErrorCount);
        }
Пример #13
0
        private int ProcessModelObject(string strLinksFolder, EA.Package eAMainPackage, EA.Package eaPackage, EA.Diagram diagram, ImportFieldsValidator oFieldsValidator, int iBaseClassID, string strImportingData, string strObjName = "")
        {
            int iErrCnt = oFieldsValidator.ParseAndValidateFields(strImportingData);

            if (iErrCnt == 0)
            {
                oFieldsValidator.ReplaceImageLinks(strLinksFolder);

                string strLogInfo = "";

                if (strObjName == "")
                {
                    strLogInfo = strImportingData + ": " + (string)oFieldsValidator[oFieldsValidator.GetIDStrName()].Value;
                }
                else
                {
                    strLogInfo = strImportingData + ": " + strObjName;
                }

                EA.Element element1 = null;
                EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

                if (strObjName == "")
                {
                    element1 = eaPackage.Elements.AddNew((string)oFieldsValidator[oFieldsValidator.GetIDStrName()].Value, "Object");
                }
                else
                {
                    element1 = eaPackage.Elements.AddNew(strObjName, "Object");
                }
                if (oFieldsValidator.GetNotesStrName() != "")
                {
                    element1.Notes = oFieldsValidator[oFieldsValidator.GetNotesStrName()].Value;
                }
                element1.ClassifierID = iBaseClassID;

                string strRunState = "";

                foreach (DictionaryEntry deFieldIndo in oFieldsValidator.GetFields())
                {
                    FieldInfo oFieldInfo = (FieldInfo)deFieldIndo.Value;
                    if ((string)oFieldInfo.Value != "")
                    {
                        if (!oFieldInfo.bIsID && !oFieldInfo.bIsNote)
                        {
                            strRunState = strRunState + "@VAR;Variable=" + oFieldInfo.ValueName + ";Value=" + (string)oFieldInfo.Value + ";Op==;@ENDVAR;";
                        }
                        if (oFieldInfo.bIsNote)
                        {
                            strRunState = strRunState + "@VAR;Variable=" + oFieldInfo.ValueName + ";Value=See notes for this object;Op==;@ENDVAR;";
                        }
                    }
                }
                element1.RunState = strRunState;
                element1.Update();

                eaPackage.Elements.Refresh();

                AddUCComponentToDiagram(eAMainPackage, diagram, element1.ElementID);
            }

            return(iErrCnt);
        }
Пример #14
0
        /// <summary>
        /// ProcessSequences
        /// </summary>
        /// <param name="strParentPackageName"></param>
        /// <param name="el"></param>
        public int Import(string strParentPackageName, XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                return(iErrorCount);
            }

            IEnumerable <XElement> elSequences = el.Elements("Scenario");

            foreach (XElement elSequence in elSequences)
            {
                Application.DoEvents();

                ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                oFieldsValidator.Add(new FieldInfo("name", elSequence));
                oFieldsValidator.Add(new FieldInfo("PrimaryActorName", elSequence.Element("PrimaryActor"), "name"));
                oFieldsValidator.Add(new FieldInfo("triggeringEvent", elSequence));
                oFieldsValidator.Add(new FieldInfo("preCondition", elSequence, "", true, false, false, true));
                oFieldsValidator.Add(new FieldInfo("postCondition", elSequence, "", true, false, false, true));
                oFieldsValidator.Add(new FieldInfo("number", elSequence));

                int iErrCnt = oFieldsValidator.ParseAndValidateFields("scenario conditions");

                iErrorCount = iErrorCount + iErrCnt;

                if (iErrCnt != 0)
                {
                    // assign temporary name to sequence to process steps for error reporting
                    oFieldsValidator["name"].Value = "DUMMY";
                }

                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Importing Sequence: " + oFieldsValidator["name"].Value);

                EA.Package theSeqPackage = EAImporter.m_Packages.Add(strParentPackageName, oFieldsValidator["name"].Value, "", elSequence);

                string strPackageName = strParentPackageName + "/" + oFieldsValidator["name"].Value;

                EA.Package theStepsPackage = EAImporter.m_Packages.Add(strPackageName, "Sequence", "");

                if (theStepsPackage != null)
                {
                    {
                        EA.Element elScenarioObj = theSeqPackage.Elements.AddNew("Scenario", "Object");
                        elScenarioObj.ClassifierID = EAImporter.m_ScenarioBaseClsID;
                        string strRunState = "";

                        strRunState = strRunState + oFieldsValidator["number"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["name"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["triggeringEvent"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["preCondition"].GetRunStateString();
                        strRunState = strRunState + oFieldsValidator["postCondition"].GetRunStateString();

                        elScenarioObj.RunState = strRunState;
                        elScenarioObj.Update();
                    }

                    {
                        EA.Element elActor = EAImporter.m_Actors.GetActor(oFieldsValidator["PrimaryActorName"].Value);

                        if (elActor != null)
                        {
                            EA.Element elPrimActorObj = theSeqPackage.Elements.AddNew("PrimaryActor_" + oFieldsValidator["PrimaryActorName"].Value, "Object");
                            elPrimActorObj.ClassifierID = elActor.ElementID;
                            elPrimActorObj.Update();
                        }
                        else
                        {
                            EAImporter.LogError(EAImporter.LogErrorLevel.A, "\"PrimaryActorName\" missing from scenario" + oFieldsValidator["PrimaryActorName"].Value);
                            iErrorCount++;
                        }
                    }

                    EA.Diagram diagram = EAImporter.AddDiagram(theStepsPackage, "Sequence Diagram", "Sequence");

                    IEnumerable <XElement> elSteps = elSequence.Elements("Step");

                    int iSeqNo     = 0;
                    int iDiagObjNo = 0;
                    foreach (XElement elStep in elSteps)
                    {
                        Application.DoEvents();

                        iErrorCount = iErrorCount + ProcessSequenceStep(theStepsPackage, diagram, elStep, ref iSeqNo, ref iDiagObjNo);
                    }
                }
                else
                {
                    iErrorCount++;
                }
            }

            return(iErrorCount);
        }
        private EA.Element AddActivityToSwimlane(EA.Diagram diagram, EA.Package thePackage, string strActivityName, string strActorName, ImportFieldsValidator oFields)
        {
            string strLogInfo = "Add activity to swimlane. Actor: " + strActorName + " activity: " + strActivityName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName];

            int iL = (iActivityHorizDistBetweenActivities * m_NoActivities) + iActivityHorizOffset;
            int iR = iL + iActivityWidth;
            int iT = (((oSwimlane.m_iB - oSwimlane.m_iT) / 2) + oSwimlane.m_iT) - (iActivityHeight / 2);
            int iB = iT + iActivityHeight;

            string strPos = "l=" + iL.ToString() + ";r=" + iR.ToString() + ";t=" + iT.ToString() + ";b=" + iB.ToString() + ";";

            EA.Element eElObj = AddActivity(diagram, thePackage, strActivityName, strActorName, strPos, oFields);

            if (eElObj == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

            m_NoActivities++;

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);
            return(eElObj);
        }
Пример #16
0
        private int ProcessNarrative(EA.Package eaPackageEnterprise, EA.Package eaPackageUseCase, ImportFieldsValidator oFieldsValidator, EA.Diagram diagram)
        {
            string strRunState = "";

            EA.Element element2 = eaPackageEnterprise.Elements.AddNew("Narrative", "Object");
            element2.Notes        = oFieldsValidator["completeDescription"].Value;
            element2.ClassifierID = EAImporter.m_iNarrativeBaseClsID;
            strRunState           = "";

            //strRunState = strRunState + "@VAR;Variable=" + "shortDescription" + ";Value=" + (string)oFieldsValidator["shortDescription"].Value + ";Op==;@ENDVAR;";
            strRunState = strRunState + oFieldsValidator["shortDescription"].GetRunStateString();
            strRunState = strRunState + "@VAR;Variable=" + "completeDescription" + ";Value=See object notes;Op==;@ENDVAR;";

            element2.RunState = strRunState;
            element2.Update();

            AddUCComponentToDiagram(eaPackageUseCase, diagram, element2.ElementID);

            return(0);
        }
        private EA.Element AddActivity(EA.Diagram diagram, EA.Package thePackage, string strActivityName, string strActorName, string strPos, ImportFieldsValidator oFields)
        {
            string strLogInfo = "Activity: " + strActivityName;

            EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo);

            EA.Element eElObj = null;

            if (strActivityName.StartsWith("Repeat till"))
            {
                eElObj = thePackage.Elements.AddNew(strActivityName, "Decision");
            }
            else if (strActivityName.StartsWith("Wait till"))
            {
                eElObj = thePackage.Elements.AddNew(strActivityName, "Event");
            }
            else if (strActivityName == "ActivityInitial")
            {
                // eElObj = thePackage.Elements.AddNew("", "ActivityInitial"); // hmm does not seem to work
                eElObj = thePackage.Elements.AddNew(strActivityName, "Activity");
            }
            else if (strActivityName == "ActivityFinal")
            {
                //eElObj = thePackage.Elements.AddNew("", "ActivityFinal"); // hmm does not seem to work
                eElObj = thePackage.Elements.AddNew(strActivityName, "Activity");
            }
            else
            {
                eElObj = thePackage.Elements.AddNew(strActivityName, "Activity");
            }

            if (AddDiagramObject(diagram, eElObj.ElementID, strPos) == null)
            {
                EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo);
                return(null);
            }

            if (oFields != null)
            {
                eElObj.Notes = oFields["description"].Value;

                EA.TaggedValue eaTgVal = eElObj.TaggedValues.AddNew("event", "TaggedValue");
                eaTgVal.Value = oFields["event"].Value;
                eaTgVal.Update();

                eaTgVal       = eElObj.TaggedValues.AddNew("number", "TaggedValue");
                eaTgVal.Value = oFields["number"].Value;
                eaTgVal.Update();

                eaTgVal       = eElObj.TaggedValues.AddNew("requirements", "TaggedValue");
                eaTgVal.Value = oFields["requirements"].Value;
                eaTgVal.Update();

                eaTgVal       = eElObj.TaggedValues.AddNew("ActorName", "TaggedValue");
                eaTgVal.Value = strActorName;
                eaTgVal.Update();

                eElObj.Update();
            }

            EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo);

            return(eElObj);
        }
Пример #18
0
        private int ProcessUseCaseFlatAttributes(EA.Package eaPackageEnterprise, EA.Package eaPackageUseCase, ImportFieldsValidator oFieldsValidator, EA.Diagram diagram, ref EA.Element elUCClassElement)
        {
            elUCClassElement = eaPackageEnterprise.Elements.AddNew("UseCase", "Object");
            elUCClassElement.ClassifierID = EAImporter.m_UseCaseBaseClsID;
            string strRunState = "";

            strRunState = strRunState + oFieldsValidator["name"].GetRunStateString();
            strRunState = strRunState + oFieldsValidator["id"].GetRunStateString();
            strRunState = strRunState + oFieldsValidator["classification"].GetRunStateString();
            strRunState = strRunState + oFieldsValidator["keywords"].GetRunStateString();
            strRunState = strRunState + oFieldsValidator["levelOfDepth"].GetRunStateString();
            strRunState = strRunState + oFieldsValidator["prioritisation"].GetRunStateString();
            strRunState = strRunState + oFieldsValidator["scope"].GetRunStateString();
            strRunState = strRunState + oFieldsValidator["viewPoint"].GetRunStateString();

            elUCClassElement.RunState = strRunState;
            elUCClassElement.Update();

            AddUCComponentToDiagram(eaPackageUseCase, diagram, elUCClassElement.ElementID);


            return(0);
        }
        /// <summary>
        /// ProcessSequences
        /// </summary>
        /// <param name="strParentPackageName"></param>
        /// <param name="el"></param>
        public int Import(string strParentPackageName, XElement el)
        {
            int iErrorCount = 0;

            if (el == null)
            {
                return(iErrorCount);
            }

            IEnumerable <XElement> elSequences = el.Elements("Scenario");

            foreach (XElement elSequence in elSequences)
            {
                Swimlane.m_NoSwimlanes = 0;
                Step.m_noSteps         = 0;
                m_NoActivities         = 0;

                m_LoadedSteps = new Hashtable();
                m_Swimlanes   = new Hashtable();

                Application.DoEvents();

                ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

                oFieldsValidator.Add(new FieldInfo("name", elSequence));

                int iErrCnt = oFieldsValidator.ParseAndValidateFields("Scenario");

                iErrorCount = iErrorCount + iErrCnt;

                if (iErrCnt != 0)
                {
                    // assign temporary name to sequence to process steps for error reporting
                    oFieldsValidator["name"].Value = "DUMMY";
                }

                EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Importing Activity: " + oFieldsValidator["name"].Value);

                EA.Package theActivityPackage = EAImporter.m_Packages.Add(strParentPackageName, oFieldsValidator["name"].Value, "", elSequence);

                string strPackageName = strParentPackageName + "/" + oFieldsValidator["name"].Value;

                EA.Package theStepsPackage = EAImporter.m_Packages.Add(strPackageName, "Activity", "");
                if (theStepsPackage != null)
                {
                    EA.Diagram diagram = EAImporter.AddDiagram(theStepsPackage, "Activity Diagram", "Activity");

                    IEnumerable <XElement> elSteps = elSequence.Elements("Step");

                    Step oStep = new Step();
                    oStep.m_strOperationName      = "INITIALSTATE";
                    m_LoadedSteps[Step.m_noSteps] = oStep;
                    Step.m_noSteps++;

                    foreach (XElement elStep in elSteps)
                    {
                        Application.DoEvents();

                        iErrorCount = iErrorCount + LoadStep(elStep);
                    }

                    if (iErrorCount == 0)
                    {
                        oStep = new Step();
                        oStep.m_strOperationName      = "FINALSTATE";
                        m_LoadedSteps[Step.m_noSteps] = oStep;
                        Step.m_noSteps++;

                        iErrorCount = iErrorCount + ProcessLoadedSteps(theStepsPackage, diagram);

                        // now extend swimlanes to cover all activities
                        foreach (DictionaryEntry deSwimlane in m_Swimlanes)
                        {
                            Swimlane oSwimlane = (Swimlane)deSwimlane.Value;

                            oSwimlane.m_eaDiagramObject.right = iActivityHorizOffset + (iActivityHorizDistBetweenActivities * (m_NoActivities - 1)) + iActivityWidth;
                            oSwimlane.m_eaDiagramObject.Update();
                            diagram.Update();
                        }
                    }
                }
                else
                {
                    iErrorCount++;
                }
            }

            return(iErrorCount);
        }
Пример #20
0
        private ImportFieldsValidator SequenceStepGetFields(XElement elStep, ref string strOperationName, ref string strFirstStep, ref string strLastStep)
        {
            ImportFieldsValidator oFieldsValidator = new ImportFieldsValidator();

            oFieldsValidator.Add(new FieldInfo("service", elStep));

            if (oFieldsValidator.ParseAndValidateFields("Scenario") != 0)
            {
                // "Service" is required
                return(oFieldsValidator);
            }

            if (oFieldsValidator["service"].Value.StartsWith("REPEAT"))
            {
                strOperationName = "REPEAT";
                string strServiceStripped = oFieldsValidator["service"].Value;
                strServiceStripped = strServiceStripped.Replace("REPEAT", "");
                strServiceStripped = strServiceStripped.Replace("(", "");
                strServiceStripped = strServiceStripped.Replace(")", "");

                string[] strSteps = strServiceStripped.Split('-');

                if (strSteps.Length != 2)
                {
                    EAImporter.LogError(EAImporter.LogErrorLevel.A, "REPEAT invalid arguments : " + oFieldsValidator["Service"].Value);
                    return(oFieldsValidator);
                }
                else
                {
                    strFirstStep = strSteps[0];
                    strLastStep  = strSteps[1];
                }
            }
            else
            {
                strOperationName = oFieldsValidator["service"].Value;
            }

            oFieldsValidator.Add(new FieldInfo("event", elStep, "", false));
            oFieldsValidator.Add(new FieldInfo("description", elStep));

            if (strOperationName == "REPEAT")
            {
                // no other fields required
            }
            else if (strOperationName == "TIMER")
            {
                oFieldsValidator.Add(new FieldInfo("name", elStep));
                oFieldsValidator.Add(new FieldInfo("Producer", elStep.Element("InformationProducer"), "name"));
                oFieldsValidator.Add(new FieldInfo("InformationExchanged", elStep.Element("InformationModel"), "name"));
                oFieldsValidator.Add(new FieldInfo("Step", elStep, "number"));
                //oFieldsValidator.Add(new FieldInfo("TechRequirementsID", elStep.Element("Requirement"), "name", false));
            }
            else
            {
                oFieldsValidator.Add(new FieldInfo("name", elStep));
                oFieldsValidator.Add(new FieldInfo("Producer", elStep.Element("InformationProducer"), "name"));
                oFieldsValidator.Add(new FieldInfo("Receiver", elStep.Element("InformationReceiver"), "name"));
                oFieldsValidator.Add(new FieldInfo("InformationExchanged", elStep.Element("InformationModel"), "name"));
                oFieldsValidator.Add(new FieldInfo("Step", elStep, "number"));
                //oFieldsValidator.Add(new FieldInfo("TechRequirementsID", elStep.Element("Requirement"), "name", false));
            }

            oFieldsValidator.ParseAndValidateFields("Scenario");

            return(oFieldsValidator);
        }