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); } } }
/// /// Called Before EA starts to check Add-In Exists /// Nothing is done here. /// This operation needs to exists for the addin to work /// /// <param name="Repository" />the EA repository /// a string public String EA_Connect(EA.Repository Repository) { logger.setRepository(Repository); try { fileManager.setBasePath(Properties.Settings.Default.BasePath); fileManager.setDiagramPath(Properties.Settings.Default.DiagramPath); } catch (Exception) { logger.log("Did not find BasePath or DiagramPath in user settings"); } DiagramManager.setLogger(logger); DiagramManager.setFileManager(fileManager); APIManager.setLogger(logger); APIManager.setFileManager(fileManager); SchemaManager.setLogger(logger); SchemaManager.setFileManager(fileManager); SampleManager.setLogger(logger); SampleManager.setFileManager(fileManager); WSDLManager.setLogger(logger); MetaDataManager.setLogger(logger); return("a string"); }
private void exportDiagram(EA.Repository Repository) { EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } DiagramManager.exportDiagram(Repository, diagram); }
public static bool filterDataItem(EA.Repository Repository, EA.Connector con, EA.Element e, EA.Element classifier) { if (e != null) { if (DiagramManager.isVisible(con)) { if (e.Stereotype.Contains(APIAddIn.APIAddinClass.METAMODEL_DATAITEM)) { return(true); } } } return(false); }
static public void exportAPI(EA.Repository Repository, EA.Diagram diagram, double version) { logger.log("Exporting an API to RAML"); REIFY_VERSION = version; EA.Element apiEl = MetaDataManager.diagramAPI(Repository, diagram); DiagramManager.captureDiagramLinks(diagram); { YamlMappingNode map = new YamlMappingNode(); REIFY_VERSION = version; reifyAPI(Repository, apiEl, map); YamlStream stream = new YamlStream(); YamlDocument yamlDoc = new YamlDocument(map); stream.Documents.Add(yamlDoc); StringWriter writer = new StringWriter(); stream.Save(writer, false /*no alias*/); string yaml = "#%RAML " + version.ToString("F1") + "\n" + writer.ToString(); EA.Package apiPackage = Repository.GetPackageByID(diagram.PackageID); fileManager.initializeAPI(apiPackage.Name); fileManager.setup(version); fileManager.exportAPI(apiPackage.Name, version, yaml, fileManager.getNamespace(Repository, apiPackage)); //fileManager.exportAPI(apiPackage.Name, APIAddinClass.RAML_0_8, yaml); //return map; } }
static int visitOutboundConnectedElements(bool ensureVisible, EA.Repository Repository, EA.Element clientElement, YamlNode parent, Func <EA.Repository, EA.Connector, EA.Element, EA.Element, bool> filter, Func <EA.Connector, EA.Element, EA.Element, string> name, Func <EA.Repository, EA.Element, EA.Connector, EA.Element, YamlNode> properties) { int outboundCount = 0; //logger.log("Processing Connections from:" + clientElement.Name); foreach (EA.Connector con in clientElement.Connectors) { //logger.log("Processing Connector:" + con.Name); if (ensureVisible) { if (!DiagramManager.isVisible(con)) { continue; } } EA.Element supplierElement = null; if (clientElement.ElementID == con.ClientID) { supplierElement = Repository.GetElementByID(con.SupplierID); //logger.log("Found resource:" + supplierElement.Name); EA.Element supplierClassifier = null; if (supplierElement.ClassifierID != 0) { supplierClassifier = Repository.GetElementByID(supplierElement.ClassifierID); } //logger.log("Classifier"); if (!filter(Repository, con, supplierElement, supplierClassifier)) { continue; } outboundCount += 1; //logger.log("Filtered"); String nm = name(con, supplierElement, clientElement); YamlNode o = properties(Repository, supplierElement, con, clientElement); if (o == null) { continue; } else if (parent.GetType().Name.StartsWith("YamlSequenceNode")) { YamlSequenceNode seq = (YamlSequenceNode)parent; if (o.GetType().Name.StartsWith("YamlSequenceNode")) { YamlSequenceNode oseq = (YamlSequenceNode)o; foreach (YamlNode n in oseq.Children) { seq.Add(n); } } else { seq.Add(o); } } else if (parent.GetType().Name.StartsWith("YamlMappingNode")) { if (nm == null) { continue; } YamlMappingNode map = (YamlMappingNode)parent; try { map.Add(nm, o); } catch (Exception ex) { throw new Exception("Duplicate entry:" + nm, ex); } } } } //logger.log("Processed Connections from:" + clientElement.Name); return(outboundCount); }