Author Topic: Call behavior Activity (CBA) element  (Read 686 times)

tzafrir

  • EA User
  • **
  • Posts: 121
  • Karma: +0/-0
    • View Profile
Call behavior Activity (CBA) element
« on: December 08, 2018, 08:08:35 am »
Hi,

I am trying to create a call behavior element, connect it to a certain diagram and place on another diagram for it to be used.

I tried creating it with EA.element but it did not give me the element I needed.
Assuming I have the diagram that it needs to connect to and the package that it should sit in,
can someone please advise how to create (AddNew) such element?

Already tried:
EA.element  newAction = toBePlacedPkg.Elements.AddNew("new name", "Action");

Thanks,
Tzafrir

qwerty

  • EA Guru
  • *****
  • Posts: 10146
  • Karma: +207/-170
  • I'm no guru at all
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #1 on: December 08, 2018, 09:22:38 am »
You need to create an entry in t_xref (I posted it earlier here; but of course finding something here except spam is difficult). An entry in t_ref is needed.

Code: [Select]
XrefID;Name;Type;Visibility;Namespace;Requirement;Constraint;Behavior;Partition;Description;Client;Supplier;Link;

{C5FA3A83-3432-4f14-AB5D-3D098AAF6E04};CustomProperties;element property;Public; ; ; ; ;0;@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallBehavior@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;;{EC627A0C-E58A-41fb-91E8-73E10B4927A4};<none>; ;

q.

tzafrir

  • EA User
  • **
  • Posts: 121
  • Karma: +0/-0
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #2 on: December 09, 2018, 08:06:07 am »
Hi,

I didnt understand you answer.
Let me ask the question again.
I have created a new element, and I have the diagramId of the diagram the call behavior should connect to.
How do I make that connection?
Meaning, where do I put is the connection in t_xref data between the new cba element I have created and the diagramid?

qwerty

  • EA Guru
  • *****
  • Posts: 10146
  • Karma: +207/-170
  • I'm no guru at all
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #3 on: December 09, 2018, 09:41:17 am »
Yes, you need to create such an entry in t_xref to make it a CallBehavior. Try with an empty EAP and run the SQL against t_xref to find out which eaguids are referenced in the t_xref. It's quite obvious. There is no way around going to EAs tables since the API does not help you here.

q.

tzafrir

  • EA User
  • **
  • Posts: 121
  • Karma: +0/-0
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #4 on: December 10, 2018, 08:57:15 am »
thanks,
I almost got my result but something is still missing.
After I create the element and change the kind manually to call behavior I see indeed that an entry is being created in t_xref table.

Something like this:
XrefID,Name,Type,Visibility,Namespace,Requirement,Constraint,Behavior,Partition,Description,Client,Supplier,Link,
{641BA055-0D1A-49d3-A91B-DEA4DDAD0857},CustomProperties,element property,Public, , , , ,0,@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallBehavior@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;,{80E581C2-0571-4ccf-8E21-046626CCD5DF},<none>, ,

But when I execute the same insert threw the addin (looking exactly the same as when I moved the kind to "call behavior")
I still don't get the element to change to "call behvior" - still need to move it manully even though t_xref got the entry from the addin.

Do you know what other table is getting updated when I move the kind to "call behavior" besides t_xref?

Thanks,
Tzafrir

qwerty

  • EA Guru
  • *****
  • Posts: 10146
  • Karma: +207/-170
  • I'm no guru at all
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #5 on: December 10, 2018, 05:42:32 pm »
None. You can not create "exactly the same" entry. At least the guid for the t_xref entry must be different. Moreover, if you don't tell what error you encountered there's just space for guessing.

q.

tzafrir

  • EA User
  • **
  • Posts: 121
  • Karma: +0/-0
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #6 on: December 10, 2018, 11:35:11 pm »
thanks for your help,
RefreshModelView solved the issue.

By the way,
in order to create the insert I am generating GUID for XrefID by myself.
Do you know an EA API that does that?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9002
  • Karma: +234/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Call behavior Activity (CBA) element
« Reply #7 on: December 10, 2018, 11:39:11 pm »
in order to create the insert I am generating GUID for XrefID by myself.
Do you know an EA API that does that?
A GUID is a GUID, it doesn't matter how you generate it.
Just make sure it's in the expected format.

Geert

