Exemplo n.º 1
0
        private int CreateUseCaseDigram(string strUseCaseName, EA.Package eaPackage, XElement elUseCase, EA.Element eaElUCClassElement)
        {
            int iErrorCount = 0;

            EA.Diagram UCdiagram = EAImporter.AddDiagram(eaPackage, "Use Case Diagram", "Use Case");

            Hashtable UCRefActors = EAImporter.m_Actors.GetActorUseCaseRefs();

            EA.Element eaElUseCase = eaPackage.Elements.AddNew(strUseCaseName, "Use Case");

            int iErrCnt = AddUCToUCDiagram(eaPackage, UCdiagram, eaElUseCase.ElementID, eaElUCClassElement.ElementID, UCRefActors.Count / 2);

            EA.Connector con2 = eaElUCClassElement.Connectors.AddNew("describes", "Dependancy");
            con2.SupplierID = eaElUseCase.ElementID;
            con2.Update();
            eaElUCClassElement.Connectors.Refresh();

            m_NoUseCaseActors = 0;

            foreach (DictionaryEntry deActorRef1 in UCRefActors)
            {
                string strActorName = (string)deActorRef1.Key;

                EA.Element eaElActor = EAImporter.m_Actors.GetActor(strActorName);

                iErrorCount = iErrorCount + AddActorToUCDiagram(eaPackage, UCdiagram, eaElActor.ElementID);

                EA.Connector con1 = eaElUseCase.Connectors.AddNew("", "UseCase");
                con1.SupplierID = eaElActor.ElementID;
                con1.Update();

                EA.ConnectorTag eaTgVal = con1.TaggedValues.AddNew("furtherInformation", "TaggedValue");

                eaTgVal.Value = ((ImportFieldsValidator)deActorRef1.Value)["furtherInformation"].Value;
                eaTgVal.Update();

                con1.Update();

                eaElUseCase.Connectors.Refresh();
            }

            return(iErrorCount);
        }
        /// <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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }