private void exportAllGlobal(EA.Repository Repository) { { List <string> diagrams = DiagramManager.queryAPIDiagrams(Repository); foreach (string diagramId in diagrams) { EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId); logger.log("Exporting Diagram:" + diagram.Name); APIManager.exportAPI(Repository, diagram); logger.log("Exported Diagram:" + diagram.Name); } } { List <string> diagrams = DiagramManager.querySchemaDiagrams(Repository); foreach (string diagramId in diagrams) { EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId); logger.log("Exporting Schema Diagram:" + diagram.Name); SchemaManager.exportSchema(Repository, diagram); } } { List <string> diagrams = DiagramManager.querySampleDiagrams(Repository); foreach (string diagramId in diagrams) { EA.Diagram diagram = Repository.GetDiagramByGuid(diagramId); EA.Package samplePackage = Repository.GetPackageByID(diagram.PackageID); EA.Package apiPackage = Repository.GetPackageByID(samplePackage.ParentID); logger.log("Exporting Sample Diagram:" + diagram.Name + " from api package:" + apiPackage.Name); SampleManager.exportSample(Repository, diagram); } } }
public List <EA.Package> GetPackagessInPackage(int packageID) { List <EA.Package> elements = new List <EA.Package>(); String strResult = eaRepository.SQLQuery( String.Format( "SELECT ea_guid FROM t_object t_package WHERE Parent_ID = {0}", packageID)); List <Row> rows = EAGuid.Deserialise(strResult); EA.Package rootPackage = eaRepository.GetPackageByID(packageID); foreach (Row row in rows) { EA.Package eaElement = eaRepository.GetPackageByGuid(row.Ea_guid); elements.Add(eaElement); } return(elements); }
public bool GetPackage(out EA.Package package) { package = null; int packageId; if (GetEAObjectId(PackageID, out packageId)) { package = repository.GetPackageByID(packageId); return(package != null); } return(false); }
private void exportAll(EA.Repository Repository, DiagramCache diagramCache) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID); exportRoundTripPackage(Repository, apiPackage, diagramCache); }
private void exportAll(EA.Repository Repository) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } APIManager.exportAPI(Repository, diagram); EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID); exportAPIPackage(Repository, apiPackage); }
private string makePackagePathFromEAPackage(EA.Package pacObj) { EA.Repository repo = ProjectSetting.getEARepo(); if (pacObj.ParentID == 0) { return("/" + pacObj.Name); } else { EA.Package parentPacObj = repo.GetPackageByID(pacObj.ParentID); return(makePackagePathFromEAPackage(parentPacObj) + "/" + pacObj.Name); } }
public void DrawDiagram(int parentDiagramID, int lifeCycleDiagramID) { EAAPI.Element parentElement = eaRepo.GetElementByID(parentDiagramID); EAAPI.Diagram lifeCycleDiagram = eaRepo.GetDiagramByID(lifeCycleDiagramID); EAAPI.Package parentPackage = eaRepo.GetPackageByID(lifeCycleDiagram.PackageID); // convert to Dictionary so it is easier to lookup. Dictionary <String, EAAPI.Element> elements = ConvertEAElementsToDictionary(parentPackage.Elements); AddOrUpdateElements(parentPackage, parentElement, lifeCycleDiagram, ref elements); AddOrUpdateElementsOnDiagram(parentElement, lifeCycleDiagram, ref elements); FixDiagramObjectsSequence(lifeCycleDiagram, elements); lifeCycleDiagram.Update(); }
/// <summary> /// Create/Update an Activity Diagram for the operation /// </summary> /// <param name="rep"></param> /// <param name="m"></param> /// <param name="treePos">If a new package is created the new tree position to show the package in the correct order</param> /// <returns></returns> public static bool CreateActivityForOperation(EA.Repository rep, EA.Method m, int treePos = 100) { // get class EA.Element elClass = rep.GetElementByID(m.ParentID); EA.Package pkgSrc = rep.GetPackageByID(elClass.PackageID); // Check if update behavior, behavior exists string behaviorGuid = m.Behavior; // Check if update Activity or Create a new one if (behaviorGuid.StartsWith("{") && behaviorGuid.EndsWith("}")) { //behaviorGuid = behaviorGuid.Substring(1, behaviorGuid.Length-2); EA.Element actForUpdate = rep.GetElementByGuid(behaviorGuid); if (actForUpdate == null) { var res = MessageBox.Show($@"Can't update Activity for Operation, invalid link to Activity found Behavior GUID =GUID of expected Activity: {behaviorGuid} Unable to find Activity for this GUID", @"Invalid link to Activity found, Create a new one?", MessageBoxButtons.OKCancel); if (res != DialogResult.OK) { return(false); } CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass); } else { UpdateParameterFromOperation(rep, actForUpdate, m); // update parameters from Operation for Activity } return(true); } CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass); return(true); }
public static bool CreateInteractionForOperation(EA.Repository rep, EA.Method m) { // get class EA.Element elClass = rep.GetElementByID(m.ParentID); Package pkgSrc = rep.GetPackageByID(elClass.PackageID); // create a package with the name of the operation Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, ""); pkgTrg.Update(); pkgSrc.Packages.Refresh(); // create Class Sequence Diagram in target package EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Sequence"); pkgSeqDia.Update(); pkgTrg.Diagrams.Refresh(); // add frame in Sequence diagram EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", ""); EA.Element frm = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram"); frm.Update(); frmObj.ElementID = frm.ElementID; //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; frmObj.Update(); pkgTrg.Elements.Refresh(); pkgSeqDia.DiagramObjects.Refresh(); // create Interaction with the name of the operation EA.Element seq = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Interaction"); seq.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!"; seq.Update(); pkgTrg.Elements.Refresh(); // create sequence diagram beneath Interaction EA.Diagram seqDia = (EA.Diagram)seq.Diagrams.AddNew(m.Name, "Sequence"); seqDia.Update(); seq.Diagrams.Refresh(); // create instance from class beneath Interaction EA.Element obj = (EA.Element)seq.Elements.AddNew("", "Object"); seq.Elements.Refresh(); obj.ClassfierID = elClass.ElementID; obj.Update(); // add node object to Sequence Diagram EA.DiagramObject node = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=100;r=180;t=50;b=70", ""); node.ElementID = obj.ElementID; node.Update(); // Add Heading to diagram EA.DiagramObject noteObj = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", ""); EA.Element note = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text"); note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType; note.Update(); noteObj.ElementID = note.ElementID; noteObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; noteObj.Update(); pkgTrg.Elements.Refresh(); seqDia.DiagramObjects.Refresh(); // Link Operation to activity HoUtil.SetBehaviorForOperation(rep, m, seq); // Set show behavior HoUtil.SetShowBehaviorInDiagram(rep, m); HoUtil.SetFrameLinksToDiagram(rep, frm, seqDia); // link Overview frame to diagram frm.Update(); //rep.ReloadDiagram(actDia.DiagramID); return(true); }
//----------------------------------------------------------------------------------------- // Create StateMachine for Operation //---------------------------------------------------------------------------------- public static bool CreateStateMachineForOperation(EA.Repository rep, EA.Method m) { // get class EA.Element elClass = rep.GetElementByID(m.ParentID); EA.Package pkgSrc = rep.GetPackageByID(elClass.PackageID); // create a package with the name of the operation EA.Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, ""); pkgTrg.Update(); pkgSrc.Packages.Refresh(); // create Class StateMachine Diagram in target package EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Statechart"); pkgSeqDia.Update(); pkgTrg.Diagrams.Refresh(); // add frame in StateMachine diagram EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", ""); EA.Element frm = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram"); frm.Update(); frmObj.ElementID = frm.ElementID; //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; frmObj.Update(); pkgTrg.Elements.Refresh(); pkgSeqDia.DiagramObjects.Refresh(); // create StateMachine with the name of the operation EA.Element stateMachine = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "StateMachine"); stateMachine.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!"; stateMachine.Update(); pkgTrg.Elements.Refresh(); // create Statechart diagram beneath State Machine EA.Diagram chartDia = (EA.Diagram)stateMachine.Diagrams.AddNew(m.Name, "Statechart"); chartDia.Update(); stateMachine.Diagrams.Refresh(); // put the state machine on the diagram EA.DiagramObject chartObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=50;r=600;t=100;b=800", ""); chartObj.ElementID = stateMachine.ElementID; chartObj.Update(); chartDia.DiagramObjects.Refresh(); // add default nodes (init/final) CreateDefaultElementsForStateDiagram(rep, chartDia, stateMachine); // Add Heading to diagram EA.DiagramObject noteObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", ""); EA.Element note = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text"); note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType; note.Update(); noteObj.ElementID = note.ElementID; noteObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;"; noteObj.Update(); pkgTrg.Elements.Refresh(); chartDia.DiagramObjects.Refresh(); // Link Operation to StateMachine HoUtil.SetBehaviorForOperation(rep, m, stateMachine); // Set show behavior HoUtil.SetShowBehaviorInDiagram(rep, m); HoUtil.SetFrameLinksToDiagram(rep, frm, chartDia); // link Overview frame to diagram frm.Update(); //rep.ReloadDiagram(actDia.DiagramID); return(true); }