コード例 #1
0
        void ButtonRevertClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;

            // 反映前のEAから取得した要素オブジェクトの情報を elements 配下のXMLに反映する
            ElementVO revertedElement = null;

            EA.Element eaElemObj = (EA.Element)repo.GetElementByGuid(mergedElement.guid);
            if (eaElemObj == null)
            {
                MessageBox.Show("EAから要素の取得に失敗しました。 異常終了しました。 GUID=" + mergedElement.guid);
                return;
            }
            else
            {
                revertedElement = ObjectEAConverter.getElementFromEAObject(eaElemObj);
            }


            // 反映後のEAから取得した要素オブジェクトの情報を elements 配下のXMLに反映する
            ArtifactXmlWriter writer       = new ArtifactXmlWriter();
            StreamWriter      elsw         = null;
            string            outputDir    = ProjectSetting.getVO().projectPath;
            string            elemFilePath = outputDir + @"\elements\" + revertedElement.guid.Substring(1, 1) + @"\" + revertedElement.guid.Substring(2, 1) + @"\" + revertedElement.guid.Substring(1, 36) + ".xml";

            try {
                //BOM無しのUTF8でテキストファイルを作成する
                elsw = new StreamWriter(elemFilePath);
                elsw.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8""?> ");
                ElementXmlWriter.writeElementXml(revertedElement, 0, elsw);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            } finally {
                if (elsw != null)
                {
                    elsw.Close();
                }
            }

            // changedFile が存在したら削除する
            try {
                string changedElemFilePath = outputDir + @"\elements\" + revertedElement.guid.Substring(1, 1) + @"\" + revertedElement.guid.Substring(2, 1) + @"\" + revertedElement.guid.Substring(1, 36) + "_changed.xml";
                if (System.IO.File.Exists(changedElemFilePath))
                {
                    System.IO.File.Delete(changedElemFilePath);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }

            // 呼び出し元から受領した更新後ElementをRevert後の要素で置き換え
//			rightElement = revertedElement;

            // 親フォームの再描画を依頼
            ElementForm oya = (ElementForm)this.Owner;

            oya.repaint(revertedElement);

            // XMLファイルをコミットするためにTortoiseGitを起動する
            //string exename = @"TortoiseGitProc.exe";
            //string arguments = @"/command:commit /path:" + elemFilePath;

            //Process p = Process.Start( exename, arguments );

            // 自分をクローズ
            this.Close();
        }
コード例 #2
0
 /// <summary>
 /// Create a package element. Be aware that a package element also contains an element to support
 /// element specific things like tagged values.
 /// </summary>
 /// <param name="rep"></param>
 /// <param name="guid"></param>
 public FindAndReplaceItemPackage(EA.Repository rep, string guid)  : base(rep, guid)
 {
     _el  = rep.GetElementByGuid(guid);
     _pkg = rep.GetPackageByGuid(guid);
     Load(rep);
 }
コード例 #3
0
ファイル: EAUtil.cs プロジェクト: SvenPeldszus/emoflon-tool
        internal static IEnumerable <EA.Element> findAllStereotypedElements(EA.Repository repository, String stereotype)
        {
            String sqlResult = repository.SQLQuery("SELECT ea_guid FROM t_object where Stereotype ='" + stereotype + "'");

            return(getXMLNodeContentFromSQLQueryString(sqlResult, "ea_guid").Select(id => repository.GetElementByGuid(id)).Where(elt => elt != null));
        }
