Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Tomasz on December 16, 2014, 03:44:59 am
-
Hi,
I have created 2 connectors in C#;
First:
EA.Connector connector = previous.m_diagramElement.Connectors.AddNew("", "Association");
Second:
EA.Connector message = previous.m_diagramElement.Connectors.AddNew(functionData.GetMethodName(), "Collaboration");
All refresh and update parts of code have been added
It works fine but I can't connect those two with arrow.
( which you can easly do using options "Add message from .. to .. " from "Association" connector context menu.
I have found in exported xml file that for "Collaboration connector" in extProperties "message_link" variable has been added with 1st connector GUID as value.
<extendedProperties stateflags="IsReturn=false;" virtualInheritance="0" message_link="EAID_AC5CF663_AF22_41ec_80D2_BD526F97913B" diagram="EAID_0B72E9F3_1B43_4505_A059_87963183DB4C" privatedata1="Synchronous" privatedata2="retval=bool;params=;paramsDlg=nameSpace, Key, data;" privatedata3="Call" privatedata4="0.4" privatedata5="SX=-98;SY=3;EX=-68;EY=3;"/>
I have no access to extProperties.
Question is how to simulate that connection in C# (not by hand) ?
Please help me :) Thanks in advance.
-
... I can't connect those two with arrow.....
Which two? The two connectors? :-?
q.
-
I have been trying to simulate in C# the same "behaviour" which I have achieved adding element by hand.
1) I have 2 diagram object - Actor and WriteInt Object
EA.Element element = m_interaction.Elements.AddNew("", "Object");
EA.DiagramObject diagramObj = m_diagram.DiagramObjects.AddNew("","");
2) I have created 2 connectors:
a) Assocation connector between those elements.
b) Second connector ( from exported .xml I know that's connector with Collaboration setting ) can be added using "Add message from .. to .. " from "Association" connector context menu.
If you do that by hand you will see line between Assocation and Collaboration connectors. I want to do that in C#.
-
This is because EA creates an additional entry in t_xref. You can find that out in an empty repository where you create one such double-connector manually. You can then try to mimic that by adding the right entry in t_xref via Repository.Execute.
q.
-
xref content hasn't change in exported xml file.
Only extendedProperties tag values have additional values as "message_link"
-
Not in the exported xml. In the internal t_xref table. Use the SQL tab for a
SELECT * FROM t_xref
q.
-
Thank you for you support.
Unfortunately too many information appears after executing that query.
I can't find something useful there. More logical connection I can find in exported xml file.
And I don't know why I should search in whole repository.
-
As said you need to create an empty EAP first. Then add two plain classes and add exactly that one connector.
This is (almost) the only way to find out such things.
q.
-
I have fixed that.
The solution is to run SQL command:
string sqlQuery =
"UPDATE t_connector SET SourceIsAggregate=" + connector.ConnectorID + " WHERE Connector_Id=" + message.ConnectorID;
m_repository.Execute(sqlQuery);
All thanks to 'qwerty' help. Thank you very much once again.
Maybe someone has idea how to do that without using SQL executions?
-
Check EAConnector.ClientEnd. It delivers a EAConnector object which holds a long Aggregation.
q.
-
Ooops, I tried it before, but it didn't work.
Because I forgot about calling update.
So now it's more simple:
message.ClientEnd.Aggregation = connector.ConnectorID;
message.ClientEnd.Update();
Thank you.
-
There's something wrong with that. Aggregation takes
0 = None, 1 = Shared, 2 = Composite
q.
-
Strange but it works only this way.
If I will add that "message connector" to "asscociate connector" by hand then in database field "SourceIsAggregate" for "message connector" is set to "associate connector" id.
In C# I have achieved the same result like that:
EA.Connector associateConnector = SOME_DIAGRAM_ELEMENT.Connectors.AddNew("", "Association");
EA.Connector messageConnector = SOME_DIAGRAM_ELEMENT.Connectors.AddNew("", "Collaboration");
....
EA.ConnectorTag tag = messageConnector.TaggedValues.AddNew("operation_guid", "String");
tag.Value = method.MethodGUID;
....
messageConnector.TransitionGuard = "retval=" + method.ReturnType + ";params=;paramsDlg=" + ....;
messageConnector.StyleEx = "aliasparamsTO=" + ..... + ";";
messageConnector.TransitionAction = "Call";
messageConnector.TransitionEvent = "Synchronous";
messageConnector.Name = method.Name + .... + ")";
messageConnector.ClientEnd.Aggregation = connector.ConnectorID;
messageConnector.ClientEnd.Update();
-
This is likely coincidence. Better use an enumeration with the named values to show none, shared or aggregate on the connector ends. It appears that all assignments above 2 are shown as aggregate. So if you assign the ConnectorID this is most likely a positive integer above 2.
q.
-
I have checked 0,1,2 and neither of those options works.
Maybe I have discovered some hidden feature :)