Author Topic: Upgrade Stereotype to its UML profile counterpart  (Read 3147 times)

Luc De Graef

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Upgrade Stereotype to its UML profile counterpart
« on: February 28, 2013, 03:04:41 am »
Our domain model contains attributes with a Key stereotype.
For our outsourcer we created a UML profile.  Within this profile a stereotype Key (extending Metaclass Attribute).
When we apply that second stereotype, the outsourcer can see it.

- How can we programmatically update the original Key stereotypes to the UML Key stereotypes?
- How can we check whether an XMI or a UML Key stereotype was applied ? (eg. with SQL the t_attribute table contains stereotype as a String column, and one cannot distinguish).

Thx
Luc

qwerty

  • EA Guru
  • *****
  • Posts: 12841
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Upgrade Stereotype to its UML profile counterp
« Reply #1 on: February 28, 2013, 03:44:31 am »
You need to stick to the following for a synch:
EaPackage:
bool SynchProfile(stringProfile,stringStereotype) — Synchronizes Tagged Values and constraints of the UML Profile for Stereotype.
Returns True if the synch was successful. Otherwise returns False.

Checking for synched tags is not easy. First you need to know that profile-related tags have a unique prefix in their GUID. Unfortunately it is Sparx' secret how this is generated. You can find it out by inspecting an already existing GUIDs.

From my Inside EA book:
Quote
As mentioned above there’s some magic with GUIDs for tagged values that come from a MDG profile. These look exactly like ‘normal’ GUIDS:

{aaaaaaaa-aaaa-aaaa-bbbb-bbbbbbbbbbbb}

Here the a and b hex codes are not completely random. Only the b part is completely random, but the a part is a hash code computed individually per profile. The hash algorithm is internal to EA and unfortunately not known.

Sadly you can not find out easily that a synch has been performed. Just run the above method to be sure.

q.

Luc De Graef

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Upgrade Stereotype to its UML profile counterp
« Reply #2 on: February 28, 2013, 11:58:16 pm »
OK....
But I want to apply a stereotype, and do not know how to check the GUID from the stereotype.

The following query shows the atributes, for classes with a non-null stereotype:

Code: [Select]
select * from dbo.t_attribute where Object_ID in (
   select object_id from dbo.t_object
   where Object_Type = 'Class' and       Package_ID =9999
   ) and
  Stereotype is not null;

Also the API provides only the stereotype as a string and not as a guid.

Regards
Luc

qwerty

  • EA Guru
  • *****
  • Posts: 12841
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Upgrade Stereotype to its UML profile counterp
« Reply #3 on: March 01, 2013, 12:45:50 am »
I'm not sure what you actually want to do. The tag guid is found with
Code: [Select]
Tag.PropertyGUID
q.

[edit] Maybe I got it. What you need is some extra information in t_xref where EA stores the relation to the according MDG. Not an easy one to make that work. Good luck...

[edit2] In order to investigate this, make an empty model and create one element from the MDG. Then have a look into t_xref and you will see what needs to be done. Creating an entry in t_xref is simple. Just create an arbitrary GUID for the primary key. Note that dealing with t_xref may corrupt your model unless you know what you're doing.
« Last Edit: March 01, 2013, 01:00:22 am by qwerty »

David Rains (bioform)

  • EA User
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Upgrade Stereotype to its UML profile counterp
« Reply #4 on: March 28, 2013, 04:29:45 am »
Hi all,

Just sitting here working on a similar problem at a Starbucks in MD.

I have stereotyped an attribute with tagged values. If I drag and drop into element the synch works fine, but

If I add the stereotyped attribute to the element's attribute collection:
....
set a = aC.AddNew("newAttrb", "")
a.Stereotype = "mySteretypedAttribute"
a.Update
aC.Refresh
Repository.SynchProfile "MyProfile", "mySteretypedAttribute"
....

I get nothing... Even if I manually try to synch nothing...
So I take it that I am missing the additional data that EA puts into the xref table when the operation is carried out by drag/drop, or copying the attribute from within the element (using EA UI).

Any idea how I can get this to work through code?

Basically I would be using code to select the "type" of stereotyped attribute to add to the element when it is missing from the element...

Thanks,

David "bioform" Rains

qwerty

  • EA Guru
  • *****
  • Posts: 12841
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Upgrade Stereotype to its UML profile counterp
« Reply #5 on: March 28, 2013, 09:38:37 am »
The problem is that once you add a tag manually the synch ignores it (Oh, it's already there). So if you need the right tag you must delete the wrong ones prior to the sync. I can't remember having heard of a force option with synch. With your code you should do the synch first and then retrieve the automatically created tag.

q.

David Rains (bioform)

  • EA User
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Upgrade Stereotype to its UML profile counterp
« Reply #6 on: March 28, 2013, 02:34:21 pm »
I am not adding a tag, but an stereotyped attribute (that has tags) to an element.

Scenario 1: If I drag and drop it works fine... e.g., delete tags from the ST'd attribute in the element, then resynch attribute - works as expected the delete tags are replaced...

Scenario 2: If I add an attribute to an element, assign the stereotype, save element, then synch attribute - works as expected the missing tags are added...

If I perform Scenario 2 using the previous code fragment, it does not work, or if I try to manually synch the st. attribute that was successfully added - the synch does not work...

Is that any clearer?

Thanks,
David "Least I have a kitchen synch?" Rains


qwerty

  • EA Guru
  • *****
  • Posts: 12841
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Upgrade Stereotype to its UML profile counterp
« Reply #7 on: March 29, 2013, 06:12:41 am »
I just verified that this isn't working here too. I'll dig a bit, but it looks like you should send a bug report to Sparx.

q.

[edit] It appears that setting the stereotype from the GUI creates an entry in t_xref which matches the profile settings. You obviously need to do that from your script too (below with ARCGIS Field Attribute):

XrefID -> arbitrary GUID
Name -> 'Stereotypes'
Type -> 'attribute property'
Description -> '@STEREO;Name=Field;FQName=ArcGIS::Field;@ENDSTEREO;'
Client -> ea_guid of the attribute

drain the rest in EA's kitchen synch...
« Last Edit: March 29, 2013, 06:23:00 am by qwerty »