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());
            }
        }
Beispiel #3
0
        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());
            }
        }
Beispiel #4
0
        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());
            }
        }
        public static void syncSample(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache)
        {
            logger.log("Sync Sample");

            RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache);
            IList <EA.Element> diagramElements = diagramCache.elementsList;

            IList <EA.Element> samples = MetaDataManager.diagramSamples(Repository, diagramElements);

            EA.Element container             = container = findContainer(Repository, diagram, diagramElements);
            EA.Element containerClassifierEl = Repository.GetElementByID(container.ClassfierID);
            string     containerName         = container.Name;
            string     containerClassifier   = containerClassifierEl.Name;


            //logger.log("Sample Root:" + container.Name);

            EA.Package samplePkg      = Repository.GetPackageByID(diagram.PackageID);
            EA.Package samplesPackage = Repository.GetPackageByID(samplePkg.ParentID);
            EA.Package apiPackage     = Repository.GetPackageByID(samplesPackage.ParentID);
            if (fileManager != null)
            {
                fileManager.initializeAPI(apiPackage.Name);
                fileManager.setup(RoundTripAddInClass.RAML_0_8);
                if (!fileManager.sampleExists(container.Name, containerClassifier))
                {
                    MessageBox.Show("No file exists at:" + fileManager.samplePath(container.Name, containerClassifier));
                    return;
                }
                else
                {
                    string  fullpath = fileManager.samplePath(containerName, containerClassifier);
                    JObject jo       = JObject.Parse(File.ReadAllText(fullpath));
                    sync_sample(Repository, container, jo);
                }
            }
        }