public EA.Method getOrCreateMethod(SQLElement parentClass, String oldGuid, String methodName, String returnType) { EA.Method method = repository.GetMethodByGuid(oldGuid); if (method == null) { method = parentClass.getRealElement().Methods.AddNew(methodName, "") as EA.Method; method.ReturnType = returnType; method.Update(); repository.Execute("update t_operation set ea_guid = '" + oldGuid + "' where ea_guid = '" + method.MethodGUID + "'"); method = repository.GetMethodByGuid(oldGuid); } return(method); }
/// <summary> /// Find method from method name /// </summary> /// <param name="rep"></param> /// <param name="methodName"></param> /// <param name="isNoExtern"></param> /// <returns></returns> public static EA.Method GetMethodFromMethodName(EA.Repository rep, string methodName, bool isNoExtern = false) { EA.Method method = null; string externStereotype = ""; if (isNoExtern) { externStereotype = " AND (stereotype = NULL OR stereotype <> 'extern')"; } string query = $@"select op.ea_guid AS EA_GUID from t_operation op where op.name = '{methodName}' {externStereotype}"; string str = rep.SQLQuery(query); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//EA_GUID"); if (operationGuidNode != null) { string guid = operationGuidNode.InnerText; method = rep.GetMethodByGuid(guid); } return(method); }
public void showObjectProperties(EA.Repository Repository, string GUID, EA.ObjectType ot) { eaObjectType.Text = ot.ToString(); eaObjectName.Text = "?"; switch (ot) { case EA.ObjectType.otAttribute: EA.Attribute attribute = Repository.GetAttributeByGuid(GUID); currentEaObject = attribute; currentEaObjectCollections = null; eaObjectName.Text = attribute.Name; showEmbeddedObjects.Enabled = false; showEmbeddedObjects.Checked = false; break; case EA.ObjectType.otElement: EA.Element element = Repository.GetElementByGuid(GUID); currentEaObject = element; currentEaObjectCollections = new EAElementCollections(element); eaObjectName.Text = element.Name; showEmbeddedObjects.Enabled = true; break; case EA.ObjectType.otMethod: EA.Method method = Repository.GetMethodByGuid(GUID); currentEaObject = method; currentEaObjectCollections = null; eaObjectName.Text = method.Name; showEmbeddedObjects.Enabled = false; showEmbeddedObjects.Checked = false; break; case EA.ObjectType.otPackage: EA.Package package = Repository.GetPackageByGuid(GUID); currentEaObject = package; currentEaObjectCollections = new EAPackageCollections(package); eaObjectName.Text = package.Name; showEmbeddedObjects.Enabled = true; break; case EA.ObjectType.otConnector: EA.Connector connector = Repository.GetConnectorByGuid(GUID); currentEaObject = connector; currentEaObjectCollections = null; showEmbeddedObjects.Enabled = false; showEmbeddedObjects.Checked = false; break; default: currentEaObject = null; currentEaObjectCollections = null; propertyGrid.SelectedObject = null; showEmbeddedObjects.Enabled = false; showEmbeddedObjects.Checked = false; break; } SynchPropertyGridSelection(); }
/// <summary> /// コンテキストのカーソルチェンジイベント /// </summary> /// <param name="Repository">EAリポジトリ</param> /// <param name="GUID">項目のGUID</param> /// <param name="ot">項目の種類</param> public void EA_OnContextItemChanged(EA.Repository Repository, string GUID, EA.ObjectType ot) { if (behaverControl == null || ot != EA.ObjectType.otMethod) { return; } behaverControl.UpdateMethod(Repository.GetMethodByGuid(GUID)); }
// Find the operation from Activity / State Machine public static EA.Method GetOperationFromBrehavior(EA.Repository rep, EA.Element el) { EA.Method method = null; string query = ""; string conString = GetConnectionString(rep); // due to shortcuts if (conString.Contains("DBType=3")) { // Oracle DB query = @"select op.ea_guid AS EA_GUID from t_operation op where Cast(op.Behaviour As Varchar2(38)) = '" + el.ElementGUID + "' "; } if (conString.Contains("DBType=1")) // SQL Server { query = @"select op.ea_guid AS EA_GUID from t_operation op where Substring(op.Behaviour,1,38) = '" + el.ElementGUID + "'"; } if (conString.Contains(".eap")) // SQL Server { query = @"select op.ea_guid AS EA_GUID from t_operation op where op.Behaviour = '" + el.ElementGUID + "'"; } if ((!conString.Contains("DBType=1")) && // SQL Server, DBType=0 MySQL (!conString.Contains("DBType=3")) && // Oracle (!conString.Contains(".eap"))) // Access { query = @"select op.ea_guid AS EA_GUID from t_operation op where op.Behaviour = '" + el.ElementGUID + "'"; } string str = rep.SQLQuery(query); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//EA_GUID"); if (operationGuidNode != null) { string guid = operationGuidNode.InnerText; method = rep.GetMethodByGuid(guid); } return(method); }
/// <summary> /// GUIDによりEAからメソッドオブジェクトを取得 /// </summary> /// <param name="methodGuid"></param> /// <returns></returns> private EA.Method getMethodByGuid(string methodGuid) { EA.Repository repo = ProjectSetting.getVO().eaRepo; EA.Method mthObj = (EA.Method)repo.GetMethodByGuid(methodGuid); if (mthObj != null) { return(mthObj); } else { return(null); } }
internal void EA_OnNotifyContextItemModified(EA.Repository Repository, string GUID, EA.ObjectType ot) { if (!initialConnectionAvailable) { return; } //EA_OnNotifyContextItemModified notifies Add-Ins that the current context item has been modified. //This event occurs when a user has modified the context item. Add-Ins that require knowledge of when // an item has been modified can subscribe to this broadcast function. // See also: http://www.sparxsystems.com/enterprise_architect_user_guide/9.3/automation/ea_onnotifycontextitemmodified.html ModificationChange change = new ModificationChange(); change.internalID = GUID; switch (ot) { case EA.ObjectType.otPackage: EA.Package eaPackage = Repository.GetPackageByGuid(GUID); change.elementType = ElementType.PACKAGE; change.name = eaPackage.Name; break; case EA.ObjectType.otElement: EA.Element eaElement = Repository.GetElementByGuid(GUID); change.elementType = ElementType.ELEMENT; change.name = eaElement.Name; break; case EA.ObjectType.otConnector: EA.Connector eaConnector = Repository.GetConnectorByGuid(GUID); change.elementType = ElementType.CONNECTOR; change.name = eaConnector.Name; break; case EA.ObjectType.otAttribute: EA.Attribute method = Repository.GetAttributeByGuid(GUID); change.elementType = ElementType.ATTRIBUTE; change.name = method.Name; break; case EA.ObjectType.otMethod: EA.Method attribute = Repository.GetMethodByGuid(GUID); change.elementType = ElementType.METHOD; change.name = attribute.Name; break; } sendObject(change); }
void EASelectObjectToolStripMenuItemClick(object sender, EventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; if (repo != null) { // 選択された属性に対する更新処理 if (selectedAttribute != null) { EA.Attribute attr = (EA.Attribute)repo.GetAttributeByGuid(selectedAttribute.guid); if (attr != null) { repo.ShowInProjectView(attr); } else { // 属性がGUIDで空振りしたら要素GUIDで再検索 EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem != null) { repo.ShowInProjectView(elem); } } } // 選択された操作に対する更新処理 if (selectedMethod != null) { EA.Method mth = (EA.Method)repo.GetMethodByGuid(selectedMethod.guid); if (mth != null) { repo.ShowInProjectView(mth); } else { // 操作がGUIDで空振りしたら要素GUIDで再検索 EA.Element elem = (EA.Element)repo.GetElementByGuid(myElement.guid); if (elem != null) { repo.ShowInProjectView(elem); } } } } else { MessageBox.Show("EAにアタッチしていないため、選択できません"); } }
public override void Save(EA.Repository rep, FindAndReplaceItem.FieldType fieldType) { EA.Method meth = rep.GetMethodByGuid(Guid); if ((fieldType & FindAndReplaceItem.FieldType.Description) > 0) { meth.Notes = Description; } if ((fieldType & FindAndReplaceItem.FieldType.Name) > 0) { meth.Name = Name; } if ((fieldType & FindAndReplaceItem.FieldType.Stereotype) > 0) { meth.StereotypeEx = Stereotype; } IsUpdated = true; meth.Update(); }
// Find the calling operation from a Call Operation Action public static EA.Method GetOperationFromAction(EA.Repository rep, EA.Element action) { EA.Method method = null; string query = @"select o.Classifier_guid AS CLASSIFIER_GUID from t_object o where o.Object_ID = " + action.ElementID.ToString(); string str = rep.SQLQuery(query); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//CLASSIFIER_GUID"); if (operationGuidNode != null) { string guid = operationGuidNode.InnerText; method = rep.GetMethodByGuid(guid); } return(method); }
/// <summary> /// メソッドのコンテキストメニュー-「EAでこのメソッドを選択」のクリックイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void FocusEAMethodToolStripMenuItemClick(object sender, EventArgs e) { //ContextMenuStripを表示しているコントロールを取得する Control source = methodContextMenuStrip.SourceControl; if (source != null) { MethodVO mth = (MethodVO)((Control)source).Tag; EA.Repository repo = ProjectSetting.getVO().eaRepo; if (mth != null && repo != null) { EA.Method meth = (EA.Method)repo.GetMethodByGuid(mth.guid); if (meth != null) { repo.ShowInProjectView(meth); } } } }
public static EA.Method GetMethodFromMethodName(EA.Repository rep, string methodName) { EA.Method method = null; string query = @"select op.ea_guid AS EA_GUID from t_operation op where op.name = '" + methodName + "' "; string str = rep.SQLQuery(query); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//EA_GUID"); if (operationGuidNode != null) { string guid = operationGuidNode.InnerText; method = rep.GetMethodByGuid(guid); } return(method); }
/// <summary> /// コンテキストメニュー:EAで選択のクリックイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void EASelectObjectToolStripMenuItemClick(object sender, EventArgs e) { EA.Repository repo = ProjectSetting.getVO().eaRepo; if (repo != null) { // メニューを開くために右クリックされたコントロールを取得 Control source = contextMenuStrip1.SourceControl; if (source != null) { if (source.Tag is AttributeVO) { AttributeVO att = (AttributeVO)source.Tag; // EAでGUIDをキーとして対象属性の取得を試み、取れたらプロジェクトブラウザーで選択する EA.Attribute attrObj = (EA.Attribute)repo.GetAttributeByGuid(att.guid); if (attrObj != null) { repo.ShowInProjectView(attrObj); } } else if (source.Tag is MethodVO) { MethodVO mth = (MethodVO)source.Tag; // EAでGUIDをキーとして対象操作の取得を試み、取れたらプロジェクトブラウザーで選択する EA.Method mthObj = (EA.Method)repo.GetMethodByGuid(mth.guid); if (mthObj != null) { repo.ShowInProjectView(mthObj); } } } } else { MessageBox.Show("EAにアタッチしていないため、選択できません"); } }
/// <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) { objectType = EA.ObjectType.otNone; // eaObjectType found in dictionary if (EaObjectTypes.TryGetValue(sqlObjectType, out EA.ObjectType 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); }
public FindAndReplaceItemMethod(EA.Repository rep, string GUID) : base(rep, GUID) { this._meth = rep.GetMethodByGuid(GUID); this.load(rep); }
public FindAndReplaceItemMethod(EA.Repository rep, string guid) : base(rep, guid) { _meth = rep.GetMethodByGuid(guid); Load(rep); }
// // read PDATA1 // public static EA.Element getPDATA(EA.Repository rep, int ID) // { // EA.Element el = null; // string query = ""; // query = // @"select pdata1 AS PDATA1 // from t_object o // where Cast(op.Behaviour As Varchar2(38)) = '" + el.ElementGUID + "'"; // if (rep.ConnectionString.Contains("DBType=3")) // { // Oracle DB // query = // @"select op.ea_guid AS EA_GUID // from t_operation op // where Cast(op.Behaviour As Varchar2(38)) = '" + el.ElementGUID + "'"; // } // if (rep.ConnectionString.Contains("DBType=1")) // // SQL Server // { // query = // @"select op.ea_guid AS EA_GUID // from t_operation op // where Substring(op.Behaviour,1,38) = '" + el.ElementGUID + "'"; // } // if (rep.ConnectionString.Contains(".eap")) // // SQL Server // { // query = // @"select op.ea_guid AS EA_GUID // from t_operation op // where op.Behaviour = '" + el.ElementGUID + "'"; // } // if ((!rep.ConnectionString.Contains("DBType=1")) && // SQL Server, DBType=0 MySQL // (!rep.ConnectionString.Contains("DBType=3")) && // Oracle // (!rep.ConnectionString.Contains(".eap")))// Access // { // query = // @"select op.ea_guid AS EA_GUID // from t_operation op // where op.Behaviour = '" + el.ElementGUID + "'"; // } // string str = rep.SQLQuery(query); // XmlDocument XmlDoc = new XmlDocument(); // XmlDoc.LoadXml(str); // XmlNode operationGUIDNode = XmlDoc.SelectSingleNode("//EA_GUID"); // if (operationGUIDNode != null) // { // string GUID = operationGUIDNode.InnerText; // method = rep.GetMethodByGuid(GUID); // } // return method; // } public static EA.Method GetOperationFromConnector(EA.Repository rep, EA.Connector con) { EA.Method method = null; string query = ""; if (GetConnectionString(rep).Contains("DBType=3")) //pdat3: 'Activity','Sequence', (..) { // Oracle DB query = @"select description AS EA_GUID from t_xref x where Cast(x.client As Varchar2(38)) = '" + con.ConnectorGUID + "'" + " AND Behavior = 'effect' "; } if (GetConnectionString(rep).Contains("DBType=1")) { // SQL Server query = @"select description AS EA_GUID from t_xref x where Substring(x.client,1,38) = " + "'" + con.ConnectorGUID + "'" + " AND Behavior = 'effect' " ; } if (GetConnectionString(rep).Contains(".eap")) { query = @"select description AS EA_GUID from t_xref x where client = " + "'" + con.ConnectorGUID + "'" + " AND Behavior = 'effect' " ; } if ((!GetConnectionString(rep).Contains("DBType=1")) && // SQL Server, DBType=0 MySQL (!GetConnectionString(rep).Contains("DBType=3")) && // Oracle (!GetConnectionString(rep).Contains(".eap"))) // Access { query = @"select description AS EA_GUID from t_xref x where client = " + "'" + con.ConnectorGUID + "'" + " AND Behavior = 'effect' " ; } string str = rep.SQLQuery(query); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(str); //string type = ""; //XmlNode pdat3Node = XmlDoc.SelectSingleNode("//PDAT3"); //if (pdat3Node != null) //{ // type = pdat3Node.InnerText; //} //if ( type.EndsWith(")")) // Operation //{ string guid = null; XmlNode operationGuidNode = xmlDoc.SelectSingleNode("//EA_GUID"); if (operationGuidNode != null) { guid = operationGuidNode.InnerText; method = rep.GetMethodByGuid(guid); } if (method == null) { OpenBehaviorForElement(rep, rep.GetElementByGuid(guid)); } //} return(method); }
private void createExtractedSDMStatementNode() { Boolean thisPatternCreated = false; int leftMax = 0; int topMax = -100000; computeLeftAndTopMax(ref leftMax, ref topMax); EA.Element thisObject = searchThisObject(); //only create a statementNode if there exists a this object on the sdm //otherwise create new story node with an this variable if (thisObject == null) { thisOvPattern = createStoryPattern("this Activity"); thisObject = createThisOv(thisOvPattern); createDiagramObject(leftMax + 50, topMax - 20, 50, 100, thisObject); createDiagramObject(leftMax, topMax, 100, 200, thisOvPattern); thisPatternCreated = true; leftMax += 300; } //create new story node with objectvariable bound to new sdm. if (checkBoxBoundOv.Checked) { EA.Element boundOvPattern = createStoryPattern("Bound new SDM"); EA.Element boundObject2 = createThisOv(boundOvPattern); SQLElement boundObject = sqlRepository.GetElementByID(boundObject2.ElementID); createDiagramObject(leftMax + 20, topMax - 20, 50, 100, boundObject2); createDiagramObject(leftMax, topMax, 100, 200, boundOvPattern); ObjectVariable ov = new ObjectVariable(boundObject, sqlRepository); ov.loadTreeFromTaggedValue(); ov.BindingState = BindingState.BOUND; MethodCallExpression mcExp = new MethodCallExpression(sqlRepository.GetMethodByID(newMethod.MethodID), sqlRepository); ObjectVariableExpression ovExp = new ObjectVariableExpression(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository); mcExp.Target = ovExp; ov.BindingExpression = mcExp; ov.Classifier = ovClassifiersComboBox1.Classifiers[ovClassifiersComboBox1.SelectedIndex]; ov.saveTreeToEATaggedValue(true); sdmCallPattern = boundOvPattern; EA.Method sdmMethod = repository.GetMethodByGuid(EAUtil.findTaggedValue(sqlRepository.GetElementByID(newSdmContainer.ElementID), SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName).Value); sdmMethod.ClassifierID = "" + ov.Classifier.EaElement.ElementID; sdmMethod.ReturnType = ov.Classifier.EaElement.Name; sdmMethod.Update(); } //instead create statement node construct else { EA.Element statementActivity = createStoryPattern("Call extracted method"); StatementNode statementNode = new StatementNode(sqlRepository, sqlRepository.GetElementByID(statementActivity.ElementID)); MethodCallExpression mcExp = new MethodCallExpression(sqlRepository.GetMethodByID(newMethod.MethodID), sqlRepository); ObjectVariableExpression ovExp = new ObjectVariableExpression(sqlRepository.GetElementByID(thisObject.ElementID), sqlRepository); mcExp.Target = ovExp; statementNode.StatementExpression = mcExp; statementActivity.Notes = thisObject.Name + "." + newMethod.Name + "()"; EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, statementActivity, "activityType", "call"); EAEcoreAddin.Util.EAUtil.setTaggedValue(sqlRepository, statementActivity, "evacuated", "false"); statementActivity.Update(); createDiagramObject(leftMax, topMax, 200, 200, statementActivity); statementNode.saveTreeToEATaggedValue(true); sdmCallPattern = statementActivity; } if (thisPatternCreated) { //create edge between this pattern and statement pattern EA.Connector acEdge = thisOvPattern.Connectors.AddNew("", Main.EAControlFlowType) as EA.Connector; acEdge.SupplierID = sdmCallPattern.ElementID; acEdge.Update(); ActivityEdge edge = new ActivityEdge(sqlRepository, sqlRepository.GetConnectorByID(acEdge.ConnectorID)); edge.saveTreeToEATaggedValue(true); } }