Author Topic: Scripting : Call Behaviour Action  (Read 2178 times)

Filip Briké

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Scripting : Call Behaviour Action
« on: January 26, 2017, 12:38:58 am »
I want to script an action on an activity diagram that has call behaviour linked to an activity.

set newelement = package.Elements.AddNew("","Action")
newelement.ClassifierID = originalAction.ClassfierID   
newelement.Update()
dim newactionondiagram as EA.DiagramObject
set newactionondiagram = currentdiagram.DiagramObjects.AddNew("","")
'l=200;r=300;t=100;b=20;
newactionondiagram.ElementID = newelement.ElementID
newactionondiagram.Update

However this does not make it a CallBehaviour (properties/general/advanced => kind : CallBehaviour) even when teh ClassifierID is set.

Which properties should i put?

Dahsra

  • EA User
  • **
  • Posts: 226
  • Karma: +17/-1
    • View Profile
Re: Scripting : Call Behaviour Action
« Reply #1 on: January 26, 2017, 01:02:46 am »
Hi
You mean , you're asking how to create a callBehaviour activity..?

If so you need to set there tagged values.

Code: [Select]
EA.TaggedValue activityType = activityElement.TaggedValuesEx.GetByName("activityType");
                    activityType.Value = "Sub-Process";
                    activityType.Update();

                    EA.TaggedValue calledActivityRef = activityElement.TaggedValuesEx.GetByName("calledActivityRef");
                    calledActivityRef.Value = addedElement.ElementGUID;
                    calledActivityRef.Update();

                    EA.TaggedValue isACalledActivity = activityElement.TaggedValuesEx.GetByName("isACalledActivity");
                    isACalledActivity.Value = "true";
                    isACalledActivity.Update();

and for diagram navigation you need to use SetComposite  proprty from element class like below

Code: [Select]
activityElement.SetCompositeDiagram(diag.DiagramGUID);

Setting all the above mentiond property will make a element as a callProcessref and composite diagram for it.
« Last Edit: January 26, 2017, 01:09:25 am by Arshad »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11249
  • Karma: +414/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Scripting : Call Behaviour Action
« Reply #2 on: January 26, 2017, 04:22:59 am »
Hi
You mean , you're asking how to create a callBehaviour activity..?

If so you need to set there tagged values.

Code: [Select]
EA.TaggedValue activityType = activityElement.TaggedValuesEx.GetByName("activityType");
                    activityType.Value = "Sub-Process";
                    activityType.Update();

                    EA.TaggedValue calledActivityRef = activityElement.TaggedValuesEx.GetByName("calledActivityRef");
                    calledActivityRef.Value = addedElement.ElementGUID;
                    calledActivityRef.Update();

                    EA.TaggedValue isACalledActivity = activityElement.TaggedValuesEx.GetByName("isACalledActivity");
                    isACalledActivity.Value = "true";
                    isACalledActivity.Update();


What you are describing is valid for BPMN, but not for a UML CallBehaviorAction.
I'm sure you need to set the Classifier to the ID of the Activity you are calling.
The fact that it is a CallBehavior type is stored in t_xref as
Code: [Select]
@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallBehavior@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;Not sure how to set that using the API though. Probably using EA.Element.CustomProperties

Geert