コード例 #4
0
        void ButtonCommitCloseClick(object sender, EventArgs e)
        {
            EA.Repository repo = ProjectSetting.getVO().eaRepo;

            if (mergedElement == null)
            {
                MessageBox.Show("反映するべき差分が見つからなかったため、終了します");
                return;
            }

            // 変更のあったメソッドを順にEAに反映する
            foreach (MethodVO m in mergedElement.methods)
            {
                MethodVO updMth = searchMethodByGuid(rightElement.methods, m.guid);
                if (m.changed == 'U')
                {
                    execUpdateMethod(repo, updMth);
                }
            }

            // 反映後のEAから取得した要素オブジェクトの情報を elements 配下のXMLに反映する
            ElementVO refreshedElement = null;

            EA.Element eaElemObj = (EA.Element)repo.GetElementByGuid(mergedElement.guid);
            if (eaElemObj == null)
            {
                MessageBox.Show("EAから要素の取得に失敗しました。 異常終了しました。 GUID=" + mergedElement.guid);
                return;
            }
            else
            {
                refreshedElement = ObjectEAConverter.getElementFromEAObject(eaElemObj);
            }

            // 反映後のEAから取得した要素オブジェクトの情報を elements 配下のXMLに反映する
            StreamWriter elsw         = null;
            string       outputDir    = ProjectSetting.getVO().projectPath;
            string       elemFilePath = outputDir + @"\elements\" + refreshedElement.guid.Substring(1, 1) + @"\" + refreshedElement.guid.Substring(2, 1) + @"\" + refreshedElement.guid.Substring(1, 36) + ".xml";

            try {
                //BOM無しのUTF8でテキストファイルを作成する
                elsw = new StreamWriter(elemFilePath);
                elsw.WriteLine(@"<?xml version=""1.0"" encoding=""UTF-8""?> ");
                ElementXmlWriter.writeElementXml(refreshedElement, 0, elsw);
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            } finally {
                if (elsw != null)
                {
                    elsw.Close();
                }
            }

            // changedFile が存在したら削除する
            try {
                string changedElemFilePath = outputDir + @"\elements\" + refreshedElement.guid.Substring(1, 1) + @"\" + refreshedElement.guid.Substring(2, 1) + @"\" + refreshedElement.guid.Substring(1, 36) + "_changed.xml";
                if (System.IO.File.Exists(changedElemFilePath))
                {
                    System.IO.File.Delete(changedElemFilePath);
                }
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
            }

            // 親フォームの再描画を依頼
            ElementForm oya = (ElementForm)this.Owner;

            oya.repaint(refreshedElement);

            // XMLファイルをコミットするためにTortoiseGitを起動する
            //string exename = @"TortoiseGitProc.exe";
            //string arguments = @"/command:commit /path:" + elemFilePath;
            //Process p = Process.Start( exename, arguments );

            // 自分をクローズ
            this.Close();
        }
コード例 #5
0
 public EA.Element GetEaObject(EnAr.Element element)
 {
     return(repositoryEa.GetElementByGuid(element.ElementGUID));
 }
 public FindAndReplaceItemElement(EA.Repository rep, string GUID)  : base(rep, GUID)
 {
     this._el = rep.GetElementByGuid(GUID);
     this.load(rep);
 }
コード例 #7
0
ファイル: EAGoatJira.cs プロジェクト: SlavekRydval/GoatJira
 public static string GetJiraKeyFromElement(EA.Repository Repository, string GUID, EA.ObjectType ot)
 => GetJiraKeyFromElement(Repository, Repository.GetElementByGuid(GUID), ot);
