Author Topic: Stereotype and FQStereotype with profiles  (Read 2474 times)

wzr

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Stereotype and FQStereotype with profiles
« on: August 04, 2021, 04:42:16 am »
Hi,

I'm confused about the handling of Profile-Names in Stereotypes in EA 15.1.
We created an MDG Tech for our project with several stereotypes for the metaclass "Requirement".
When I create Elements of this stereotypes via VBS, I'm setting the Stereotype Attribute of the element to '<ProfileName>::<StereotypeName>'.
For most of the stereotypes the result looks like this (what seems to be logical for me):
  • PropertiesView: Stereotype: '<ProfileName>::<StereotypeName>'
  • Seperate Property Window (i.e. from the context menu in the project browser): Type: '<StereotypeName>' (for whatever reason in this window the stereotype is called "type"?)
  • Stereotype column in the t_object table: '<StereotypeName>'
  • Project Browser: '<<<StereotypeName>>><ElementName>'
  • Stereotype Attribute via VBS API: '<StereotypeName>'
  • FQStereotype Attribute via VBS API: '<ProfileName>::<StereotypeName>'

Now, for two stereotypes I can see a result which is different in the following:
  • Seperate Property Window (i.e. from the context menu in the project browser): Type: '<ProfileName>::<StereotypeName>'
  • Stereotype column in the t_object table: '<ProfileName>::<StereotypeName>'
  • Project Browser: '<<<ProfileName>::<StereotypeName>>><ElementName>'

The only way I can change this behavior for this stereotypes is the Seperate Property Window: if I change the "Type" from '<ProfileName>::<StereotypeName>' to '<StereotypeName>', the element permanently behaves like the other stereotypes.

When the PropertiesView is used to reset the Stereotype, the ProjectBrowser changes. But only until I reload the containing package.
The same for a change via VBS. Even if I set the Stereotype Attribute without the ProfileName, it will be added to the Stereotype Column in the t_object table (at least after reloading the Package).

I can't find any difference to the other stereotype definitions. Does anyone has an idea?
I would like to fix this via script, since its quite a big number of Elements and the different ways of showing the Profile-Name or not is confusing.

Thanks!

Best regards

qwerty

  • EA Guru
  • *****
  • Posts: 12318
  • Karma: +347/-286
  • I'm no guru at all
    • View Profile
Re: Stereotype and FQStereotype with profiles
« Reply #1 on: August 04, 2021, 05:56:36 am »
I don't know what you are doing via VB, but
Quote
Stereotype column in the t_object table: '<ProfileName>::<StereotypeName>'
is just wrong. The stereotype in t_object has only the base name. The FQN is stored in t_xref.

q.

wzr

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Stereotype and FQStereotype with profiles
« Reply #2 on: August 04, 2021, 04:49:06 pm »
I'm just creating an 'Requirement' Element and set the Stereotype:

Code: [Select]
currentElement.Stereotype = "MyProfile::MyStereotype"
currentElement.Update()

This works with most of the stereotypes and, as you said, the t_object has only the base name. But for two stereotypes the FQN is written in t_object.
Even when im trying to update the Stereotype of this elements it will be resetted to the FQN

Code: [Select]
currentElement.Stereotype = "MyStereotype"
currentElement.Update()

No matter what is written in t_object, the api always returns the base name for stereotype (before and after the change):
Code: [Select]
Session.Output("1: " + currentElement.Stereotype)>> MyStereotype

t_xref looks exactly the same for elements with FQN in t_abject as for the others:
"@STEREO;Name=MyStereotype;FQName=MyProfile::MyStereotype;@ENDSTEREO;"

wzr

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Stereotype and FQStereotype with profiles
« Reply #3 on: August 04, 2021, 04:58:30 pm »
I tried something else now. I changed the Stereotype of an existing "MyStereotype-Element" to a "normal/working" one first and then change it again to the actual one:

Code: [Select]
currentElement.Stereotype = "MyGoodStereotype"
currentElement.Update()
currentElement.Stereotype = "MyStereotype"
currentElement.Update()

The result is a proper base name in t_object. But the PropertiesView is showing both Stereotypes now and t_xref containes both as well  :'(
"@STEREO;Name=MyStereotype;FQName=MyProfile::MyStereotype;@ENDSTEREO;@STEREO;Name=MyGoodStereotype;FQName=MyProfile::MyGoodStereotype;@ENDSTEREO;"

qwerty

  • EA Guru
  • *****
  • Posts: 12318
  • Karma: +347/-286
  • I'm no guru at all
    • View Profile
Re: Stereotype and FQStereotype with profiles
« Reply #4 on: August 04, 2021, 07:10:29 pm »
I guess (from a quick look) that you should rather use StereotypeEx (well, this is EA). Give that a try (on a clean model) and see what the outcome is.

q.

wzr

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Stereotype and FQStereotype with profiles
« Reply #5 on: August 04, 2021, 08:52:48 pm »
Ok, that one works in my "non-clean model":
I change StereotypeEx to another arbitrary single stereotype and update the Element.
After that I directly set StereotypeEx back to "MyStereotype" without the ProfileName.

That results in a proper base name in t_object.stereotype and the expected stereotype description in t_xref (including the FQName with ProfileName).

I still don't understand what triggers EA in some cases to add the FQName in t_object.stereotype. And why or when
Code: [Select]
currentElement.Stereotype = "MyStereotype"adds an additional Stereotype to the Element instead of overwriting the existing.
There seems to be a mysterious method behind this call which handles the base name, the FQName and the table entries.

Thanks for your help!

qwerty

  • EA Guru
  • *****
  • Posts: 12318
  • Karma: +347/-286
  • I'm no guru at all
    • View Profile
Re: Stereotype and FQStereotype with profiles
« Reply #6 on: August 04, 2021, 09:24:24 pm »
Yes, a mystery that is. And that's how quite some parts of EA work. EA guesses the profile from what it finds first. Else it creates a wild stereotype without profile. Best is to safely only use unique stereotype names that differ from any other in standard and (Sparx) extended profiles. And also using StereotypeEx with FQN should (not 100% sure, though) do what one expects.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7563
  • Karma: +94/-17
    • View Profile
Re: Stereotype and FQStereotype with profiles
« Reply #7 on: August 05, 2021, 01:45:34 pm »
Code: [Select]
currentElement.Stereotype = "MyProfile::MyStereotype"

On older versions of EA this would cause a problem when "MyProfile::MyStereotype" doesn't exist. It will define that as a new stereotype name. From memory the current version will no longer define a stereotype with '::' in the name. It also meant that once that had been defined in the model it would choose that in preference to the actual profile stereotype. To fix that you need to remove all matching stereotypes, delete the definition from the global list and then you can add the stereotypes back. The stereotype property does not support qualified names, largely to handle legacy situations.

Code: [Select]
currentElement.Stereotype = "MyStereotype"
In effect, this code is telling EA to guess which stereotype with that name you want to apply.
Eve

support@sparxsystems.com