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 exportAPIPackage(EA.Repository Repository, EA.Package apiPackage) { EA.Package samplePackage = null; EA.Package schemasPackage = null; foreach (EA.Package p in apiPackage.Packages) { //logger.log("Package:" + p.Name); if (p.Name.Equals(APIAddinClass.API_PACKAGE_SAMPLES)) { samplePackage = p; } else if (p.Name.Equals(APIAddinClass.API_PACKAGE_SCHEMAS)) { schemasPackage = p; } } if (samplePackage == null || schemasPackage == null) { logger.log("Not an api/model package:" + apiPackage.Name); return; } logger.log("Found api/model package:" + apiPackage.Name); if (samplePackage != null) { List <EA.Package> pkgs = new List <EA.Package>(); pkgs.Add(samplePackage); foreach (EA.Package child in samplePackage.Packages) { pkgs.Add(child); } foreach (EA.Package sp in pkgs) { logger.log("Exporting Samples:" + sp.Name); foreach (object obj in sp.Diagrams) { EA.Diagram samplediagram = (EA.Diagram)obj; logger.log("Exporting Schema Diagram:" + samplediagram.Name); SampleManager.exportSample(Repository, samplediagram); } } } if (schemasPackage != null) { logger.log("Exporting Schemas:" + schemasPackage.Name); foreach (EA.Diagram schemadiagram in schemasPackage.Diagrams) { logger.log("Exporting Sample Diagram:" + schemadiagram.Name); SchemaManager.exportSchema(Repository, schemadiagram); } } }
/// /// Called when user makes a selection in the menu. /// This is your main exit point to the rest of your Add-in /// /// <param name="Repository" />the repository /// <param name="Location" />the location of the menu /// <param name="MenuName" />the name of the menu /// <param name="ItemName" />the name of the selected menu item public void EA_MenuClick(EA.Repository Repository, string Location, string MenuName, string ItemName) { logger.enable(Repository); EA.Diagram diagram = null; if (Repository.GetContextItemType() == ObjectType.otDiagram) { diagram = Repository.GetContextObject(); } switch (ItemName) { case menuExportAll: exportAll(Repository); break; case menuExportPackage: exportPackage(Repository); break; case menuExportDiagram: exportDiagram(Repository); break; case menuExportSchema: try { SchemaManager.exportSchema(Repository, diagram); MetaDataManager.setAsSchemaDiagram(Repository, diagram); } catch (Exception ex) { MessageBox.Show(ex.Message); } break; //case menuExportCanonical: // try // { // SchemaManager.exportCanonical(Repository, diagram); // //MetaDataManager.setAsCanonicalDiagram(Repository, diagram); // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } // break; case menuExportSample: SampleManager.exportSample(Repository, diagram); MetaDataManager.setAsSampleDiagram(Repository, diagram); break; case menuSyncSample: SampleManager.syncSample(Repository, diagram); break; case menuCreateSample: SchemaManager.generateSample(Repository); break; case menuUpdateClassFromInstance: SchemaManager.updateClassFromInstance(Repository); break; case menuUpdateInstanceFromClass: SchemaManager.operateOnSample(Repository, SchemaManager.updateSampleFromClass); break; case menuValidateDiagram: if (diagram != null) { if (diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SAMPLEDIAGRAM)) { SampleManager.validateDiagram(Repository, diagram); } else if (diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_SCHEMADIAGRAM)) { SchemaManager.validateDiagram(Repository, diagram); } else if (diagram.Stereotype.Equals(APIAddinClass.EA_STEREOTYPE_APIDIAGRAM)) { APIManager.validateDiagram(Repository, diagram); } } break; case menuExportAPI: APIManager.exportAPI(Repository, diagram); MetaDataManager.setAsAPIDiagram(Repository, diagram); break; case menuExportAPIRAML1: APIManager.exportAPI_RAML1(Repository, diagram); MetaDataManager.setAsAPIDiagram(Repository, diagram); break; case menuToggleLogging: logger.toggleLogging(Repository); break; case menuWeb: this.callWeb(Repository); break; case menuImportSOA: WSDLManager.importWSDLs(Repository, diagram); break; case menuExportSOA: WSDLManager.exportWSDLs(Repository, diagram); break; } }