Enterprise Architect脚本:为序列图设置Connector的属性

时间:2015-03-11 12:08:04

标签: enterprise-architect

我在两个元素之间创建了一条消息(序列连接符):

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

如何以编程方式设置连接器的其他属性(例如我使用Stereotype)?我想要设置的属性是我在用户界面上可以看到的属性:

  • 返回值
  • 控制流程类型/同步
  • 控制流程类型/生命周期
  • 控制流类型/ isReturn

修改 感谢Geert的回答,以下是以编程方式设置用户界面提供的所有参数的完整代码(在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]"

1 个答案:

答案 0 :(得分:0)

您必须检查t_connector的列。 我知道生命周期被放入Subtype,但其他参数可能存储在其他地方。

特别注意PDATA *和Style *列。它们通常包含这类信息。