Exemple #1
0
        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);
                }
            }
        }
        //DIAGRAM CONTENT
        public void Generate_otDiagram_content(EA.Repository m_Repository, string TOI_GUID, string SP_BaseURL,
                                               out List <string> listOfElements,
                                               out List <string> listOfElementsNames,
                                               out List <string> listOfLinks,
                                               out List <string> listOfLinkNames,
                                               out Dictionary <string, string> DiagramDictionary)
        {
            listOfElements      = new List <string>();
            listOfElementsNames = new List <string>();
            listOfLinks         = new List <string>();
            listOfLinkNames     = new List <string>();

            EA.Diagram DiagramToShow = (EA.Diagram)m_Repository.GetDiagramByGuid(TOI_GUID);



            //STORE DIAGRAM ELEMENTS
            for (short iDO = 0; iDO < DiagramToShow.DiagramObjects.Count; iDO++)
            {
                EA.DiagramObject MyDO = (EA.DiagramObject)DiagramToShow.DiagramObjects.GetAt(iDO);
                int        ID         = m_Repository.GetElementByID(MyDO.ElementID).ElementID;
                EA.Element MyEle      = (EA.Element)m_Repository.GetElementByID(ID);
                listOfElements.Add(MyEle.Name + "|" + MyEle.ObjectType + "|" + MyEle.ElementGUID);
                listOfElementsNames.Add(MyEle.Name);
            }



            //STORE DIAGRAM LINKS
            for (short iDO = 0; iDO < DiagramToShow.DiagramLinks.Count; iDO++)
            {
                EA.DiagramLink MyLink = (EA.DiagramLink)DiagramToShow.DiagramLinks.GetAt(iDO);
                int            ID     = m_Repository.GetConnectorByID(MyLink.ConnectorID).ConnectorID;

                EA.Connector con;

                try //Try and get the connector object from the repository
                {
                    con = (EA.Connector)m_Repository.GetConnectorByID(ID);
                    listOfLinks.Add(con.Name + "|" + con.ObjectType + "|" + con.ConnectorGUID);
                    listOfLinkNames.Add(con.Name);
                }
                catch { }
            }



            //JSON Content
            string DiagramURL = SP_BaseURL + "/" + DiagramToShow.Name + "|otDiagram|" + TOI_GUID;


            DiagramDictionary = new Dictionary <string, string>();
            DiagramDictionary.Add("Diagram Name", DiagramToShow.Name);
            DiagramDictionary.Add("Created Data", DiagramToShow.CreatedDate.ToString());
            DiagramDictionary.Add("Meta Type", DiagramToShow.MetaType);
            DiagramDictionary.Add("Notes", DiagramToShow.Notes);
            DiagramDictionary.Add("Package ID", DiagramToShow.PackageID.ToString());
            DiagramDictionary.Add("Big Preview", DiagramURL + "/BigPreview");
            DiagramDictionary.Add("Small Preview", DiagramURL + "/SmallPreview");
        }
Exemple #3
0
        private void RemoveInvalidIds()
        {
            for (int i = L.Count - 1; i >= 0; i--)
            {
                try
                {
                    switch (L[i].EaTyp)
                    {
                    case ObjectType.otDiagram:
                        EA.Diagram dia = (EA.Diagram)_rep.GetDiagramByGuid(L[i].Guid);
                        if (dia == null)
                        {
                            L.RemoveAt(i);
                            continue;
                        }
                        UpdateDiagram(i, dia);
                        break;

                    case ObjectType.otPackage:
                        EA.Package pkg = _rep.GetPackageByGuid(L[i].Guid);
                        if (pkg == null)
                        {
                            L.RemoveAt(i);
                            continue;
                        }
                        UpdatePackage(i, pkg);
                        break;

                    case ObjectType.otElement:
                        EA.Element el = _rep.GetElementByGuid(L[i].Guid);
                        if (el == null)
                        {
                            L.RemoveAt(i);
                            continue;
                        }
                        UpdateElement(i, el);
                        break;
                    }
                }
                catch //(Exception e)
                {
                    L.RemoveAt(i);
                }
            }
            LPosition = L.Count - 1;
        }
Exemple #4
0
        public void StartTest()
        {
            string progId = "EA.Repository";
            Type   type   = Type.GetTypeFromProgID(progId);

            EAAPI.Repository repository = Activator.CreateInstance(type) as EAAPI.Repository;

            try
            {
                string fileName = "TestModel1.eap";

                bool openResult = repository.OpenFile(AssemblyDirectory + "/TestData/" + fileName);

                // root package guid: {45A143E0-D43A-4f51-ACA6-FF695EEE3256}

                if (openResult)
                {
                    Console.WriteLine("Model open");

                    //EAAPI.Package rootModelPackage = repository.GetPackageByGuid("{45A143E0-D43A-4f51-ACA6-FF695EEE3256}");

                    EAAPI.Diagram diagram = repository.GetDiagramByGuid("{BF30DD09-E13E-451b-B210-786F93A74936}") as EAAPI.Diagram;

                    SpecIF.DataModels.SpecIF specIF;

                    EaUmlToSpecIfConverter converter;

                    ISpecIfMetadataReader metadataReader = new SpecIfFileMetadataReader("d:\\work\\github\\SpecIF\\classDefinitions");

                    converter = new EaUmlToSpecIfConverter(repository, metadataReader);

                    Resource resource = converter.ConvertDiagram(diagram);

                    //specIF = converter.ConvertModelToSpecIF(rootModelPackage);


                    //SpecIfFileReaderWriter.SaveSpecIfToFile(specIF, @"D:\speciftest\TestModel1.specif");

                    Console.WriteLine("Finished");
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
            finally
            {
                //Console.ReadLine();
                repository.Exit();
            }
        }