Author Topic: MDG definition to restrict stereotyped attributes on a class?  (Read 129 times)

Guillaume

  • EA User
  • **
  • Posts: 822
  • Karma: +22/-0
    • View Profile
    • www.umlchannel.com
MDG definition to restrict stereotyped attributes on a class?
« on: October 14, 2019, 07:45:47 pm »
Hi,

My UML profile has the TypeA stereotype on the Class metaclass, and Type1 + Type2 stereotypes on the Attribute metaclass.
I'd like to define that a "TypeA" stereotyped class can either have "Type1" or "Type2" stereotyped attributes.

Is there a way in the MDG Uml Profile definition to enforce this? For instance when one uses Enumeration classes, attributes are automatically stereotyped enum. Is there a way to achieve something similar?

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9547
  • Karma: +275/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: MDG definition to restrict stereotyped attributes on a class?
« Reply #1 on: October 14, 2019, 08:28:33 pm »
The enum thing only happens when using Java as langauge, and I'm pretty sure it's a hardcoded thing.

Geert

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2664
  • Karma: +41/-2
    • View Profile
Re: MDG definition to restrict stereotyped attributes on a class?
« Reply #2 on: October 24, 2019, 09:20:44 am »
Try defining a pair of <<metaconstraint>> as described in the help here: Define Metamodel Constraints. I think you will need a <<metaconstraint>> from Type1 to TypeA with umlRole=class, and the same from Type2 to TypeA.

EDIT: Or you may need to reverse these and have umlRole=ownedAttribute.
« Last Edit: October 24, 2019, 11:32:23 am by KP »
The Sparx Team
support@sparxsystems.com

Guillaume

  • EA User
  • **
  • Posts: 822
  • Karma: +22/-0
    • View Profile
    • www.umlchannel.com
Re: MDG definition to restrict stereotyped attributes on a class?
« Reply #3 on: October 24, 2019, 04:55:35 pm »
It looks exactly what I'm looking for but unfortunately I cannot get it to work.
I created metaconstraints from the class stereotypes to each attribute stereotype with umlRole = ownedAttribute
I also tried with the metaconstraint from the attribute stereotype to the class with umlRole = class

Any idea on what I might do wrongly?

Note: there's another topic on the metaconstraint that is waiting for some advice -> https://www.sparxsystems.com/forums/smf/index.php/topic,43433.msg257321.html#msg257321
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com