public int ParseAndValidateFields(string strParsingElementNote) { int iErrorCount = 0; foreach (DictionaryEntry deFieldIndo in m_Fields) { FieldInfo oFieldInfo = (FieldInfo)deFieldIndo.Value; //string strErrorInfo = strParsingElementNote + " field: " + oFieldInfo.ValueName; string strCurrElement = ""; if (!oFieldInfo.ParseAndValidateField()) { if (oFieldInfo.XElement != null) { strCurrElement = " (" + EAImporter.Recurse(oFieldInfo.XElement) + ")"; } else { //strErrorInfo = strErrorInfo + " in: EMPTY"; } iErrorCount++; EAImporter.LogError(EAImporter.LogErrorLevel.A, "\"" + oFieldInfo.ValueName + "\" missing or empty from " + strParsingElementNote + strCurrElement); } } m_ImportErrCnt = iErrorCount; return(m_ImportErrCnt); }
private int AddConnector(EA.Diagram diagram, EA.Element eaElSource, EA.Element eaElDest, string strText, string strControlType, string strPath = "") { string strLogInfo = "Connector for operation: " + strText; EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); EA.Connector eConnector = eaElSource.Connectors.AddNew(strText, strControlType); if (eConnector == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo); return(0); } // eConnector.Notes = strNotes; eConnector.SupplierID = eaElDest.ElementID; eConnector.Width = 2; eConnector.Update(); EA.DiagramLink eDiagramLink = diagram.DiagramLinks.AddNew(strText, strControlType); if (eDiagramLink == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo); return(0); } eDiagramLink.ConnectorID = eConnector.ConnectorID; if (strPath != "") { eDiagramLink.Path = strPath; } eDiagramLink.Update(); EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); return(0); }
private EA.Element AddDataObjectToSwimlane(EA.Diagram diagram, EA.Package thePackage, string strInfoExchanged, string strActorName) { string strLogInfo = "Actor: " + strActorName + " info: " + strInfoExchanged; EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName]; int iL = (iActivityHorizDistBetweenActivities * (m_NoActivities - 1)) + 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 = AddDataObject(diagram, thePackage, strInfoExchanged, strActorName, strPos); if (eElObj == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, "Could not add actor \"" + strActorName + "\" info \"" + strInfoExchanged + "\" to activity diagram"); return(null); } EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); return(eElObj); }
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); }
public EA.Package Add(string strNewPackageName, EA.Package eaPackage) { if (strNewPackageName == "") { string strErrInfo = "Package name is empty."; EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo); return(null); } if (eaPackage == null) { string strErrInfo = "Must provide package."; EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo); return(null); } string strLogInfo = "Package: " + strNewPackageName; EA.Package oNewPackage = (EA.Package)m_Packages[strNewPackageName]; if (oNewPackage != null) { EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); return(oNewPackage); } m_Packages[strNewPackageName] = eaPackage; return(eaPackage); }
/// <summary> /// AddInformationClass /// </summary> /// <param name="strPackageName"></param> /// <param name="strInfoClassName"></param> /// <param name="strInfoClassDescription"></param> private int AddInformationClass(EA.Package eaPackage, string strInfoClassName, string strInfoClassDescription, string strRequirements) { string strLogInfo = "Information Class: " + strInfoClassName; int iErrorCount = 0; EA.Element element1 = null; EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); if (eaPackage == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, "cannot add infomation class- package does not exist " + strInfoClassName); iErrorCount++; return(iErrorCount); } if (m_InfoClasses[strInfoClassName] != null) { EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); return(iErrorCount); } try { element1 = eaPackage.Elements.GetByName(strInfoClassName); } catch (Exception ex) { EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message); // EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, m_Repository.Stereotypes.GetLastError() + " : " + ex.Message); } if (element1 == null) { element1 = eaPackage.Elements.AddNew(strInfoClassName, "Class"); element1.Notes = strInfoClassDescription; element1.Update(); EA.TaggedValue eaTgVal = element1.TaggedValues.AddNew("requirements", "TaggedValue"); eaTgVal.Value = strRequirements; eaTgVal.Update(); eaPackage.Elements.Refresh(); EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); m_InfoClasses[strInfoClassName] = element1; } else { m_InfoClasses[strInfoClassName] = element1; EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); } return(iErrorCount); }
internal int AddInformationClass(EA.Package eaPackage, string strRequirementID, string strDescription) { string strLogInfo = "Requirement: " + strRequirementID; int iErrorCount = 0; EA.Element element1 = null; EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); if (eaPackage == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, "cannot add requirement- package does not exist " + strRequirementID); iErrorCount++; return(iErrorCount); } if (m_Requirements[strRequirementID] != null) { EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); return(iErrorCount); } try { element1 = eaPackage.Elements.GetByName(strRequirementID); } catch (Exception ex) { EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message); // EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, m_Repository.Stereotypes.GetLastError() + " : " + ex.Message); } if (element1 == null) { element1 = eaPackage.Elements.AddNew(strRequirementID, "Class"); element1.Notes = strDescription; element1.Update(); eaPackage.Elements.Refresh(); EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); m_Requirements[strRequirementID] = element1; } else { m_Requirements[strRequirementID] = element1; EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); } return(iErrorCount); }
private int AddSwimlane(EA.Diagram diagram, EA.Package thePackage, string strActorName) { string strLogInfo = "Swimlane: " + strActorName; EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); Swimlane oSwimlane = (Swimlane)m_Swimlanes[strActorName]; if (oSwimlane != null) { EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); return(0); } EA.Element eElObj = thePackage.Elements.AddNew(strActorName, "ActivityPartition"); if (eElObj == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo); return(1); } eElObj.Update(); thePackage.Elements.Refresh(); oSwimlane = new Swimlane(); m_Swimlanes[strActorName] = oSwimlane; oSwimlane.m_iL = m_iSwimlaneHorizOffset; oSwimlane.m_iR = 500; oSwimlane.m_iT = (Swimlane.m_NoSwimlanes * m_iSwimlaneHeight) + m_iSwimlaneVertOffset; oSwimlane.m_iB = oSwimlane.m_iT + m_iSwimlaneHeight; string strPos = "l=" + oSwimlane.m_iL.ToString() + ";r=" + oSwimlane.m_iR.ToString() + ";t=" + oSwimlane.m_iT.ToString() + ";b=" + oSwimlane.m_iB.ToString() + ";"; oSwimlane.m_eaDiagramObject = AddDiagramObject(diagram, eElObj.ElementID, strPos); if (oSwimlane.m_eaDiagramObject == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo); return(1); } Swimlane.m_NoSwimlanes++; EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); return(0); }
private EA.DiagramObject AddDiagramObject(EA.Diagram diagram, int iLinkedElementID, string strPos) { string strLogInfo = "diagram object for link ID: " + iLinkedElementID.ToString(); EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); EA.DiagramObject diagramObj = diagram.DiagramObjects.AddNew(strPos, ""); if (diagramObj == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo); return(null); } diagramObj.ElementID = iLinkedElementID; diagramObj.Update(); diagram.DiagramObjects.Refresh(); EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); return(diagramObj); }
private EA.Element AddDataObject(EA.Diagram diagram, EA.Package thePackage, string strInfoExchanged, string strActorName, string strPos) { string strLogInfo = "Activity Info Exchanged: " + strInfoExchanged; EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); EA.Element eElObj = thePackage.Elements.AddNew(strInfoExchanged, "Object"); if (eElObj == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo); return(null); } try { eElObj.ClassifierID = EAImporter.m_InfoModels.Get(strInfoExchanged).ElementID; } catch (Exception ex) { EAImporter.LogError(EAImporter.LogErrorLevel.A, "Information exchanged \"" + strInfoExchanged + "\" used in a sequence step is not defined in the Use Case or in the Repository"); string Temp = ex.Message; return(null); } EA.TaggedValue eaTgVal = eElObj.TaggedValues.AddNew("ActorName", "TaggedValue"); eaTgVal.Value = strActorName; eaTgVal.Update(); eElObj.Update(); if (AddDiagramObject(diagram, eElObj.ElementID, strPos) == null) { EAImporter.LogError(EAImporter.LogErrorLevel.A, strLogInfo); return(null); } EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); return(eElObj); }
/// <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); }
public EA.Package Add(string parentPackageName, string strNewPackageName, string strNotes = "", XElement CurrXEl = null) { string strLogInfo = "Package: " + strNewPackageName; EAImporter.LogMsg(EAImporter.LogMsgType.Adding, strLogInfo); if (parentPackageName == "") { string strErrInfo = "Parent package name is empty."; if (CurrXEl != null) { strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl); } EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo); return(null); } if (strNewPackageName == "") { string strErrInfo = "Package name is empty."; if (CurrXEl != null) { strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl); } EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo); return(null); } EA.Package oNewPackage = (EA.Package)m_Packages[parentPackageName + "/" + strNewPackageName]; if (oNewPackage != null) { EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); return(oNewPackage); } if ((EA.Package)m_Packages[parentPackageName] == null) { string strErrInfo = "Add Failed- parent package does not exist"; if (CurrXEl != null) { strErrInfo = strErrInfo + "Processing element: " + EAImporter.Recurse(CurrXEl); } EAImporter.LogError(EAImporter.LogErrorLevel.A, strErrInfo); return(null); } try { oNewPackage = ((EA.Package)m_Packages[parentPackageName]).Packages.GetByName(strNewPackageName); } catch (Exception ex) { EAImporter.LogMsg(EAImporter.LogMsgType.MiscExceptions, ex.Message); } if (oNewPackage == null) { oNewPackage = ((EA.Package)m_Packages[parentPackageName]).Packages.AddNew(strNewPackageName, "Nothing"); oNewPackage.Notes = strNotes; oNewPackage.Update(); m_Packages[parentPackageName + "/" + strNewPackageName] = oNewPackage; EAImporter.LogMsg(EAImporter.LogMsgType.Added, strLogInfo); } else { EAImporter.LogMsg(EAImporter.LogMsgType.Exists, strLogInfo); m_Packages[parentPackageName + "/" + strNewPackageName] = oNewPackage; return(oNewPackage); } return(oNewPackage); }
/// <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("<", "<"); //strTemp.Replace(">", ">");*/ ////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); }
public bool ReplaceImageLinks(string strImagePackagePath) { if (m_bIsNote) { while (Value.IndexOf("<img ") > 0) { Regex rgx1 = new Regex(@"<img.*?>"); MatchCollection matches1 = rgx1.Matches(Value); foreach (Match match1 in matches1) { Regex rgxSrc = new Regex(@"(?<=src="").*?(?="")"); MatchCollection matchesSrc = rgxSrc.Matches(match1.Value); Regex rgxWidth = new Regex(@"(?<=width="").*?(?="")"); MatchCollection matchesWidth = rgxWidth.Matches(match1.Value); Regex rgxHeight = new Regex(@"(?<=height="").*?(?="")"); MatchCollection matchesHeight = rgxHeight.Matches(match1.Value); Regex rgxId = new Regex(@"(?<=id="").*?(?="")"); MatchCollection matchesId = rgxId.Matches(match1.Value); Regex rgxAlign = new Regex(@"(?<=align="").*?(?="")"); MatchCollection matchesAlign = rgxAlign.Matches(match1.Value); Regex rgxStyle = new Regex(@"(?<=style="").*?(?="")"); MatchCollection matchesStyle = rgxStyle.Matches(match1.Value); string strAlign = ""; if (matchesAlign.Count > 0) { strAlign = matchesAlign[0].Value; } string strStyle = ""; if (matchesStyle.Count > 0) { strStyle = matchesStyle[0].Value; } strStyle = strStyle.Replace(':', '#'); string strTargetPath = System.IO.Path.Combine(@"\\127.0.0.1\EAImages", strImagePackagePath); string sourceFile = System.IO.Path.Combine(EAImporter.m_strImportFilePath, matchesSrc[0].Value); string strNewFileName = "W" + matchesWidth[0].Value + "_H" + matchesHeight[0].Value + "_ID" + matchesId[0].Value + "_AL" + strAlign + "_ST" + strStyle + "_" + matchesSrc[0].Value.Split('/')[1]; string destFile = System.IO.Path.Combine(strTargetPath, strNewFileName); try { if (!Directory.Exists(strTargetPath)) { DirectoryInfo di = Directory.CreateDirectory(strTargetPath); } } catch (Exception ex) { EAImporter.LogError(EAImporter.LogErrorLevel.A, "Could not create directory for images: " + ex.Message); return(false); } sourceFile = sourceFile.Replace("%20", " "); System.IO.File.Copy(sourceFile, destFile, true); string strReplacement = " <a href=\"" + destFile + "\"><font color=\"#0000ff\"><u>" + "<Ctl Left Click with Mouse to View Image>" + "</u></font></a> "; Value = Value.Replace(match1.Value, strReplacement); EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Replacing image ref: " + match1.Value); EAImporter.LogMsg(EAImporter.LogMsgType.Info, "Replacing image ref with: " + strReplacement); } } } return(true); }
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); }
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); }
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); }
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); }