/// informed that the deletion of the Method will delete the SDM Diagram as well. /// </summary> /// <param name="Repository"></param> /// <param name="Info"></param> /// <returns></returns> public Boolean EA_OnPreDeleteMethod(EA.Repository Repository, EA.Method method) { EA.Method meth = method; EA.Element methParent = Repository.GetElementByID(meth.ParentID); EA.TaggedValue aTag = null; SQLRepository sqlRep = new SQLRepository(Repository, false); foreach (EA.Element actEle in methParent.Elements) { aTag = EAEcoreAddin.Util.EAUtil.findTaggedValue(actEle, SDMModelingMain.SDMContainerAssociatedMethodTaggedValueName); if (aTag != null) { if (aTag.Value.ToString() == meth.MethodGUID.ToString()) { Boolean delete = false; DeleteMethod deleteMethod = new DeleteMethod(delete); deleteMethod.StartPosition = FormStartPosition.CenterScreen; deleteMethod.ShowDialog(); delete = deleteMethod.setVal(); if (delete) { EAUtil.deleteElement(actEle, sqlRep); return(true); } return(false); } } } return(true); }
/// <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 EA.Parameter getOrCreateParameter(EA.Method parentMethod, MocaNode attributeNode) { String oldGuid = attributeNode.getAttributeOrCreate(Main.GuidStringName).Value; String result = repository.SQLQuery("select * from t_operationparams where ea_guid = '" + oldGuid + "'"); EA.Parameter rattribute = null; SQLParameter attribute = new SQLParameter(sqlRep, result); if (attribute.ParameterGUID == "") { rattribute = parentMethod.Parameters.AddNew(attributeNode.getAttributeOrCreate("name").Value, "") as EA.Parameter; rattribute.Update(); repository.Execute("update t_operationparams set ea_guid = '" + oldGuid + "' where ea_guid = '" + rattribute.ParameterGUID + "'"); parentMethod.Parameters.Refresh(); foreach (EA.Parameter parm in parentMethod.Parameters) { if (parm.ParameterGUID == oldGuid) { return(parm); } } } return(rattribute); }
void addParameter(EA.Repository r, EA.Method method, XmlQualifiedName elName, ServiceDescription wsdl) { foreach (XmlSchema sch in wsdl.Types.Schemas) { XmlSchemaObject so = findElement(sch, elName); if (so != null) { XmlSchemaElement sel = (XmlSchemaElement)so; XmlSchemaComplexType complexType = (XmlSchemaComplexType)sel.SchemaType; XmlSchemaSequence sequence = (XmlSchemaSequence)complexType.Particle; foreach (XmlSchemaObject sp in sequence.Items) { XmlSchemaElement spel = (XmlSchemaElement)sp; EA.Parameter param = method.Parameters.AddNew(spel.Name, ""); param.Name = spel.Name; string classifiedId = queryIAAType(r, spel.SchemaTypeName.Name); param.Type = spel.SchemaTypeName.Name; param.ClassifierID = classifiedId; param.Update(); method.Parameters.Refresh(); } } } }
/// <summary> /// 操作とのリンクの解除 /// </summary> public void DisconnectMethod() { if (this.method == null) { return; } var behaviorText = richTextBox.Text.Replace("\n", "\r\n"); if (behaviorText != this.method.Behavior) { var assemblyTitle = (AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), true).Single(); var result = MessageBox.Show(MSG_NO_SAVED, assemblyTitle.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { // 保存して、更新する method.Behavior = behaviorText; method.Update(); } } method = null; enableAutoReflesh.Checked = false; richTextBox.ReadOnly = true; toolStripStatus.Text = "操作とのリンスはありません。"; }
// ReSharper disable once UnusedMethodReturnValue.Global public static bool CreateCallAction(EA.Repository rep, EA.Element action, EA.Method method) { // add ClassifierGUID to target action string updateStr = @"update t_object set classifier_GUID = '" + method.MethodGUID + "' where ea_guid = '" + action.ElementGUID + "' "; rep.Execute(updateStr); // set CallOperation string callOperationProperty = "@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallOperation@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;"; Guid g = Guid.NewGuid(); string xrefid = "{" + g + "}"; string insertIntoTXref = @"insert into t_xref (XrefID, Name, Type, Visibility, Namespace, Requirement, [Constraint], Behavior, Partition, Description, Client, Supplier, Link) VALUES('" + xrefid + "', 'CustomProperties', 'element property','Public', '','','', '',0, '" + callOperationProperty + "', '" + action.ElementGUID + "', null,'')"; rep.Execute(insertIntoTXref); // Link Call Operation to operation g = Guid.NewGuid(); xrefid = "{" + g + "}"; insertIntoTXref = @"insert into t_xref (XrefID, Name, Type, Visibility, Namespace, Requirement, [Constraint], Behavior, Partition, Description, Client, Supplier, Link) VALUES('" + xrefid + "', 'MOFProps', 'element property','Public', '','','', 'target',0, ' null ', '" + method.MethodGUID + "', null,'')"; //rep.Execute(insertIntoT_xref); return(true); }
private void setClassifierAttributes() { int counter = 0; foreach (Object objectToBeTyped in this.ObjectToTypeGuid.Keys) { String typeElementGuid = this.ObjectToTypeGuid[objectToBeTyped]; if (hasGui) { ImportWorker.ReportProgress(4, new ProgressObject(ProgressBarType.Current, "Set Classifiers", ObjectToTypeGuid.Count)); } else { Console.Out.WriteLine("SCALE:Set Classifiers for '" + typeElementGuid + "' %" + counter + "/" + ObjectToTypeGuid.Count + "#"); counter++; } if (OldGuidToNewGuid.ContainsKey(typeElementGuid)) { String newTypeElementGuid = this.OldGuidToNewGuid[typeElementGuid]; EA.Element typeElement = ElementGuidToElement[newTypeElementGuid]; if (objectToBeTyped is EA.Element) { EA.Element elem = objectToBeTyped as EA.Element; elem.ClassifierID = typeElement.ElementID; elem.Update(); } else if (objectToBeTyped is EA.Method) { EA.Method meth = objectToBeTyped as EA.Method; meth.ReturnType = typeElement.Name; meth.ClassifierID = typeElement.ElementID.ToString(); meth.Update(); } else if (objectToBeTyped is EA.Attribute) { EA.Attribute attr = objectToBeTyped as EA.Attribute; attr.Type = typeElement.Name; attr.ClassifierID = typeElement.ElementID; attr.Update(); } else if (objectToBeTyped is EA.Parameter) { EA.Parameter param = objectToBeTyped as EA.Parameter; param.Type = typeElement.Name; param.ClassifierID = typeElement.ElementID.ToString(); param.Update(); } else { throw new NotImplementedException(); } } else { } } }
// set "ShowBeh=1; in operation field StyleEx public static Boolean SetShowBehaviorInDiagram(EA.Repository rep, EA.Method m) { string updateStr = @"update t_operation set StyleEx = 'ShowBeh=1;'" + " where operationID = " + m.MethodID.ToString(); rep.Execute(updateStr); return(true); }
private void DeleteParameter(EA.Method m) { for (short i = (short)(m.Parameters.Count - 1); i >= 0; i--) { m.Parameters.Delete(i); m.Parameters.Refresh(); } }
public Boolean EA_OnPostNewMethod(EA.Repository Repository, EA.EventProperties Info) { EA.Method method = Repository.GetMethodByID(int.Parse((string)Info.Get(0).Value)); consistencyModule.dispatchSingleObject(Repository, method.MethodGUID, method.ObjectType); incrementalUpdateAdapter.EA_OnPostNewMethod(Repository, Info); return(true); }
public EA.Method getRealMethod() { if (realMethod == null) { realMethod = repository.GetOriginalRepository().GetMethodByID(MethodID); } return(realMethod); }
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(); }
private bool Update(EA.Method mth) { bool result = mth.Update(); if (result == false) { throw new Exception("Update Didn't work out properlly!!!"); } return(result); }
public static Boolean SetBehaviorForOperation(EA.Repository rep, EA.Method op, EA.Element act) { string updateStr = @"update t_operation set behaviour = '" + act.ElementGUID + "' " + " where operationID = " + op.MethodID.ToString(); rep.Execute(updateStr); return(true); }
public ArrayList getParameters(EA.Method method, SQLRepository repository) { ArrayList parameters = new ArrayList(); foreach (EA.Parameter actParameter in method.Parameters) { parameters.Add(actParameter); } return(parameters); }
protected override void Correct(IMyOperation elementToCorrect) { EA.Element theClass = Repository.GetElementByGuid(elementToCorrect.Owner.Guid); EA.Method theOperation = theClass.Methods.Cast <EA.Method>().SingleOrDefault(m => m.MethodGUID == elementToCorrect.Guid); if (theOperation == null) { return; } theOperation.Name = "_" + elementToCorrect.Name; theOperation.Update(); }
// 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); }
protected override void Correct(IMyOperation elementToCorrect) { EA.Element theClass = Repository.GetElementByGuid(elementToCorrect.Owner.Guid); EA.Method theMethod = theClass.Methods.Cast <EA.Method>().SingleOrDefault(m => m.MethodGUID == elementToCorrect.Guid); if (theMethod == null) { return; } theMethod.Name = elementToCorrect.Name.FilterSpecialCharacters(); theMethod.Update(); }
protected override void Correct(IMyParameter elementToCorrect) { EA.Method element = Repository.GetMethodByGuid(elementToCorrect.Owner.Guid); EA.Parameter parameter = element.Parameters.Cast <EA.Parameter>().SingleOrDefault(p => p.ParameterGUID == elementToCorrect.Guid); if (parameter == null) { return; } parameter.Name = elementToCorrect.Name.FilterSpecialCharacters(); parameter.Update(); }
public bool EA_OnPreDeleteMethod(EA.Repository Repository, EA.EventProperties Info) { bool allowed = true; EA.Method meth = Repository.GetMethodByID(int.Parse((string)Info.Get(0).Value)); allowed = allowed && sdmModeling.EA_OnPreDeleteMethod(Repository, meth); allowed = allowed && tggModeling.EA_OnPreDeleteMethod(Repository, meth); incrementalUpdateAdapter.EA_OnPreDeleteMethod(Repository, Info); return(allowed); }
/// <summary> /// 操作オブジェクトの更新 /// </summary> /// <param name="method">操作オブジェクト</param> /// <param name="force">強制更新Flg</param> public void UpdateMethod(EA.Method method, bool force = false) { // 変更なし if (this.method != null && this.method.MethodGUID == method.MethodGUID) { return; } // 強制更新 if (!force) { force = enableAutoReflesh.Checked; } // 操作オブジェクトの更新処理 if (force) { var isChanged = false; var behaviorText = richTextBox.Text.Replace("\n", "\r\n"); if (this.method != null && behaviorText != this.method.Behavior) { var assemblyTitle = (AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), true).Single(); var result = MessageBox.Show(MSG_NO_SAVED, assemblyTitle.Title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes) { // 保存して、更新する this.method.Behavior = behaviorText; this.method.Update(); } else if (result == DialogResult.No) { // 放棄して、更新する } else { // キャンセルして、自動更新を停止する enableAutoReflesh.Checked = false; isChanged = true; } } if (!isChanged) { this.method = method; toolStripStatus.Text = "操作:" + method.Name; richTextBox.ReadOnly = false; richTextBox.Text = method.Behavior; } } }
private void HandleMethod(EA.Method method) { string returnType = method.ReturnType; Method m = new Method(method.Name, returnType); foreach (EA.Parameter p in method.Parameters) { HandleParameter(p, m); } m_Data.AddMethod(m); }
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); }
public static EA.Element GetBehaviorForOperation(EA.Repository repository, EA.Method method) { EA.Element returnValue = null; string behavior = method.Behavior; if (behavior.StartsWith("{", StringComparison.Ordinal) & behavior.EndsWith("}", StringComparison.Ordinal)) { // get object according to behavior EA.Element el = repository.GetElementByGuid(behavior); returnValue = el; } return(returnValue); }
/// <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); }
/// <summary> /// Searches for a MethodTag with the given name on the given Method /// </summary> /// <param name="element"></param> /// <param name="name"></param> /// <returns>the found MethodTag or null</returns> public static EA.MethodTag findTaggedValue(EA.Method method, String name) { method.TaggedValues.Refresh(); EA.MethodTag aTag = null; foreach (EA.MethodTag aTaggi in method.TaggedValues) { if (aTaggi.Name == name) { aTag = aTaggi; } } return(aTag); }
public EA.Parameter getRealParameter() { if (parameter == null) { EA.Method parent = repository.GetOriginalRepository().GetMethodByID(this.OperationID); foreach (EA.Parameter actParam in parent.Parameters) { if (actParam.Name == this.Name) { this.parameter = actParam; } } } return(parameter); }
private static void ViewFromBehavior(EA.Repository repository, EA.Element el, DisplayMode showBehavior) { EA.Method method = Util.GetOperationFromBrehavior(repository, el); if (method != null) { if (showBehavior.Equals(DisplayMode.Behavior)) { BehaviorForOperation(repository, method); } else { repository.ShowInProjectView(method); } } }
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 FindAndReplaceItemMethod(EA.Repository rep, string GUID) :base(rep, GUID) { this._meth = rep.GetMethodByGuid(GUID); this.load(rep); }