tzafrir

  • EA User
  • **
  • Posts: 121
  • Karma: +0/-0
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #8 on: December 19, 2018, 03:25:52 am »
Hi,
Seems like I still have an issue with the refreshing of the model.

After adding the insert to t_xref as mentioned above a refresh to the DB must take place in order for the element be affected by the insert and become call behavior.

I have tried to do it in several way none of them worked and EA crushes after completing the Addin code.
1.  repository.RefreshModelView(0);
2.  repository.RefreshModelView(element.PackageID);

I have seen that closing the diagram and open it manually (not threw the add in) refreshes it correctly (but that's not good as well everything needs to be done in the addin). Doing it like this, it crushes:
3.  repository.CloseDiagram(diagramId)
     repository.OpenDiagram(diagramId)
   

After saying all that can someone advise another way to refresh that insert so that the element will pick the new insert and become Call Behavior?

Thanks

qwerty

  • EA Guru
  • *****
  • Posts: 10146
  • Karma: +207/-170
  • I'm no guru at all
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #9 on: December 19, 2018, 03:45:56 am »
I might have a look the next days.

q.

tzafrir

  • EA User
  • **
  • Posts: 121
  • Karma: +0/-0
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #10 on: December 19, 2018, 06:17:17 pm »
Hi,
I found that the issue might be due to my GUID generation method.
I am creating it as basic:
{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX}
tried X as Hexa\ random number between 0-9 and got some guid that at the end after refreshing I guess EA does some validation rules on it and crashes.

When I took EA guid and changed one of its numbers it and generated the insert with it, the close\open sometimes works and sometimes does not (so i guess it relates to the number I change) of the diagram is working and does not crush.

My question is, can you send me a sample code that generate guid correctly according to EA validations?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9002
  • Karma: +234/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Call behavior Activity (CBA) element
« Reply #11 on: December 19, 2018, 06:41:37 pm »
you really shouldn't try to generate a GUID yourself.
There are build in library functions in almost any language I know to do this properly.

Just google for "generate GUID <YourProgrammingLanguage>" and you'll find plenty of examples.

Geert

tzafrir

  • EA User
  • **
  • Posts: 121
  • Karma: +0/-0
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #12 on: December 25, 2018, 07:15:56 am »
Hi,
I am still having issues with creating this CBA.

Seems like when I remove the command:
repository.Execute(sql);
(when sql holds the insert to t_xref table, EA crushes after it exists the Addin with no explanation why it throws exception.

Can someone send me a short sample of creating CBA so I can compare it with my code.

Thanks.

qwerty

  • EA Guru
  • *****
  • Posts: 10146
  • Karma: +207/-170
  • I'm no guru at all
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #13 on: December 25, 2018, 08:51:56 am »
Hmm. Indeed this seems to be tricky. I tried a couple of tricks (so it at least resembles a CBA) but when I just open the properties the right one has a "Call" property while the automated one doesn't. That might give me some more headaches...

q.

qwerty

  • EA Guru
  • *****
  • Posts: 10146
  • Karma: +207/-170
  • I'm no guru at all
    • View Profile
Re: Call behavior Activity (CBA) element
« Reply #14 on: December 25, 2018, 09:06:13 am »
Got it. It was just a "late evening issue". If you don't mind the Python:

Code: [Select]
rep = repository.Repository.Instance()
root = rep.models.getat(0)
view = root.packages.getAt(0)
act = rep.getElementByGuid("{20BAF6F4-FF48-4848-8939-BA867420CE8B}")
cba = view.elements.addNew("", "Object") # to set the classifier it must be an object!
cba.classifierID = act.elementID
cba.update
sql = "UPDATE t_object SET Object_Type = \"Action\" WHERE Object_ID = %d" % cba.elementID # or you create an Action and change the classifier here :-/
rep.execute(sql)
sql = "INSERT INTO t_xref (XrefID,[Name],[Type],Visibility,Partition,Description,Client,Supplier) VALUES ('{%s}','CustomProperties','element property','Public','0','@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=CallBehavior@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;','%s',NULL)" % (str(uuid.uuid4()).upper(), cba.elementGUID)
rep.execute(sql)
rep.RefreshModelView (view.packageID) # the above AddNew leaves the Action to be an Object in EA's view

Not sure if this could be optimized, but that one worked.

q.