Author Topic: How EA identifies stereotypes  (Read 2768 times)

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
How EA identifies stereotypes
« on: July 03, 2012, 07:06:12 am »
I've developed an MDG technology. When I use use it to create an element in a diagram, it works as I expect. When I use the automation interface to create an element, it doesn't.  The symptoms appear in the tagged values pane:
  • For the "good" element, the label at the pane's top displays a fully qualified path name from my MDG technology (i.e.,  it has the form "ProfilePkg::stereotypeName"). For the bad element, it just displays the element's UML type (e.g., "Package").
  • For the good element, the tagged values pane displays the tags I expect. For the bad element, it doesn't list any tags.
Can someone please explain this behavior to me, and tell me how to get the automation interface working?

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2768
  • Karma: +47/-3
    • View Profile
Re: How EA identifies stereotypes
« Reply #1 on: July 03, 2012, 09:29:14 am »
The step that you are missing is that once you have created a stereotyped element (or applied a stereotype to an already created element) you need to call EA.Element.SynchTaggedValues(Profile, Stereotype)
The Sparx Team
support@sparxsystems.com

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
Re: How EA identifies stereotypes
« Reply #2 on: July 03, 2012, 11:47:01 pm »
KP,

I'm using the Java API, so SynchTaggedValues() isn't available.

I don't know if it's relevant, but I've tried opening Enterprise Architect and synching the stereotype from the toolbox (i.e., right-click a toolbox item and select "Synchronize Stereotype"). The action has no effect. I have also tried:

Code: [Select]
repository.CustomCommand("Repository", "SynchProfile", "Profile=profile-name;Stereotype=stereotype-name;");
without success.

Perhaps another way to ask my question is as follows. I can transfer my project to a MySQL database, dump the database, then restore the database; Enterprise Architect still knows which is the good element and which is the bad one. What information is it using to do so? I have looked at the MySQL dump and can't figure out how EA knows which element is created from my MDG technology, despite both having a stereotype with the same name (and same value for the Description field in the t_xref table).

rayt

  • EA User
  • **
  • Posts: 28
  • Karma: +1/-0
    • View Profile
Re: How EA identifies stereotypes
« Reply #3 on: July 05, 2012, 06:30:57 pm »
The stereotype doesn't need to be identified, but the tagged values do. They each have a PropertyGUID which references their counterpart in the profile (Actually, the first 8 bytes of the PropertyGUID are that reference, the other 8 bytes are a random GUID)

Unfortunately, this reference can't be reconstructed because it's generated internally as a hash from the tagged value's fullly qualified name (at least that's my best guess).

The only way I see what could work is to pregenerate a table of these 8 byte refs from all existing tagged values, store it somewhere and look it up when rebuilding new tagged values.

I hope Sparx does something about this in the future (Add SynchTaggedValues to the Java API, and also make SynchTaggedValues available for all items that can hold stereotypes, for example attributes)
Ray
« Last Edit: July 05, 2012, 06:42:33 pm by rayt »

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
Re: How EA identifies stereotypes
« Reply #4 on: July 06, 2012, 05:53:44 am »
Rayt,

Thanks -- your solution is workable for the time being. Let us hope Sparx Systems improves API support for stereotypes soon.

qwerty

  • EA Guru
  • *****
  • Posts: 11472
  • Karma: +305/-263
  • I'm no guru at all
    • View Profile
Re: How EA identifies stereotypes
« Reply #5 on: July 06, 2012, 09:24:50 pm »
Quote
I've developed an MDG technology. When I use use it to create an element in a diagram, it works as I expect. When I use the automation interface to create an element, it doesn't.  The symptoms appear in the tagged values pane:
  • For the "good" element, the label at the pane's top displays a fully qualified path name from my MDG technology (i.e.,  it has the form "ProfilePkg::stereotypeName"). For the bad element, it just displays the element's UML type (e.g., "Package").
  • For the good element, the tagged values pane displays the tags I expect. For the bad element, it doesn't list any tags.
Can someone please explain this behavior to me, and tell me how to get the automation interface working?

You can create elements from your MDG via
Code: [Select]
Elements.AddNew ("name", "<profile>::<meta>")where <profile> is the id of the profile (see second line in the MDG) and  <meta> is the meta type of the according element. The meta type must be unique. I.e. you can not create a profile element which is extends multiple meta classes (e.g. <<extends>> Class and <<extends>> Package).

q.

Steve Wartik

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
  • Why aren't I outside?
    • View Profile
Re: How EA identifies stereotypes
« Reply #6 on: July 07, 2012, 01:24:31 am »
Qwerty,

Thanks -- that bit of magic helps too.