Пример #1
0
        static public void exportSample(EA.Repository Repository, EA.Diagram diagram, DiagramCache diagramCache)
        {
            RepositoryHelper.createDiagramCache(Repository, diagram, diagramCache);

            Hashtable ht        = sampleToJObject(Repository, diagram, diagramCache.elementsList);
            string    sample    = (string)ht["sample"];
            string    clazz     = (string)ht["class"];
            JObject   container = (JObject)ht["json"];


            if (!diagram.Stereotype.Equals(RoundTripAddInClass.EA_STEREOTYPE_SAMPLEDIAGRAM))
            {
                logger.log("exportSample: Ignore diagam that isnt a sample diagram");
                return;
            }

            //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);
            EA.Package samplesPackage = Repository.GetPackageByID(samplePkg.ParentID);
            EA.Package apiPackage     = Repository.GetPackageByID(samplesPackage.ParentID);

            string sourcecontrolPackage = apiPackage.Name;

            if (MetaDataManager.isCDMPackage(Repository, apiPackage))
            {
                sourcecontrolPackage = "cdm";
            }

            if (fileManager != null)
            {
                fileManager.initializeAPI(sourcecontrolPackage);
                fileManager.setup(RoundTripAddInClass.RAML_0_8);
                fileManager.exportSample(sample, clazz, msg);
            }
        }