Book a Demo

Author Topic: restrict use stereotypes to other stereotypes  (Read 3130 times)

Palm

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
restrict use stereotypes to other stereotypes
« on: November 22, 2019, 09:50:57 pm »
Hi,

I created a UML classdiagram profile and a related MDG and toolbox, which is working correctly. I created several stereotypes for classes and several for attributes. What I want now is that certain stereotypes on attributes may only be used in classes of specific stereotypes. So restricting attribute stereotypes to specific class stereotypes. Is this possible?

Paul

Modesto Vega

  • EA Practitioner
  • ***
  • Posts: 1183
  • Karma: +30/-8
    • View Profile
Re: restrict use stereotypes to other stereotypes
« Reply #1 on: November 22, 2019, 11:39:40 pm »
Not sure I follow you, Class stereotypes should only be applicable to classes and Attribute stereotypes should only be applicable to attributes providing you have extended the right metaclasses.

Palm

  • EA Novice
  • *
  • Posts: 17
  • Karma: +0/-0
    • View Profile
Re: restrict use stereotypes to other stereotypes
« Reply #2 on: November 22, 2019, 11:58:47 pm »
Yes you are right in that respect. But my question is different. I have created attribute stereotype <<X>> and two Class stereotypes <<Y>> and <<Z>>.

I want the attribute stereotype <<X>> only te be applicable to attributes of a class of stereotype <<Y>> and not of type <<Z>>.


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: restrict use stereotypes to other stereotypes
« Reply #3 on: November 23, 2019, 12:30:21 am »
Metamodel constraints might be the solution, but I don't know if it works for the ownership relation between attributes and elements.

Geert

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: restrict use stereotypes to other stereotypes
« Reply #4 on: November 23, 2019, 01:53:34 am »
I have just conducted some experiments using metaconstraints, which I agree with Geert as the approach that should work

The obvious candidate for the umlRole tag is ownedAttribute

This certainly has no effect when adding stereotyped attributes to stereotyped classes, (as indeed do any other umlRoles for example owner)

Reading the user guide, it states this constraint is typically used to validate nesting during Model Validation, I tried Model Validation … guess what? No errors no warnings

I suppose a custom validation is required.

Sorry I could not be of more help, but if anyone does come up with an answer that does not involve coding or scripting (these can provide a psot validation of course), then I would very much like to know

All the best

Phil

Models are great!
Correct models are even greater!