Author Topic: Connect Activity and Action via CallBehavior.  (Read 487 times)

Markus Bauernfeind

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Connect Activity and Action via CallBehavior.
« on: October 18, 2017, 07:07:14 pm »
This might be a basic question, but I could not find the answer. I know how to do it in the GUI, but in an Add-In?
I have an Activity Element and an Action Element. How do I connect them via a CallBehavior?

Thank you.

qwerty

  • EA Guru
  • *****
  • Posts: 8969
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #1 on: October 18, 2017, 08:54:48 pm »
Good question. The API does not seem to expose it. I'll have a look.

q.

P.S. t_document.classifier_guid corresponds to the operation's guid.
« Last Edit: October 18, 2017, 08:56:46 pm by qwerty »

Uffe

  • EA Practitioner
  • ***
  • Posts: 1072
  • Karma: +81/-5
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #2 on: October 18, 2017, 09:18:15 pm »
If it's an operation, that would be a CallOperation action, not a CallBehavior one.

Also, t_document? I think you might be responding to a different post there. :)

The referenced behavior in a CallBehavior action is a simple classifier, and is set like any other simple classifier:
Code: [Select]
action.ClassifierID = activity.ElementID
Semantically it doesn't have to be an activity, any behavior element is accepted. In reality, I'm pretty sure EA will accept any classifier.


CallOperation actions, on the other hand, have no classifier ID. They do have a classifier GUID. If you look in the database, these are different columns. For simple instance/classifier relationships (like the one above), the classifier ID and GUID refer to the same classifier element, but for things like CallOperation actions, the ID is 0 while the GUID contains the GUID of the operation.

So the classifier ID must (apparently) always refer to another element, while the classifier GUID can refer to other stuff as well. The API doesn't expose Element.ClassifierGUID, and it's not in Element.CustomProperties either. I think the only way to set this might be Repository.Execute().


/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 8969
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #3 on: October 18, 2017, 09:18:46 pm »
So, there are two things to do. One is to set the classifier as above. This can not be done with the API, but only directly in the database. The second is to add a couple of CustomProperties which, according to the help, are "Currently only editable from the user interface.". Instead you can create an entry in t_xref with

Code: [Select]
Name="CustomProperties"
Type="element property"
Description="@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallOperation@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;"
Supplier=<guid of the action>

Good luck.

q.

P.S. Uffe is right. It's t_object.classifier_guid (I was working on t_document for a request from Geert). And it's a CallOperation I'm talking about (drag operation onto diagram).
« Last Edit: October 18, 2017, 09:22:52 pm by qwerty »

Uffe

  • EA Practitioner
  • ***
  • Posts: 1072
  • Karma: +81/-5
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #4 on: October 18, 2017, 09:25:01 pm »
This looks right to me, but the OP was talking about CallBehavior actions. They don't refer to an operation but to an activity (or other behavior, like an interaction), so setting the classifier ID is all you need to do in that case.

/U
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 8969
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #5 on: October 18, 2017, 09:28:10 pm »
For CallBehavior it's similar. t_object.classifier_guid has the guid of the StateMachine or whatever is in place. t_xref differs in

Code: [Select]
Description="@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallBehavior@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;;"

q.

Markus Bauernfeind

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #6 on: October 18, 2017, 09:33:58 pm »
Sorry, but I do not understand. I am coding it in C#.

I have two Variables

Element action;
Element activity;

What would be the code?


qwerty

  • EA Guru
  • *****
  • Posts: 8969
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #7 on: October 18, 2017, 09:40:18 pm »
On that level? Your magic hand moving the mouse.

q.

Markus Bauernfeind

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #8 on: October 18, 2017, 09:56:18 pm »
I am sorry, but I really do not know, what to do with the code you provided. :(

Uffe

  • EA Practitioner
  • ***
  • Posts: 1072
  • Karma: +81/-5
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #9 on: October 18, 2017, 09:59:28 pm »
If your action is a CallBehavior action, you just need the code I posted up above. It only gets complicated if you're working with CallOperation actions.

Plus you need to call Element.Update() at the end of any set of changes you make, since that's what writes the changes back to the database.

/U
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 8969
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #10 on: October 18, 2017, 10:19:53 pm »
Uffe, that's not correct. The above will create an instance, which is something completely different.

q.

qwerty

  • EA Guru
  • *****
  • Posts: 8969
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #11 on: October 18, 2017, 10:22:06 pm »
I am sorry, but I really do not know, what to do with the code you provided. :(

In other words: you can not do that easily. The API provides nothing to do it. You need to dig into the underlying database and how to deal with it. Only then you can use what I posted above.

q.

PeterHeintz

  • EA User
  • **
  • Posts: 549
  • Karma: +37/-14
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #12 on: October 18, 2017, 10:36:41 pm »
Hello Markus,
To bring you to the right track.
The API seems to have no method, that allows you to make an action a call behavior action or at least to define by API what it calls by that action.

So, if you do not have an API, you have to change your model by changing DB content directly.

By doing so, you will see some ugly things in the EA DB design like the stuff above, what shows that the relevant data for your issue is stored as some kind of structured text in a description field of a db table.
Best regards,

Peter Heintz

Uffe

  • EA Practitioner
  • ***
  • Posts: 1072
  • Karma: +81/-5
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #13 on: October 19, 2017, 01:00:23 am »
Hmm.... I have tested what I posted and it does work. It does not "create" anything. It links an instance-type element (eg an action) to a classifier-type element (eg an activity). That is how EA links CallBehavior actions to activities: the action is an instance of the activity.

I have an Activity Element and an Action Element. How do I connect them via a CallBehavior?

The OP said you had an activity element and an action element, which you wanted to connect. If that is the case, you set the action element's ClassifierID to the activity element's ElementID. That is it. The code I posted will do exactly that, but it doesn't include the Update call you always need to issue.

If the problem is that you don't know how to create a CallBehavior action, then that's not the same thing at all. Then you need to create a CallBehavior action first. But again, once you've done that, setting its classifier ID is all you need to do.


/Uffe
My theories are always correct, just apply them to the right reality.

qwerty

  • EA Guru
  • *****
  • Posts: 8969
  • Karma: +136/-124
  • I'm no guru at all
    • View Profile
Re: Connect Activity and Action via CallBehavior.
« Reply #14 on: October 19, 2017, 01:46:41 am »
Uffe, what you describe is what you get when you press Ctrl-L on the Action and select  a classifier. Do that for an Action of your choice. Now from the menu create a new Action and select CallBehavior. It will ask for certain elements (e.g. a StateMachine) you can assign to the behavior. Now look at both elements and you will see the difference.

q.