/// /// 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"); }
static public void importWSDLs(EA.Repository repository, EA.Diagram diagram) { string [] wsdls = Directory.GetFiles(@"D:\SOA\Modelling\Schema\", "*datarich.wsdl"); foreach (string filename in wsdls) { WSDLManager mgr = new WSDLManager(); mgr.importWSDL(filename, repository, diagram); } }
static public void exportWSDLs(EA.Repository repository, EA.Diagram diagram) { WSDLManager mgr = new WSDLManager(); //mgr.path = @"D:\SOA\Modelling\Schema\"; mgr.path = @"D:\tmp\"; foreach (EA.DiagramObject obj in diagram.DiagramObjects) { EA.Element component = repository.GetElementByID(obj.ElementID); ServiceDescription sd = mgr.exportWSDL(repository, component); sd.Write(mgr.path + "/" + sd.Name + ".wsdl"); } }
/// /// 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; } }