I created a message (sequence connector) between two elements:
dim w_src as EA.Element
dim w_dst as EA.Element
set w_src = Repository.GetElementByGuid("{C90B3F33-D01D-48d9-A46A-BD32CA8AF20E}")
set w_dst = Repository.GetElementByGuid("{239814DD-D331-47dc-A198-F2C32E57471C}")
Session.Output "Src: " & w_src.Name
Session.Output "Dest: " & w_dst.Name
dim w_con as EA.Connector
set w_con = w_src.Connectors.AddNew("wocMessage", "Sequence")
w_con.SupplierID = w_dst.ElementID
w_con.Stereotype = "query"
if not w_con.Update then : Session.Output "Error:" & w_con.GetLastError : exit sub : end if
w_src.Connectors.Refresh
How to set programmatically additional properties of the connector (like I did with Stereotype for example)? The properties I want to set are the ones I can see on User interface:
- Return Value
- Control flow type / Synch
- Control flow type / Lifecycle
- Control flow type / isReturn
EDIT: Thanks to the Geert's answer, hereafter the complete code to set programmatically all the parameters provided by the user interface (Tested on EA 10):
dim w_src as EA.Element
dim w_dst as EA.Element
set w_src = Repository.GetElementByGuid("{C90B3F33-D01D-48d9-A46A-BD32CA8AF20E}")
set w_dst = Repository.GetElementByGuid("{239814DD-D331-47dc-A198-F2C32E57471C}")
Session.Output "Src: " & w_src.Name
Session.Output "Dest: " & w_dst.Name
dim w_con as EA.Connector
set w_con = w_src.Connectors.AddNew("wocMessage", "Sequence")
w_con.SupplierID = w_dst.ElementID
w_con.Stereotype = "query"
w_con.StyleEx = "aliasparamsTO=int, string;paramvalues=5, theString;aliasparams=5, theString;alias=theAlias;"
w_con.Subtype = "" ' Lifecycle: "New" | "Delete" | ""
w_con.Notes = "This is a note"
if not w_con.Update then : Session.Output "Error:" & w_con.GetLastError : exit sub : end if
'w_con.MiscData(0) = "Asynchronous"
dim w_params : w_params = "'retval=unsigned int;params=5, theString;paramsDlg=5, theString;retatt=returnedValue;'"
dim w_condition : w_condition = "'theCondition'"
dim w_constraint : w_constraint = "'theConstraint'"
dim w_isIteration : w_isIteration = "'Iteration'" ' 'Iteration' | NULL
dim w_synch : w_synch = "'Synchronous'" ' 'Synchronous' | 'Asynchronous'
dim w_kind : w_kind = "'Call'" ' 'Call' | 'Signal'
dim w_isReturn : w_isReturn = 0 ' 1 | 0
Repository.Execute("update t_connector set PDATA1=" & w_synch _
& ", PDATA2=" & w_params _
& ", PDATA3=" & w_kind _
& ", PDATA4=" & w_isReturn _
& ", SourceCard=" & w_isIteration _
& ", Btm_Mid_Label=" & w_condition _
& ", SourceConstraint=" & w_constraint _
& " where Connector_ID=" & w_con.ConnectorID)
w_src.Connectors.Refresh
Session.Output "[OK]"