// 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); }
/// <summary> /// Create Call Action of type "CallBehavior or "CallOperation" /// </summary> /// <param name="rep"></param> /// <param name="action"></param> /// <param name="guid">The guid of method(CallOperation) or of Activity (CallBehavior)</param> /// <param name="typeCall">'CallOperation' or 'CallBehavior'</param> /// <returns></returns> public static bool CreateCallAction(EA.Repository rep, EA.Element action, string guid, string typeCall = "CallOperation") { // add ClassifierGUID to target action string updateStr = $@"update t_object set classifier_GUID = '{guid}' where ea_guid = '{action.ElementGUID}' "; rep.Execute(updateStr); // set CallOperation string callBehaviorProperty = $"@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU={typeCall}@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;"; Guid g = Guid.NewGuid(); string xrefid = "{" + g + "}"; string insertIntoTXref = $@"insert into t_xref (XrefID, Name, Type, Visibility, Description, Client) VALUES('{xrefid}', 'CustomProperties', 'element property','Public', '{callBehaviorProperty}', '{action.ElementGUID}')"; try { rep.Execute(insertIntoTXref); } catch (Exception e) { MessageBox.Show($"{insertIntoTXref}\r\nAction='{action.Name}'\r\n\r\n{e}", "Error CreateAction t_xref"); } return(true); }
public bool Save() { Delete(); // insert string sql = @"insert into t_xref (XrefID, Type, Client) " + $@" VALUES ( '{_xrefGuid}','Favorite', '{_clientGuid}') "; _rep.Execute(sql); return(true); }
// 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); }
public static Boolean SetFrameLinksToDiagram(EA.Repository rep, EA.Element frm, EA.Diagram dia) { string updateStr = @"update t_object set pdata1 = " + dia.DiagramID + " where object_ID = " + frm.ElementID.ToString(); rep.Execute(updateStr); return(true); }
public static Boolean SetDiagramHasAttchaedLink(EA.Repository rep, EA.Element el) { string updateStr = @"update t_object set pdata1 = 'Diagram Note' " + " where object_ID = " + el.ElementID.ToString(); rep.Execute(updateStr); return(true); }
public static Boolean SetVcFlags(EA.Repository rep, EA.Package pkg, string flags) { string updateStr = @"update t_package set packageflags = '" + flags + "' " + " where package_ID = " + pkg.PackageID.ToString(); rep.Execute(updateStr); return(true); }
public EA.Package getOrCreatePackage(SQLPackage rootPackage, MocaNode packageNode) { String oldGuid = packageNode.getAttributeOrCreate(Main.GuidStringName).Value; EA.Package modelPackage = repository.GetPackageByGuid(oldGuid); if (modelPackage != null) { DeleteWithGuid(rootPackage, oldGuid); EA.Package parent = repository.GetPackageByID(modelPackage.ParentID); DeleteWithGuid(parent, oldGuid); } EA.Package rootPackageOriginal = rootPackage.getRealPackage(); String packageName = packageNode.getAttributeOrCreate(MetamodelHelper.MoflonCustomNameTaggedValueName).Value; if (packageName == "") { packageName = packageNode.getAttributeOrCreate("name").Value; } modelPackage = rootPackageOriginal.Packages.AddNew(packageName, "") as EA.Package; if (rootPackageOriginal.ParentID == 0) { modelPackage.Flags = "isModel=1;VICON=3;"; } modelPackage.Update(); // import nsUri setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomNsUriTaggedValueName, packageNode, modelPackage); // import export setTagValueIfPossibleForPackage(MetamodelHelper.MoflonExportTaggedValueName, packageNode, modelPackage); // import pluginID setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomPluginIDTaggedValueName, packageNode, modelPackage); // import prefix setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomNsPrefixTaggedValueName, packageNode, modelPackage); // import validated setTagValueIfPossibleForPackage(MetamodelHelper.MoflonValidatedTaggedValueName, packageNode, modelPackage); // import name setTagValueIfPossibleForPackage(MetamodelHelper.MoflonCustomNameTaggedValueName, packageNode, modelPackage); repository.Execute("update t_package set ea_guid = '" + oldGuid + "' where ea_guid = '" + modelPackage.PackageGUID + "'"); repository.Execute("update t_object set ea_guid = '" + oldGuid + "' where ea_guid = '" + modelPackage.PackageGUID + "'"); modelPackage = repository.GetPackageByGuid(oldGuid); return(modelPackage); }
public static bool SetClassifierId(EA.Repository rep, EA.Element el, string guid) { // add ClassifierGUID to target action string updateStr = @"update t_object set classifier_GUID = '" + guid + "' where ea_guid = '" + el.ElementGUID + "' "; rep.Execute(updateStr); return(true); }
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 static Boolean SetElementHasAttchaedLink(EA.Repository rep, EA.Element el, EA.Element elNote) { string updateStr = @"update t_object set pdata1 = 'Element Note', pdata2 = '" + el.ElementID.ToString() + "', pdata4='Yes' " + " where object_ID = " + elNote.ElementID.ToString(); rep.Execute(updateStr); return(true); }
//--------------------------------------------------------------------- // Save() Save ParameterProperties to t_xref //--------------------------------------------------------------------- // public bool Save() { // create new entry in t_xref if (_xrefid == "") { Guid g = Guid.NewGuid(); _xrefid = g.ToString(); string insertIntoTXref = @"insert into t_xref (XrefID, Name, Type, Visibility, Namespace, Requirement, [Constraint], Behavior, Partition, Description, Client, Supplier, Link) VALUES('" + g + "', 'CustomProperties', 'element property','Public', '','','', '',0, '" + _properties + "', '" + _parTrgt.ElementGUID + "', null,'')"; _rep.Execute(insertIntoTXref); } // update propertyValue string update = @"update t_xref set description = '" + _properties + "' where XrefID = '" + _xrefid + "'"; _rep.Execute(update); return(true); }
// private static void appendTaggedValue() #endregion #region addDiagram methods private static void appendDiagram(EA.Package parentPackage, String diagramMetaType, EA.Repository repository) { if (parentPackage.Diagrams.Count == 0) { EA.Diagram diag = parentPackage.Diagrams.AddNew(parentPackage.Name, "") as EA.Diagram; diag.Update(); diag.StyleEx = "MDGDgm=" + "eMoflon Ecore Diagrams::Ecore Diagram" + ";"; diag.Update(); repository.Execute("UPDATE t_diagram SET Diagram_Type='" + diagramMetaType + "' WHERE Diagram_ID=" + diag.DiagramID); MainImport.getInstance().DiagramsToBeFilled.Add(diag); } }
/// <summary> /// creates an empty story diagram related to the given Method /// </summary> /// <param name="method"></param> /// <param name="repository"></param> /// <param name="currentDiagram"></param> The currently open diagram. An anchor will be added to this diagram. public static void createStoryDiagram(SQLMethod method, EA.Repository repository, EA.Diagram currentDiagram) { EA.Element containingEClass = repository.GetElementByID(method.ParentID); SQLRepository sqlRepository = new SQLRepository(repository, false); EA.Element sdmContainer = (EA.Element)(containingEClass.Elements.AddNew(method.Name, Main.EAClassType)); sdmContainer.ParentID = containingEClass.ElementID; EA.Diagram sdmDiagram = (EA.Diagram)(sdmContainer.Diagrams.AddNew(method.Name + " Story Diagram", SdmDiagramMetatype[0])); sdmDiagram.ParentID = sdmContainer.ElementID; sdmDiagram.ExtendedStyle = "HideRel=0;ShowTags=0;ShowReqs=0;ShowCons=0;OpParams=1;ShowSN=0;ScalePI=0;PPgs.cx=1;PPgs.cy=1;PSize=9;ShowIcons=1;SuppCN=0;HideProps=0;HideParents=0;UseAlias=0;HideAtts=0;HideOps=0;HideStereo=0;HideEStereo=1;FormName=;"; sdmDiagram.StyleEx = sdmDiagram.StyleEx + "HideConnStereotype=0;"; repository.SaveDiagram(sdmDiagram.DiagramID); sdmDiagram.Update(); EA.Element startNode = (EA.Element)sdmContainer.Elements.AddNew(" Start", Main.EAStateNodeType); startNode.Subtype = Main.EAStartNodeSubtype; startNode.ParentID = sdmContainer.ElementID; startNode.Name = SDMUtil.computeStartNodeName(sqlRepository.GetMethodByID(method.MethodID), sqlRepository.GetElementByID(containingEClass.ElementID)); startNode.Update(); EA.DiagramObject startNodeDiagramObject = (EA.DiagramObject)sdmDiagram.DiagramObjects.AddNew("l=50;r=70;t=50;b=70;", Main.EAStateNodeType); startNodeDiagramObject.ElementID = startNode.ElementID; startNodeDiagramObject.Update(); method.getRealMethod().Update(); sdmContainer.Update(); Navigator.addAnchorEntry(sdmDiagram.DiagramID, currentDiagram.DiagramID); String objectStyleString = "StateNodeLBL=CX=437:CY=13:OX=-9:OY=-18:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;DUID=2B547EF9;LBL=CX=437:CY=13:OX=-6:OY=-17:HDN=0:BLD=0:ITA=0:UND=0:CLR=-1:ALN=0:ALT=0:ROT=0;"; repository.Execute("UPDATE t_diagramobjects SET ObjectStyle = '" + objectStyleString + "' WHERE Object_ID = " + startNodeDiagramObject.ElementID); repository.OpenDiagram(sdmDiagram.DiagramID); sdmContainer.Elements.Refresh(); setAnchorElementTags(sqlRepository, currentDiagram, sqlRepository.GetElementByID(sdmContainer.ElementID)); Activity activity = new Activity(sqlRepository.GetElementByID(sdmContainer.ElementID), sqlRepository); activity.OwningOperation = new ECOREModeling.ECOREExportWrapper.EOperation(sqlRepository.GetMethodByID(method.MethodID), sqlRepository); activity.saveTreeToEATaggedValue(true); StartNode startNodeObject = new StartNode(sqlRepository, sqlRepository.GetElementByID(startNode.ElementID)); startNodeObject.saveTreeToEATaggedValue(true); }
/// <summary> /// Create a Tagged value type /// </summary> /// <param name="rep"></param> /// <param name="property"></param> /// <returns></returns> public static bool DeleteTaggedValueTye(EA.Repository rep, string property) { try { string sql = $@"Delete from t_propertytypes where Property = '{property}';"; rep.Execute(sql); } catch (Exception e) { MessageBox.Show($@"Property: '{property}' {e}", @"Can't delete Tagged Value Type"); return(false); } return(true); }
/// <summary> /// Create a Tagged value type /// </summary> /// <param name="rep"></param> /// <param name="property"></param> /// <param name="notes"></param> /// <param name="description"></param> /// <returns></returns> public static bool CreateTaggedValueType(EA.Repository rep, string property, string notes, string description) { try { string del = notes.Contains("'") ? @"""" : "'"; string sql = $@"Insert into t_propertytypes ( Property, Notes, Description ) values ({del}{property}{del}, {del}{notes}{del}, {del}{description}{del});"; rep.Execute(sql); } catch (Exception e) { MessageBox.Show($@"Property: '{property}' {e}", @"Can't create Tagged Value Type"); return(false); } return(true); }
private void updateDiagramMetaType(String oldMetaType, String newMetaType, EA.Repository repository) { SQLRepository sqlRep = new SQLRepository(repository, false); String sqlString = "select Diagram_ID from t_diagram where StyleEx LIKE '*" + oldMetaType + "*'"; String result = repository.SQLQuery(sqlString); foreach (String row in EAUtil.getXMLNodeContentFromSQLQueryString(result, "Row")) { if (row != "") { SQLDiagram diag = new SQLDiagram(sqlRep, row); EA.Diagram rdiag = EAUtil.sqlEAObjectToOriginalObject(sqlRep, diag) as EA.Diagram; String StyleEx = rdiag.StyleEx.Replace(oldMetaType, newMetaType); sqlString = "UPDATE t_diagram SET StyleEx = '" + StyleEx + "' WHERE Diagram_ID = " + rdiag.DiagramID; repository.Execute(sqlString); } } }
public void Execute(string SQL) { eaRepository.Execute(SQL); }
public static void fillTGGSchemaDiagram(EA.Repository repository, EA.Package tggPackage, EA.Diagram tggDiagram) { int i = 2; int j = 1; List <int> validIds = new List <int>(); List <int> addedIds = new List <int>(); foreach (EA.Element element in tggPackage.Elements) { EA.DiagramObject diagramObject = tggDiagram.DiagramObjects.AddNew("", "") as EA.DiagramObject; diagramObject.ElementID = element.ElementID; diagramObject.left = i * 300; diagramObject.right = diagramObject.left + 250; diagramObject.top = j * -200; diagramObject.bottom = diagramObject.top - 100; diagramObject.Update(); validIds.Add(element.ElementID); addedIds.Add(element.ElementID); int z = i - 1; foreach (EA.Connector con in element.Connectors) { EA.Element otherEnd = null; if (con.ClientID == element.ElementID) { otherEnd = repository.GetElementByID(con.SupplierID); } else { otherEnd = repository.GetElementByID(con.ClientID); } if (otherEnd.Stereotype == ECOREModeling.ECOREModelingMain.EClassStereotype) { if (!addedIds.Contains(otherEnd.ElementID)) { diagramObject = tggDiagram.DiagramObjects.AddNew("", "") as EA.DiagramObject; diagramObject.left = z * 300; diagramObject.right = diagramObject.left + 200; diagramObject.top = j * -200; diagramObject.bottom = diagramObject.top - 100; diagramObject.ElementID = otherEnd.ElementID; diagramObject.Update(); addedIds.Add(otherEnd.ElementID); } z = z + 2; } } j++; } tggDiagram.DiagramObjects.Refresh(); tggDiagram.DiagramLinks.Refresh(); repository.ReloadDiagram(tggDiagram.DiagramID); repository.Execute("UPDATE t_diagramlinks SET Hidden = true WHERE DiagramID = " + tggDiagram.DiagramID); foreach (EA.DiagramLink links in tggDiagram.DiagramLinks) { EA.Connector con = repository.GetConnectorByID(links.ConnectorID); if (!validIds.Contains(con.ClientID) && !validIds.Contains(con.SupplierID)) { links.IsHidden = true; links.Update(); } } }
public static void updateStereotype(EA.Repository repository, String newStereo, String oldStereo) { repository.Execute("UPDATE t_object SET Stereotype = '" + newStereo + "' WHERE Stereotype = '" + oldStereo + "'"); }