Author Topic: 2 stereotypes on attribute  (Read 5884 times)

The apprentice

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
2 stereotypes on attribute
« on: February 28, 2019, 02:22:27 am »
Hi,

I use an Addins in C# and I would like add 2 stereotypes on attribute like this :



Code: [Select]
attribute.Stereotype = "New";
//attribute.Stereotype = "enum"; will erase the old value and I want just add it

Thank you

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13303
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: 2 stereotypes on attribute
« Reply #1 on: February 28, 2019, 03:01:48 am »
use Attribute.StereotypeEx with comma separated stereotypes.
To be sure EA chooses the correct stereotype you can use fully qualified stereotypes (e.g. BPMN2.0::Activity)

Geert

The apprentice

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: 2 stereotypes on attribute
« Reply #2 on: February 28, 2019, 03:52:44 am »
Thank you.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: 2 stereotypes on attribute
« Reply #3 on: February 28, 2019, 06:50:16 am »
you can use fully qualified stereotypes
Rather I think you should use FQNs. Even (especially) with those (barely documented) EAUML etc. profiles.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13303
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: 2 stereotypes on attribute
« Reply #4 on: February 28, 2019, 03:26:14 pm »
you can use fully qualified stereotypes
Rather I think you should use FQNs. Even (especially) with those (barely documented) EAUML etc. profiles.

q.
Yes, unless you are sure that your stereotype names are unique.
I tend to prefix all my own stereotypes with the name of the profile, so I'm 100% certain no other stereotypes exist with the same name.
Makes life a lot easier :D

Geert

The apprentice

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: 2 stereotypes on attribute
« Reply #5 on: March 01, 2019, 01:27:19 am »
What's a FQN ?

I have 2 stereotypes now but I'm not sur about the methodology :

Code: [Select]
newAttribute.StereotypeEx = "University::New";
                    newAttribute.Update();
                    newAttribute.StereotypeEx = "University::Data";
                    newAttribute.Update();
                    //newAttribute.Stereotype = newAttribute.StereotypeEx;

It seems to be working but I don't know how to remove an attribute.

I also seen that from an EA Administrator :

Quote
Use StereotypeEx for every time you want to write a stereotype.
•Use HasStereotype() for every time you want to check a stereotype.
•Edge cases for appending a stereotype to the existing list or checking for any stereotype both use StereotypeEx.
•FQStereotype is read only. It allows you to see the profile the first stereotype applied comes from.
•MetaType allows you to get the Metatype defined for an applied stereotype. (It's not read only, but it ignores any assignment)
•SynchTaggedValues() should be automatic when assigning a stereotype. It's useful if the stereotype definition has been updated or tags accidentally deleted

Do I Use Stereotype ?

Thank You
Pardon my english

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13303
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: 2 stereotypes on attribute
« Reply #6 on: March 01, 2019, 01:42:16 am »
FQN == Fully Qualified Name. So "University::New" instead of "New"
I think you can add both stereotypes at the same time by doing
Code: [Select]
newAttribute.StereotypeEx = "University::New,University::Data";
newAttribute.Update();

No, as you have read, the best practice is to not use the Stereotype property.

Geert

The apprentice

  • EA Novice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: 2 stereotypes on attribute
« Reply #7 on: March 01, 2019, 01:46:57 am »
Ok

But if I want to remove one of them. It'is possible to "clear" the stereotypeEx ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13303
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: 2 stereotypes on attribute
« Reply #8 on: March 01, 2019, 01:49:23 am »
Ok

But if I want to remove one of them. It'is possible to "clear" the stereotypeEx ?
I'm pretty sure it's possible but I don't remember how exactly. You'll have to experiment a bit to figure out how to use it.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: 2 stereotypes on attribute
« Reply #9 on: March 01, 2019, 06:53:36 am »
Makes me think that this should be added to my Scripting book. How and when are which stereotypes affected  (passing null, single, list FQN, non-FQN) using stereotype and -Ex properties.

q.

Richard Freggi

  • EA User
  • **
  • Posts: 487
  • Karma: +18/-7
    • View Profile
Re: 2 stereotypes on attribute
« Reply #10 on: March 01, 2019, 03:24:54 pm »
Per UML 2.5 can an element have more than one stereotype?  Asking for a friend.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8066
  • Karma: +118/-20
    • View Profile
Re: 2 stereotypes on attribute
« Reply #11 on: March 01, 2019, 05:19:55 pm »
Per UML 2.5 can an element have more than one stereotype?  Asking for a friend.

Technically the only UML elements that have stereotypes are Profiles.

Setting a stereotype on an element is actually creating an instance of that stereotype and setting the base_Element property on the stereotype to that element.

Yes. It is valid to have multiple stereotype instances reference the one UML element.

Talking about EA instead of UML. EA also allows a stereotype to be used as a metaclass. The meaning of that is that the element is now an instance of a specialized version of the base type. Multiples of that sort of stereotype are more complicated conceptually, but generally in EA it will behave like only one has that property.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: 2 stereotypes on attribute
« Reply #12 on: March 01, 2019, 07:33:32 pm »
When applying a stereotype is equivalent to creating an instance, then how would that be possible with multiple stereotypes? Really sounds like we have a machine that creates zombies or mutants. Looking at how stereotypes are dealt with in EA this proves to be true.

q.

Richard Freggi

  • EA User
  • **
  • Posts: 487
  • Karma: +18/-7
    • View Profile
Re: 2 stereotypes on attribute
« Reply #13 on: March 01, 2019, 08:31:53 pm »
Eve and Qwerty, thank you and I look forward to learning more if anyone has further insights

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: 2 stereotypes on attribute
« Reply #14 on: March 02, 2019, 12:19:30 am »
My view on stereotypes always was rather EA-centric and I did not look too deeply into the UML specs (they are no good read anyway). However, I started reading now and see that stereotype is no property of element. Rather a profile defines a view on the model and it contains stereotypes to create extended elements based on UML elements (or such provided by other profiles). So assigning a (EA) stereotype as a property appears to be just wrong. Let alone assigning two stereotypes. From what I currently understand (which is honestly just a bit of the whole thing) EA's implementation just looks like a mess. Just what it always felt when dealing with stereotype property assignments over the last (10) years. It seems that EA tries to create an instance of the profile element on the fly when assigning a stereotype. No wonder I had this Frankenstein-feeling all time.

If I'm wrong I'm open to any lecture.

q.