/// <summary> /// /// </summary> private void exportElementGraph() { StreamWriter grphsw = null; try { grphsw = new StreamWriter(outputDir + "\\" + "graphdata.dat", false, System.Text.Encoding.GetEncoding("utf-8")); // Elementノードの出力 List <ElementSearchItem> elementSearches = getElementSearcheItems(); foreach (ElementSearchItem elemSrch in elementSearches) { grphsw.Write("CREATE (" + "E" + elemSrch.elementId + ":Element "); grphsw.Write("{ name:\"" + elemSrch.elemName + "\","); grphsw.Write(" id:" + elemSrch.elementId + ","); grphsw.Write(" path:\"" + elemSrch.elemPath + "\" "); grphsw.WriteLine("});"); } // Element間の接続情報を追加 ConnectorSearcher connectorSearcher = new ConnectorSearcher(); // 抽出されたElementSearchItem のGUIDをキーとして、Connector情報を調べる foreach (ElementSearchItem elemSrch in elementSearches) { List <ConnectorVO> elemConnectors = connectorSearcher.findByObjectGuid(elemSrch.elemGuid); foreach (ConnectorVO conn in elemConnectors) { // 自オブジェクトがsrcの場合のみ if (conn.srcObjId == elemSrch.elementId) { // 2ノードのMATCHと、MATCHされた2ノード間にリレーションを設定する以下のようなCypher文を出力: // MATCH (src:Element{id:9999}),(dst:Element{id:9999}) CREATE (src)-[:Association]->(dst); grphsw.Write("MATCH (src:Element{id:" + conn.srcObjId + "}), "); grphsw.Write("(dst:Element{id:" + conn.destObjId + "}) "); grphsw.WriteLine("CREATE (src)-[:" + conn.connectorType + "]->(dst)"); grphsw.WriteLine(";"); } } } } catch (Exception ex) { Console.WriteLine("Message=" + ex.Message); Console.WriteLine(ex.StackTrace); } finally { if (grphsw != null) { grphsw.Close(); } } }
private static void writePlantUml(ElementVO element, StreamWriter sw) { sw.WriteLine(""); // sw.WriteLine("[plantuml, images/" + element.guid.Substring(1,8) + ", svg]"); sw.WriteLine("[plantuml, img-" + element.guid.Substring(1, 13) + ", png]"); sw.WriteLine("--"); sw.WriteLine("@startuml"); sw.WriteLine("class \"" + filterSpecialChar(element.name) + "\" " + getStereotypeStr(element.stereoType) + " {"); if (element.attributes != null) { foreach (AttributeVO attr in element.attributes) { sw.WriteLine(" " + getVisibilitySymbol(attr.visibility) + " " + attr.name + ""); } } if (element.methods != null) { foreach (MethodVO mth in element.methods) { sw.WriteLine(" " + getVisibilitySymbol(mth.visibility) + " " + mth.name + "()"); } } sw.WriteLine("}"); ElementSearcher elemSrch = new ElementSearcher(); // DBからこの要素につながっている接続情報を取得 ConnectorSearcher searcher = new ConnectorSearcher(); List <ConnectorVO> conns = searcher.findByObjectGuid(element.guid); Dictionary <string, ElementSearchItem> nameHash = new Dictionary <string, ElementSearchItem>(); List <ConnectorVO> srcConnList = new List <ConnectorVO>(); List <ConnectorVO> destConnList = new List <ConnectorVO>(); foreach (ConnectorVO cn in conns) { if (cn.srcObjGuid == element.guid) { srcConnList.Add(cn); outputConnDestClass(cn.destObjGuid, elemSrch, nameHash, sw); } if (cn.destObjGuid == element.guid) { destConnList.Add(cn); outputConnDestClass(cn.srcObjGuid, elemSrch, nameHash, sw); } } for (var i = 0; i < srcConnList.Count; i++) { outputSrcConnectLine(srcConnList[i], sw); } for (var i = 0; i < destConnList.Count; i++) { outputDestConnectLine(destConnList[i], sw); } sw.WriteLine("@enduml"); sw.WriteLine("--"); sw.WriteLine(""); }
/// <summary> /// 自クラスから参照できる識別子を検索し、補完ウィンドウに出力する。 /// </summary> /// <param name="elementVO"></param> /// <returns></returns> public IList <ICompletionData> searchCompletionDataFromMyOwn(ElementVO elementVO) { IList <ICompletionData> retDatas = new List <ICompletionData>(); double priority = 1.0; // 自要素が保持する属性を取得して追加 foreach (AttributeVO attr in elementVO.attributes) { string content = "this." + attr.name; string description = attr.notes; string text = "this." + attr.name; retDatas.Add(new CompletionData(content, description, bitmapAttr, priority++, text)); } // 自要素が保持する操作を取得して追加 foreach (MethodVO mth in elementVO.methods) { string content = "this." + mth.name; string description = mth.notes; string text = "this." + mth.name + "(" + getParameterString(mth.parameters) + ")"; retDatas.Add(new CompletionData(content, description, bitmapMth, priority++, text)); } // 自要素の接続先要素を全て抽出 ConnectorSearcher connSearcher = new ConnectorSearcher(); List <ConnectorVO> retConns = connSearcher.findByObjectGuid(elementVO.guid); foreach (ConnectorVO cn in retConns) { string targetName = ""; switch (cn.connectorType) { // 依存線、関連線で自分が src側の場合は destのオブジェクト名を取得 case "Dependency": case "Association": if (cn.srcObjGuid == elementVO.guid) { targetName = cn.destObjName; } break; // 集約線で自分が dest側の場合は srcのオブジェクト名を取得 case "Aggregation": if (cn.destObjGuid == elementVO.guid) { targetName = cn.srcObjName; } break; } // 得られた名前が空でなかったら、候補として追加 if (targetName != "") { retDatas.Add(new CompletionData(targetName, targetName, null, priority++, targetName)); } } return(retDatas); }
private void readElementContents(ElementVO elemvo, XmlNode parentNode) { List <AttributeVO> retAttrList = new List <AttributeVO>(); List <MethodVO> retMethList = new List <MethodVO>(); IList <ConnectorVO> retConnList = new List <ConnectorVO>(); foreach (XmlNode elemNode in parentNode.ChildNodes) { if ("attribute".Equals(elemNode.Name)) { AttributeVO attvo = new AttributeVO(); foreach (XmlAttribute attr in elemNode.Attributes) { switch (attr.Name) { case "name": attvo.name = attr.Value; break; case "alias": attvo.alias = attr.Value; break; // case "stereotype" : attvo.stereoType = attr.Value; break; case "guid": attvo.guid = attr.Value; break; // case "pos" : attvo.pos = attr.Value; break; } } retAttrList.Add(attvo); } if ("method".Equals(elemNode.Name)) { MethodVO mthvo = new MethodVO(); foreach (XmlAttribute attr in elemNode.Attributes) { switch (attr.Name) { case "name": mthvo.name = attr.Value; break; case "alias": mthvo.alias = attr.Value; break; // case "stereotype" : mthvo.stereoType = attr.Value; break; case "guid": mthvo.guid = attr.Value; break; // case "pos" : mthvo.pos = attr.Value; break; } } if (elemNode.SelectSingleNode("behavior") != null) { mthvo.behavior = elemNode.SelectSingleNode("behavior").InnerText; } if (elemNode.SelectSingleNode("notes") != null) { mthvo.notes = elemNode.SelectSingleNode("notes").InnerText; } // mthvo.returnType = elemNode.elemNode.SelectSingleNode("returnType").InnerText; // mthvo.visibility = elemNode.elemNode.SelectSingleNode("visibility").InnerText; retMethList.Add(mthvo); } // if ( "connector".Equals(elemNode.Name) ) { // ConnectorVO convo = new ConnectorVO(); // foreach(XmlAttribute attr in elemNode.Attributes) { // switch( attr.Name ) { // case "name" : convo.name = attr.Value; break; // case "guid" : convo.guid = attr.Value; break; // } // } // // this.connReader.readConnectorByGUID(convo, elemvo); // // retConnList.Add(convo); // } } elemvo.attributes = retAttrList; elemvo.sortAttributes(); elemvo.methods = retMethList; elemvo.sortMethods(); elemvo.connectors = connSearcher.findByObjectGuid(elemvo.guid); }
private void readElementContents(ElementVO elemvo, XmlNode parentNode) { List <AttributeVO> retAttrList = new List <AttributeVO>(); List <MethodVO> retMethList = new List <MethodVO>(); List <TaggedValueVO> retTagValList = new List <TaggedValueVO>(); List <ConnectorVO> retConnList = new List <ConnectorVO>(); foreach (XmlNode eNode in parentNode.ChildNodes) { if ("attribute".Equals(eNode.Name)) { AttributeVO attvo = new AttributeVO(); foreach (XmlAttribute attr in eNode.Attributes) { switch (attr.Name) { case "name": attvo.name = attr.Value; break; case "alias": attvo.alias = attr.Value; break; case "stereotype": attvo.stereoType = attr.Value; break; case "guid": attvo.guid = attr.Value; break; case "pos": Int32 p; if (!Int32.TryParse(attr.Value, out p)) { p = 0; } attvo.pos = p; break; case "changed": attvo.changed = attr.Value[0]; break; } } retAttrList.Add(attvo); } if ("method".Equals(eNode.Name)) { MethodVO mthvo = new MethodVO(); foreach (XmlAttribute attr in eNode.Attributes) { switch (attr.Name) { case "name": mthvo.name = attr.Value; break; case "alias": mthvo.alias = attr.Value; break; case "stereotype": mthvo.stereoType = attr.Value; break; case "guid": mthvo.guid = attr.Value; break; case "pos": Int32 p; if (!Int32.TryParse(attr.Value, out p)) { p = 0; } mthvo.pos = p; break; case "changed": mthvo.changed = attr.Value[0]; break; } } if (eNode.SelectSingleNode("behavior") != null) { mthvo.behavior = eNode.SelectSingleNode("behavior").InnerText; } if (eNode.SelectSingleNode("notes") != null) { mthvo.notes = eNode.SelectSingleNode("notes").InnerText; } if (eNode.SelectSingleNode("returnType") != null) { mthvo.returnType = eNode.SelectSingleNode("returnType").InnerText; } if (eNode.SelectSingleNode("visibility") != null) { mthvo.visibility = eNode.SelectSingleNode("visibility").InnerText; } retMethList.Add(mthvo); } // タグ付き値の読み込み if ("tv".Equals(eNode.Name)) { retTagValList = readTaggedValues(eNode); } // if ( "connector".Equals(eNode.Name) ) { // ConnectorVO convo = new ConnectorVO(); // foreach(XmlAttribute attr in eNode.Attributes) { // switch( attr.Name ) { // case "name" : convo.name = attr.Value; break; //// case "alias" : convo.alias = attr.Value; break; //// case "stereotype" : convo.stereoType = attr.Value; break; // case "guid" : convo.guid = attr.Value; break; //// case "pos" : convo.pos = attr.Value; break; // } // } // // this.connReader.readConnectorByGUID(convo, elemvo); // // retConnList.Add(convo); // } } elemvo.attributes = retAttrList; elemvo.methods = retMethList; elemvo.taggedValues = retTagValList; // ConnectionSearcher if (connSearcher == null) { elemvo.connectors = new List <ConnectorVO>(); elemvo.sortAttributesGUID(); elemvo.sortMethodsGUID(); elemvo.sortTaggedValuesGUID(); } else { elemvo.connectors = connSearcher.findByObjectGuid(elemvo.guid); elemvo.sortAttributes(); elemvo.sortMethods(); elemvo.sortTaggedValues(); } }