Exemplo n.º 1
0
        public string diagramPath(string page, string name)
        {
            string result = diagrampath + @"\content\" + page + "---" + name + ".svg";

            if (logger != null)
            {
                logger.log("FilePath:" + result);
            }
            return(result);
        }
        ///
        /// 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");
            }

            MappingManager.setLogger(logger);
            MappingManager.setFileManager(fileManager);

            HierarchyManager.setLogger(logger);
            HierarchyManager.setFileManager(fileManager);

            PopulationManager.setLogger(logger);
            PopulationManager.setFileManager(fileManager);

            ConstraintManager.setLogger(logger);
            ConstraintManager.setFileManager(fileManager);

            DiagramManager.setLogger(logger);
            DiagramManager.setFileManager(fileManager);

            SchemaManager.setLogger(logger);
            SchemaManager.setFileManager(fileManager);
            SampleManager.setLogger(logger);
            SampleManager.setFileManager(fileManager);

            MetaDataManager.setLogger(logger);
            RepositoryHelper.setLogger(logger);
            ObjectManager.setLogger(logger);

            return("a string");
        }
Exemplo n.º 3
0
        static public void parentToJObject(EA.Repository Repository, EA.Diagram diagram, JArray container, IList <int> sampleIds, EA.Element ancestor, EA.Element constraint, IList <int> visited, IList <int> relationsVisited, DiagramCache diagramCache)
        {
            IList <EA.Element> children = new List <EA.Element>();

            visited.Add(constraint.ElementID);

            EA.Element constraintClazz = diagramCache.elementIDHash[constraint.ClassifierID];


            JObject jsonClass = new JObject();

            jsonClass.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_GUID, constraint.ElementGUID));
            jsonClass.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_NAME, constraint.Name));
            jsonClass.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_CLASS, constraintClazz.Name));
            jsonClass.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_STEREOTYPE, constraint.Stereotype));

            ObjectManager.addTagsToJson(constraint, jsonClass);

            container.Add(jsonClass);

            JArray sources = new JArray();
            JArray targets = new JArray();

            jsonClass.Add(RoundTripAddInClass.CONSTRAINT_PROPERTY_SOURCE, sources);
            jsonClass.Add(RoundTripAddInClass.CONSTRAINT_PROPERTY_TARGET, targets);

            foreach (EA.Connector con in constraint.Connectors)
            {
                if (relationsVisited.Contains(con.ConnectorID))
                {
                    continue;
                }

                if (!DiagramManager.isVisible(con))
                {
                    continue;
                }

                relationsVisited.Add(con.ConnectorID);

                Boolean    isSource = true;
                EA.Element related  = null;
                if (constraint.ElementID == con.ClientID)
                {
                    isSource = false;
                    related  = diagramCache.elementIDHash[con.SupplierID];
                }
                else
                {
                    isSource = true;
                    related  = diagramCache.elementIDHash[con.ClientID];
                }


                String relGuid  = related.ElementGUID;
                String relName  = related.Name;
                String relClass = "";

                if (related.ClassifierID != 0)
                {
                    EA.Element relatedClazz = diagramCache.elementIDHash[related.ClassifierID];
                    relClass = relatedClazz.Name;
                }

                JObject jsonCon = new JObject();
                jsonCon.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_GUID, relGuid));
                jsonCon.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_NAME, relName));
                jsonCon.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_CLASS, relClass));
                jsonCon.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_CONNECTOR_TYPE, con.Type));
                jsonCon.Add(new JProperty(RoundTripAddInClass.CONSTRAINT_PROPERTY_CONNECTOR_GUID, con.ConnectorGUID));

                logger.log("Related " + related.Name + "-" + relClass);
                if (isSource)
                {
                    sources.Add(jsonCon);
                }
                else
                {
                    targets.Add(jsonCon);
                }
            }
        }
Exemplo n.º 4
0
        static public void parentToJObject(EA.Repository Repository, EA.Diagram diagram, JArray container, IList <int> sampleIds, EA.Element ancestor, EA.Element parent, IList <int> visited, int depth, DiagramCache diagramCache)
        {
            String type = "";

            if (parent.ClassifierID != 0)
            {
                //logger.log("Get Parent Classifier");
                EA.Element classifier = diagramCache.elementIDHash[parent.ClassifierID];
                type = classifier.Name;
            }

            JObject jsonClass = new JObject();

            jsonClass.Add(new JProperty(RoundTripAddInClass.HIERARCHY_PROPERTY_TYPE, type));
            jsonClass.Add(new JProperty(RoundTripAddInClass.HIERARCHY_PROPERTY_ID, parent.ElementGUID));
            jsonClass.Add(new JProperty(RoundTripAddInClass.HIERARCHY_PROPERTY_NAME, parent.Name));
            jsonClass.Add(new JProperty(RoundTripAddInClass.HIERARCHY_PROPERTY_DESCRIPTION, parent.Notes));
            jsonClass.Add(new JProperty(RoundTripAddInClass.HIERARCHY_PROPERTY_LEVEL, depth));
            if (ancestor != null)
            {
                jsonClass.Add(new JProperty(RoundTripAddInClass.HIERARCHY_PROPERTY_PARENT, ancestor.ElementGUID));
            }
            else
            {
                jsonClass.Add(new JProperty(RoundTripAddInClass.HIERARCHY_PROPERTY_PARENT, "null"));
            }
            container.Add(jsonClass);

            //ObjectManager.addTagsToJson(parent, jsonClass);
            //ObjectManager.addRunStateToJson(parent.RunState, jsonClass);

            IList <EA.Element> children = new List <EA.Element>();

            visited.Add(parent.ElementID);
            foreach (EA.Connector con in parent.Connectors)
            {
                if (!DiagramManager.isVisible(con)) //skip not visiable
                {
                    continue;
                }

                EA.Element related = DiagramManager.getVisibleRelatedElement(Repository, parent, con, diagramCache);
                if (related == null)
                {
                    continue;
                }

                //logger.log("Parent" + parent.Name);
                //logger.log("Related"+ related.Name);
                if (!sampleIds.Contains(related.ElementID))
                {
                    continue;
                }

                if (visited.Contains(related.ElementID))
                {
                    continue;
                }

                children.Add(related);

                logger.log("Parent:" + parent.Name + " Child:" + related.Name);
            }

            parentsToJObject(Repository, diagram, container, sampleIds, parent, children, visited, ++depth, diagramCache);
        }
Exemplo n.º 5
0
        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);
                }
            }
        }