コード例 #8
0
        private static void sync_hierarchy(EA.Repository Repository, EA.Diagram diagram, EA.Element sample, JObject jo, EA.Package pkg, DiagramCache diagramCache)
        {
            logger.log("Syncing JObject:" + sample.Name);
            Dictionary <string, RunState> rs  = ObjectManager.parseRunState(sample.RunState);
            Dictionary <string, RunState> nrs = new Dictionary <string, RunState>();

            foreach (JProperty p in jo.Properties())
            {
                logger.log("Property:" + p.Name + ":" + p.Value.ToString());
                if (p.Name == RoundTripAddInClass.HIERARCHY_PROPERTY_LEVEL)
                {
                    continue;
                }
                if (p.Name == RoundTripAddInClass.HIERARCHY_PROPERTY_ID)
                {
                    continue;
                }
                if (p.Name == RoundTripAddInClass.HIERARCHY_PROPERTY_NAME)
                {
                    sample.Name = p.Value.ToString();
                    continue;
                }
                if (p.Name == RoundTripAddInClass.HIERARCHY_PROPERTY_DESCRIPTION)
                {
                    sample.Notes = p.Value.ToString();
                    continue;
                }

                if (p.Name == RoundTripAddInClass.HIERARCHY_PROPERTY_TYPE)
                {
                    string     classifierName    = p.Value.ToString();
                    EA.Element elementClassifier = diagramCache.elementIDHash[sample.ClassifierID];
                    if (elementClassifier == null || elementClassifier.Name != classifierName)
                    {
                        EA.Element clazz = RepositoryHelper.queryClassifier(Repository, classifierName);
                        if (clazz != null)
                        {
                            sample.ClassifierID = clazz.ElementID;
                            continue;
                        }
                    }
                    else
                    {
                    }
                    continue;
                }
                if (p.Name == RoundTripAddInClass.HIERARCHY_PROPERTY_PARENT)
                {
                    string guid = p.Value.ToString();
                    if (guid == null || guid.Length == 0 || guid == "null")
                    {
                        continue;
                    }

                    EA.Element parent = null;
                    if (diagramCache.elementGuidHash.ContainsKey(guid))
                    {
                        parent = diagramCache.elementGuidHash[guid];
                    }
                    if (parent == null)
                    {
                        parent = Repository.GetElementByGuid(guid);
                    }
                    if (parent == null)
                    {
                        logger.log("missing parent");
                        continue;
                    }
                    else
                    {
                        linkToParent(Repository, diagram, sample, parent);
                    }
                    continue;
                }

                //string rsv=null;
                if (p.Value.Type != JTokenType.Object && p.Value.Type != JTokenType.Array)
                {
                    //logger.log("Adding Property:" + sample.Name);
                    RunState r;
                    if (rs.ContainsKey(p.Name))
                    {
                        r = rs[p.Name];
                    }
                    else
                    {
                        r     = new RunState();
                        r.key = p.Name;
                    }
                    r.value = p.Value.ToString();

                    nrs.Add(r.key, r);
                }
            }

            sample.RunState = ObjectManager.renderRunState(nrs);
            logger.log(sample.RunState);
            sample.Update();

            foreach (EA.Connector con in sample.Connectors)
            {
                EA.Element related = null;

                if (!DiagramManager.isVisible(con)) //skip not visiable
                {
                    continue;
                }

                //logger.log("Connector:" + con.SupplierEnd.Role);

                if (sample.ElementID == con.ClientID)
                {
                    if (diagramCache.elementIDHash.ContainsKey(con.SupplierID))
                    {
                        related = diagramCache.elementIDHash[con.SupplierID];
                    }

                    if (related == null)
                    {
                        related = Repository.GetElementByID(con.SupplierID);
                    }

                    JProperty p = jo.Property(con.SupplierEnd.Role);

                    if (p != null)
                    {
                        //logger.log("Found Json Property:" + con.SupplierEnd.Role);
                        if (p.Value.Type == JTokenType.Object)
                        {
                            JObject pjo = (JObject)p.Value;
                            sync_hierarchy(Repository, diagram, related, pjo, pkg, diagramCache);
                        }
                        else if (p.Value.Type == JTokenType.Array)
                        {
                            JArray ja = (JArray)p.Value;
                            if (ja.Count > 0)
                            {
                                JToken t = ja.ElementAt(0);
                                ja.RemoveAt(0);
                                if (t.Type == JTokenType.Object)
                                {
                                    sync_hierarchy(Repository, diagram, related, (JObject)t, pkg, diagramCache);
                                }
                                else
                                {
                                    MessageBox.Show("Arrays of types other than object not supported");
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #9
0
 public FindAndReplaceItemElement(EA.Repository rep, string guid)  : base(rep, guid)
 {
     this._el = rep.GetElementByGuid(guid);
     this.Load(rep);
 }
コード例 #10
0
        /// <summary>
        /// Extension Method EA.Repository to get:
        /// - EA Object
        /// - EA.ObjectType
        /// from Object Type in Table and GUID
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="sqlObjectType"></param>
        /// <param name="guid"></param>
        /// <param name="objectType"></param>
        /// <returns></returns>
        public static object GetEaObject(this EA.Repository rep, string sqlObjectType, string guid, out EA.ObjectType objectType)
        {
            EA.ObjectType eaObjectType;
            objectType = EA.ObjectType.otNone;

            // eaObjectType found in dictionary
            if (EaObjectTypes.TryGetValue(sqlObjectType, out eaObjectType))
            {
                switch (eaObjectType)
                {
                case EA.ObjectType.otElement:
                    objectType = eaObjectType;
                    return(rep.GetElementByGuid(guid));

                case EA.ObjectType.otDiagram:
                    objectType = eaObjectType;
                    return((object)rep.GetDiagramByGuid(guid));

                case EA.ObjectType.otPackage:
                    objectType = eaObjectType;
                    return(rep.GetPackageByGuid(guid));

                case EA.ObjectType.otAttribute:
                    objectType = eaObjectType;
                    return(rep.GetAttributeByGuid(guid));

                case EA.ObjectType.otMethod:
                    objectType = eaObjectType;
                    return(rep.GetMethodByGuid(guid));

                case EA.ObjectType.otConnector:
                    objectType = eaObjectType;
                    return(rep.GetConnectorByGuid(guid));

                default:
                    break;
                }
            }
            else
            {
                // by SQL
                string where = $"where ea_guid = '{ guid}'";
                string sql = $"select 'OBJECT'  as object_type from t_object  {where}      UNION " +
                             $"select 'DIAGRAM'                from t_diagram {where}            ";
                XElement x     = XElement.Parse(rep.SQLQuery(sql));
                var      oType = (from t in x.Descendants("object_type")
                                  select t).FirstOrDefault();
                if (oType == null)
                {
                    MessageBox.Show($"GUID:'{guid}'", @"GUID not found, Break!!!!");
                    return(null);
                }
                string type = oType.Value;
                switch (type)
                {
                case "OBJECT":
                    objectType = EA.ObjectType.otElement;
                    return(rep.GetElementByGuid(guid));

                case "DIAGRAM":
                    objectType = EA.ObjectType.otDiagram;
                    return(rep.GetDiagramByGuid(guid));

                default:
                    MessageBox.Show($"GUID searched in object, diagram:'{guid}'", @"GUID not found in Repository, Break!!!!");
                    return(null);
                }
            }
            return(null);
        }
コード例 #11
0
        public bool EA_OnContextItemDoubleClicked(EA.Repository Repository, String GUID, EA.ObjectType ot)
        {
            SQLRepository sqlRepository = new SQLRepository(Repository, false);

            EA.Diagram currentDiagram = Repository.GetCurrentDiagram();
            if (currentDiagram != null)
            {
                Repository.SaveDiagram(currentDiagram.DiagramID);
            }

            if (ot == EA.ObjectType.otPackage)
            {
                EA.Package doubleClickedPackage = Repository.GetPackageByGuid(GUID);
                if (doubleClickedPackage.Element.Stereotype == TGGModelingMain.TggSchemaPackageStereotype)
                {
                    return(onTggSchemaPackageDoubleClicked(sqlRepository, doubleClickedPackage));
                }
            }

            if (ot == EA.ObjectType.otElement)
            {
                EA.Element doubleClickedElement = Repository.GetElementByGuid(GUID);
                if (doubleClickedElement.Stereotype == TGGModelingMain.TggLinkStereotype)
                {
                    if (doubleClickedElement.Diagrams.Count > 0)
                    {
                        onTggLinkDoubleClicked(Repository, doubleClickedElement);
                        return(true);
                    }
                }

                else if (doubleClickedElement.Stereotype == TGGModelingMain.TggObjectVariableStereotype)
                {
                    onTggOvDoubleClicked(sqlRepository, doubleClickedElement);
                    return(true);
                }
                else if (doubleClickedElement.Stereotype == TGGModelingMain.TggCorrespondenceStereotype)
                {
                    onTggCorrespondenceDoubleClicked(sqlRepository, doubleClickedElement);
                    return(true);
                }

                else if (doubleClickedElement.Stereotype == CSPConstraintStereotype || doubleClickedElement.Stereotype == "TGGCsp")
                {
                    if (currentDiagram != null && TggRuleDiagramMetatype.Contains(currentDiagram.MetaType))
                    {
                        onCSPConstraintDoubleClicked(sqlRepository, doubleClickedElement);
                        return(true);
                    }
                }
                else if (doubleClickedElement.Stereotype == TGGModelingMain.TggRuleStereotype)
                {
                    if (doubleClickedElement.Diagrams.Count > 0)
                    {
                        onTggRuleDoubleClicked(Repository, doubleClickedElement);
                        return(true);
                    }
                }
            }
            if (ot == EA.ObjectType.otConnector)
            {
                if (currentDiagram != null && TGGModelingMain.TggRuleDiagramMetatype.Contains(currentDiagram.MetaType))
                {
                    EA.Connector doubleClickedConnector = Repository.GetConnectorByGuid(GUID);
                    if (doubleClickedConnector.Stereotype == TGGModelingMain.TggLinkVariableStereotype || doubleClickedConnector.Stereotype == SDMModelingMain.LinkVariableStereotype)
                    {
                        onTggLvDoubleClicked(sqlRepository, sqlRepository.GetConnectorByID(doubleClickedConnector.ConnectorID));
                        return(true);
                    }
                }
            }
            return(false);
        }