Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: dambsst_gmail on March 30, 2017, 07:25:56 pm
-
Hello,
I am trying to automatically generate an "interaction with sequence diagram" for an operation by using and ADD_IN.
Everything is fine but in the "behavior tab" of the interaction the "specification" field is always empty, I can't figure out how to link it to the operation.
For the operation it's fine, the behavior tab displays the correct element.
Here is my code:
EA.Method theMethod = Repository.GetTreeSelectedObject() as EA.Method;
if (theMethod != null)
{
EA.Element oClass = Repository.GetElementByID(theMethod.ParentID);// class
//EA.Package oClass = Repository.GetPackageByID(oClasss.PackageID);// class
if (oClass != null)
{
EA.Element elt;
try
{
elt = oClass.Elements.GetByName(theMethod.Name);
}
catch
{
elt = oClass.Elements.AddNew(theMethod.Name, "Interaction");
if (elt.Update() == false)
{
Debug.WriteLine(elt.GetLastError());
}
oClass.Elements.Refresh();
}
EA.Diagram diagram = elt.Diagrams.GetByName(theMethod.Name);
if(diagram == null)
{
diagram = elt.Diagrams.AddNew(theMethod.Name, "Sequence");
if (diagram.Update() == false)
{
Debug.WriteLine(diagram.GetLastError());
}
elt.Diagrams.Refresh();
}
theMethod.Behavior = elt.ElementGUID;
if (theMethod.Update() == false)
{
Debug.WriteLine(theMethod.GetLastError());
}
if (oClass.Update() == false)
{
Debug.WriteLine(oClass.GetLastError());
}
}
}
Also, I would like to generate the parameters automatically, but here too I can't find anywhere (taggedvalues, methods, methodsex, etc.....) where to put a reference or create these parameters!
Maybe someone knows how to handle this....
Thanks you,
-
There's normally only a link from the operation to the interaction, not the other way around.
So it would be normal for the behavior tab of the interaction to be empty.
Geert
-
Thanks for your reply!
But if I used the behavior tab of the operation to assign a behavior to it, the behavior tab of the interaction is not empty it is also automatically filled with the reference of the operation. So there must be a kind of backward link which is created or sth like that, because TaggedValues and Methods/MethodsEx properties are always empty.
Later I will try to do a "database compare" before and after creating a link between operation and interaction using the UI, so I guess I will see which column/tables are affected. I will do the same for the interaction parameters because I can't find where they are stored.
Thanks again,
Damien
-
Thanks for your reply!
But if I used the behavior tab of the operation to assign a behavior to it, the behavior tab of the interaction is not empty it is also automatically filled with the reference of the operation. So there must be a kind of backward link which is created or sth like that, because TaggedValues and Methods/MethodsEx properties are always empty.
Later I will try to do a "database compare" before and after creating a link between operation and interaction using the UI, so I guess I will see which column/tables are affected. I will do the same for the interaction parameters because I can't find where they are stored.
Thanks again,
Damien
Is it? I hadn't noticed that before.
I'll do some testing when I get around to it....
Geert
-
Is it? I hadn't noticed that before.
I'll do some testing when I get around to it....
There is a row in the t_xref table which holds the link :)
This C# function perform the database update:
private bool op_gen_add_t_xref(EA.Repository Rep, string operation_guid, string interaction_guid)
{
string xrefmysqlquery =
"INSERT INTO t_xref (XrefID, Name, Type, Visibility, Behavior, Description,Client) "
+ "VALUES('@XrefID', '@Name', '@Type', '@Visibility', '@Behavior', '@Description', '@Client')";
string xrefmysqlcmd = xrefmysqlquery;
xrefmysqlcmd = xrefmysqlcmd.Replace("@XrefID", "{" + Guid.NewGuid().ToString() + "}");
xrefmysqlcmd = xrefmysqlcmd.Replace("@Name", "MOFProps");
xrefmysqlcmd = xrefmysqlcmd.Replace("@Type", "element property");
xrefmysqlcmd = xrefmysqlcmd.Replace("@Visibility", "Public");
xrefmysqlcmd = xrefmysqlcmd.Replace("@Behavior", "specification");
xrefmysqlcmd = xrefmysqlcmd.Replace("@Description", operation_guid);
xrefmysqlcmd = xrefmysqlcmd.Replace("@Client", interaction_guid);
Debug.WriteLine(xrefmysqlcmd);
try
{
Rep.Execute(xrefmysqlcmd);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
return false;
}
return true;
}
Thanks for your help,
Damien
-
Nice, thanks Damien :)
Geert