Book a Demo

Author Topic: Create stereotyped Methods programmatically  (Read 10658 times)

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Create stereotyped Methods programmatically
« on: August 24, 2013, 09:27:46 pm »
Hello everyone,

I've developed my own UML Profile with several stereotypes.
One of them is a stereotype of a method with some tagged values.
My problem is that when I create a method programmatically with that stereotype the tagged values simply don't show up.
The code I've been using:
Code: [Select]
Method m = element.Methods.AddNew(name, "");
m.Stereotype = "XisAction";
m.Update();

After the Update the tagged values should have been created, like for other stereotypes (for Classes and Attributes) I have.
In my profile this stereotype extends the metaclass Operation, I think is the proper one.

Thanks in advance!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #1 on: August 24, 2013, 10:58:42 pm »
Have you tried "<myProfile>::XisAction" instead?

q.

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #2 on: August 24, 2013, 11:23:11 pm »
Yes, I have tried that with no success.

rothnic

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #3 on: August 25, 2013, 09:31:44 am »
Quote
Yes, I have tried that with no success.

Did you try actually creating an MDG technology for that UML Profile, then installing it? Or did you just create the relationship in a diagram? I think other tools don't require you to actually install it like EA.

I checked and since I deal with SysML a good bit I expect to see SysML1.3::<stereotype> available as a metatype of an element. This isn't available for a method. I applied a sysml stereotype and the stereotype simply has the stereotype without the appended profile.

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #4 on: August 30, 2013, 01:15:10 am »
@rothnic,

I tried with my own MDG Technology and by only loading the profile as resource in the EA.
I've also created custom toolboxes in the MDG Technology and on dragging the XisAction operation element it loads its tagged values, but when I create it programmatically they do not show up.

Thanks.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #5 on: August 30, 2013, 07:52:22 pm »
That's probably because EA is doing some t_xref-foo when creating the operation. I remember that was a general issue in the past. So probably Sparx has not implemented it correctly for automation in this case. You should both send a bug report.

q.

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #6 on: September 03, 2013, 12:01:20 am »
@qwerty,

Can you figure out any workaround to overcome this issue?
Something like executing a query or so?

Thanks in advance!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #7 on: September 03, 2013, 02:08:13 am »
I just tried that with a WSDLportType operation (from the WSDL toolbox). What they create in t_xref is following entry:
XrefID: any GUID
Name: Stereotypes
Type: element property
Visibility: Public
Partition: 0
Description: @STEREO;Name=WSDLportType;@ENDSTEREO;
Client: guid of the operation

You need to supply your stereotype instead of WSDLportType. After adding this record to t_xref you should be fine. I did a similar thing some time ago.

Let us know if it worked (or not...).

q.

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #8 on: September 13, 2013, 03:46:19 am »
I've tried the following code with no success:

Code: [Select]
Method m = element.Methods.AddNew(name, "");
m.Stereotype = "XisAction";
m.Update();
repository.Execute("insert into t_xref (XrefID, Name, Type, Visibility, Partition, Description, Client, Supplier) values " +
    "('{" + Guid.NewGuid() + "}', 'Stereotypes', 'operation property', 'Public', 0, '@STEREO;Name=XisAction;FQName=XIS-Mobile::XisAction;@ENDSTEREO;', '" + action.MethodGUID + "', '&lt;none&gt;');");

I've also queried the table t_operationtag and it's empty...
Any idea what could be wrong?

Thanks in advance!
« Last Edit: September 13, 2013, 03:47:22 am by krypton »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #9 on: September 13, 2013, 05:58:25 am »
Probably unlike for elements the operations will not be synched. So the only way is to a) send a bug report and b) add the expected tags programmatically. I'll see whether I can look into that in more detail over the weekend.

q.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #10 on: September 13, 2013, 06:33:46 pm »
Not sure if it will help - but i had a similar issue. You need v10.08 or above (issue v10.07/06 i think), you may also need to perform a refresh on the element, before you will see the tagged values.

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #11 on: September 17, 2013, 12:40:23 am »
Hello,

In fact I'm using EA v10.0.1005 (Build 1005) that has this bug.
I'm using this version, because I'm using EA in my master thesis and I only have academic licenses for this version and EA v7.5 (Build 844).
Is possible to get a patch or so to overcome this issue?
Otherwise, I must add the tagged values programmaticaly like qwerty said.

Many thanks!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #12 on: September 17, 2013, 05:27:45 am »
You only get an upgrade if you have an account for downloads. Without you might ask Sparx sales support and hope for them having a nice day :-)

q.

André Ribeiro

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #13 on: November 06, 2013, 05:11:06 am »
Hi everyone,

I've added the tagged values manually to my stereotyped method.
Now, one of those tagged values is from a custom enum type. My doubt is how can I programmatically define the allowed values (enum literals) for the tagged value (in order to the select box appear)?

Many thanks!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Create stereotyped Methods programmatically
« Reply #14 on: November 06, 2013, 05:48:51 am »
If they come from your MDG you have bad luck. You only can change it by modifying the MDG and re-loading it. Privately defined ones can be changed with the default tagged values window.

q.