Book a Demo

Author Topic: automatic attribute stereotype for a given object stereotype  (Read 5177 times)

EvaSchreck

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
automatic attribute stereotype for a given object stereotype
« on: February 21, 2019, 08:12:30 am »
Hi all,

I have made a profile I am using in an MDG, where I have defined a stereotype for an enumeration called "LOVType" and another for the attributes called "LOVValue".

So I can successfully apply the stereotypes and the TaggedValues appear correctly. I have not found out how I can connect the two, so that whenever I create a "LOVType" class, all attributes get automatically the stereotype "LOVValue" applied. At the moment I have to add the stereotype manually.

Can anyone give me a hint on how to get this done? I searched quite a lot, but have not found anything. I will have the same challenge with other class/attributes in the future.

Thanks for your answers in advance.
Eva

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: automatic attribute stereotype for a given object stereotype
« Reply #1 on: February 21, 2019, 08:25:27 am »
Honestly, I don't get what you're doing there or what your issue is. Pictures would probably be helpful. (It might also be that it's just too late right now.)

q.

EvaSchreck

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: automatic attribute stereotype for a given object stereotype
« Reply #2 on: February 21, 2019, 09:26:14 am »
hope this link works:
This is the Profile definition I have:
https://tuteco-my.sharepoint.com/:i:/g/personal/eva_schreck_tuteco_de/EaijUWFC4phOnC9gBWzrAV0BXKjCR4daccO1Ow2Hog0WuQ?e=vJCF6k

And this is how it looks like in action:
https://tuteco-my.sharepoint.com/:i:/g/personal/eva_schreck_tuteco_de/EdLAVCQCS4VMpxx4V85P2TgBW6xQC7gAVTKOENBwEYMAwA?e=x44eJf

if I drag and drop the "LOVValue" it creates an attribute with the correct stereotype. If I manually add an attribute - no stereotype is set. And here I'm looking for a solution, that the stereotype gets set automatically to "LOVValue".

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: automatic attribute stereotype for a given object stereotype
« Reply #3 on: February 21, 2019, 07:13:04 pm »
Hmm. Semantically I still don't get what this should be. However, in your example you added "first value" manually. Obviously this was added as plain attribute and not from the toolbox as <<LOVValue>>. Then you add manually <<enum>> as stereotype which does not have anything to do with your profile.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: automatic attribute stereotype for a given object stereotype
« Reply #4 on: February 21, 2019, 07:25:06 pm »
The «enum» stereotype you get for free if you set the code generation language to "Java" (which is the default).
Change to <none> to avoid this.

Have you tried to set the default attribute type in the profile helper?
It seems like that is exactly what you are looking for, but I haven't tried it myself yet and I can't find any documentation about it in the help.

Geert

EvaSchreck

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: automatic attribute stereotype for a given object stereotype
« Reply #5 on: February 22, 2019, 11:16:01 pm »
fist of all thanks for your answers.

In the example, the first attribute is added plain in the attributes list. It gets the stereotype <<enum>> from the system.

I think this is because I derived the "LOVType" from an enumeration. This was the way of thinking I had, because my "LOVType" is a special kind of enumeration with added metadata on the class and attribute level.

The «enum» stereotype you get for free if you set the code generation language to "Java" (which is the default).
Change to <none> to avoid this.

Have you tried to set the default attribute type in the profile helper?
It seems like that is exactly what you are looking for, but I haven't tried it myself yet and I can't find any documentation about it in the help.
Geert, thank for the hint with the code generation language. This removed the default Stereotype <<enum>> when I add a plain attribute. This allows the assumption that setting the correct stereotype of an attribute has something to do with the programming language.
I have tried the default attribute in the profile helper, bit it only affects the behavior when I drop in the attribute from the toolbox. Whenever I create a plain attribute, the stereotype on the attribute is not set.

I have opened up a support request with Sparks, to get clarification, on how I can achieve to have a stereotype on an attribute automatically set, depending on the stereotype of the class.



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: automatic attribute stereotype for a given object stereotype
« Reply #6 on: February 22, 2019, 11:24:47 pm »
Hi Eva,

If you could keep us posted on the results of that, that would be great.
I'm interested in an exactly the same thing for a client of mine.

Geert

EvaSchreck

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: automatic attribute stereotype for a given object stereotype
« Reply #7 on: March 04, 2019, 08:47:50 pm »
update from the Sparx support on this topic:

Quote
The only way to have EA automatically create all attributes with a stereotype depending on the parent element's stereotype is to write an Add-in. The Add-in would need to respond to the EA_OnPostNewAttribute broadcast event where it should check the stereotype of the parent element and conditionally add a stereotype to the attribute.
https://sparxsystems.com/enterprise_architect_user_guide/14.0/automation/ea_onpostnewattribute.html

If you do not want to have an Add-in running at all times however, you could instead write a script that you would run manually as needed that would search for all attributes owned by an element with the given parent stereotype, and apply the attribute stereotype if it isn't already.

for the moment, I will solve it with a script, but in the mid term I will go for a add-in solution, because there are other things I need an add-in for.

Thanks for your support guys
Eva