public static void syncPopulation(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache) { logger.log("Sync Population"); RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache); IList <EA.Element> diagramElements = diagramCache.elementsList; //IList<EA.Element> samples = MetaDataManager.diagramSamples(Repository, diagramElements); IList <EA.Element> samples = diagramElements; EA.Element container = container = MetaDataManager.findContainer(Repository, diagram, diagramCache, RoundTripAddInClass.EA_STEREOTYPE_POPULATION); logger.log("Classifier ID:" + container.ClassifierID); string containerName = container.Name; string containerClassifier = "Classes"; EA.Element containerClassifierEl = null; if (container.ClassifierID != 0) { containerClassifierEl = Repository.GetElementByID(container.ClassfierID); containerName = container.Name; containerClassifier = containerClassifierEl.Name; } EA.Package samplePkg = Repository.GetPackageByID(diagram.PackageID); Hashtable ht = new Hashtable(); MetaDataManager.extractDiagramMetaData(ht, container); string project = (String)ht[RoundTripAddInClass.PROJECT]; if (project == null) { MessageBox.Show("No project defined in the Population stereotyped element. Please enter project name where population should be exported."); return; } if (fileManager != null) { fileManager.initializeAPI(project); fileManager.setDataName(RoundTripAddInClass.POPULATION_PATH); fileManager.setup(RoundTripAddInClass.RAML_0_8); if (!fileManager.populationExists(container.Name, containerClassifier, RoundTripAddInClass.POPULATION_PATH, container.Name)) { MessageBox.Show("No file exists at:" + fileManager.exportPath(container.Name, containerClassifier, RoundTripAddInClass.POPULATION_PATH, container.Name)); return; } else { string fullpath = fileManager.exportPath(containerName, containerClassifier, RoundTripAddInClass.POPULATION_PATH, container.Name); JArray jo = JArray.Parse(File.ReadAllText(fullpath)); sync_population(Repository, container, containerClassifierEl, jo, samplePkg, diagramCache); samplePkg.Update(); } } }
static public void exportMapping(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache) { try { DiagramManager.captureDiagramLinks(diagram); //logger.log("links captured"); RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache); //logger.log("cache created"); if (!diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_MAPPINGDIAGRAM)) { logger.log("exportSample: Ignore diagram that isnt a mapping diagram"); return; } Hashtable ht = sampleToJObject(Repository, diagram, diagramCache); string sample = (string)ht["sample"]; string clazz = (string)ht["class"]; string container = (string)ht["json"]; string export = (string)ht[RoundTripAddInClass.FILENAME]; string sourcecontrolPackage = (string)ht[RoundTripAddInClass.PROJECT]; logger.log("Project:" + sourcecontrolPackage); //KeyValuePair<string,JObject> kv = sampleToJObject(Repository, diagram); //JObject container = kv.Value; if (container == null) { MessageBox.Show("No object linked to root with classification sample declared nor (older style) object of classification Request declared"); return; } //string msg = JsonConvert.SerializeObject(container, Newtonsoft.Json.Formatting.Indented) + "\n"; EA.Package samplePkg = Repository.GetPackageByID(diagram.PackageID); if (fileManager != null) { fileManager.initializeAPI(sourcecontrolPackage); fileManager.setDataName(RoundTripAddInClass.MAPPING_PATH); fileManager.setup(RoundTripAddInClass.RAML_0_8); fileManager.exportData(sample, clazz, container, RoundTripAddInClass.MAPPING_PATH, export); } } catch (ModelValidationException ex) { MessageBox.Show(ex.errors.messages.ElementAt(0).ToString()); } }
static public void exportHierarchy(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache) { try { if (!diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_HIERARCHYDIAGRAM)) { logger.log("exportSample: Ignore diagram that isnt a hierarchy diagram"); return; } DiagramManager.captureDiagramLinks(diagram); RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache); Hashtable ht = sampleToJObject(Repository, diagram, diagramCache); string sample = (string)ht["sample"]; string clazz = (string)ht["class"]; string container = (string)ht["json"]; string exportName = (string)ht[RoundTripAddInClass.FILENAME]; string projectName = (string)ht[RoundTripAddInClass.PROJECT]; if (container == null) { MessageBox.Show("No object linked to root with classification sample declared nor (older style) object of classification Request declared"); return; } if (projectName == null) { projectName = RoundTripAddInClass.EXPORT_PACKAGE; } logger.log("saving"); if (fileManager != null) { fileManager.initializeAPI(projectName); fileManager.setDataName(RoundTripAddInClass.HIERARCHY_PATH); fileManager.setup(RoundTripAddInClass.RAML_0_8); fileManager.exportData(sample, clazz, container, RoundTripAddInClass.HIERARCHY_PATH, exportName); } }catch (ModelValidationException ex) { MessageBox.Show(ex.errors.messages.ElementAt(0).ToString()); } }
static public void exportConstraint(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache) { try { DiagramManager.captureDiagramLinks(diagram); RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache); if (!diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_CONSTRAINTDIAGRAM)) { logger.log("Ignore diagram that isnt a constraint diagram"); return; } Hashtable ht = sampleToJObject(Repository, diagram, diagramCache); string sample = (string)ht["sample"]; string clazz = (string)ht["class"]; string container = (string)ht["json"]; string export = (string)ht[RoundTripAddInClass.FILENAME]; string sourcecontrolPackage = (string)ht[RoundTripAddInClass.PROJECT]; logger.log("Project:" + sourcecontrolPackage); if (container == null) { MessageBox.Show("No object linked to root with classification sample declared nor (older style) object of classification Request declared"); return; } EA.Package samplePkg = Repository.GetPackageByID(diagram.PackageID); if (fileManager != null) { fileManager.initializeAPI(sourcecontrolPackage); fileManager.setDataName(RoundTripAddInClass.CONSTRAINT_PATH); fileManager.setup(RoundTripAddInClass.RAML_0_8); fileManager.exportData(sample, clazz, container, RoundTripAddInClass.CONSTRAINT_PATH, export); } } catch (ModelValidationException ex) { MessageBox.Show(ex.errors.messages.ElementAt(0).ToString()); } }