Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: RodneyRichardson on June 06, 2025, 01:12:32 am

Title: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: RodneyRichardson on June 06, 2025, 01:12:32 am
I'm pretty sure EA doesn't support this, but thought I'd ask the talented people on here.

I have created custom stereotypes in an MDG profile. I would like to use the same name for a stereotype I can apply to either a Class or a Connector; let's call it «mechanical». When applied to a Class, I would like it to apply a Tagged Value called CAD File ID, but I don't want to apply the Tagged Value when used on a Connector.

In my profile, if I create a single Stereotype which extends both Class and Connector, then then tagged values I define on the stereotype get added when I apply it to a Class or a Connector. If I try to define a second Stereotype with the same name, the first extending Class and the second extending Connector, then only one of these ends up in the exported MDG profile and I can't apply it on both Classes and Connectors (depending which one ends up in the profile).

Is there a way to conditionally define which tagged values get applied based on the extended metaclass? I think my only alternatives are to give the Connector stereotype a different name, or just live with the additional Tagged Value on the connector (and leave the value empty).



Title: Re: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: Geert Bellekens on June 06, 2025, 01:37:08 am
No, that doesn't work.

But why would you want to do that. If your two stereotype does not even have the same properties, in what sense are they the same then?
Why can't you simply make two stereotypes with different names? ("MechanicalElemnet" and "MechanicalConnector")?
You can make an abstract stereotype "Mechanical" and have both generalize that abstract stereotype if you do have common properties or relations.

Geert
Title: Re: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: RodneyRichardson on June 06, 2025, 02:45:24 am
No, that doesn't work.

But why would you want to do that. If your two stereotype does not even have the same properties, in what sense are they the same then?
Why can't you simply make two stereotypes with different names? ("MechanicalElemnet" and "MechanicalConnector")?
You can make an abstract stereotype "Mechanical" and have both generalize that abstract stereotype if you do have common properties or relations.

Geert

Thanks. I thought as much, and I've gone for a second stereotype with a different name.

As for why I'd want to do this: I, long ago along with a lot of the software world, moved away from putting the "type of the thing in the name of the thing" when it can otherwise be inferred from context - e.g. in code, I don't say
Code: [Select]
int intValue = 1;but instead
Code: [Select]
int value = 1;and it's the same here - it just feels clumsy.

I traced this back to the SysML 1.5 (and 1.7) specification but it doesn't say anything on the matter. It gives an example of applying the same stereotype to different metaclasses and applying the same properties (which is what EA does), but doesn't seem to explicitly include or exclude using the same-named stereotype on different metaclasses.
Title: Re: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: PDC on June 06, 2025, 05:20:49 pm
Might be messy (and I'm sure you thought of this) but you could always include the TV on your Connectors too but set it to something like 'N/A'. At least means you can use the stereotypes in the way you want to.
Title: Re: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: Geert Bellekens on June 06, 2025, 05:27:18 pm
Even if it would work, it's sometimes kind of annoying.
ArchiMate does that for a few stereotypes (ArchiMate_Path, and ArchiMate_CommunicationNetwork). They are applied on both Class and Connector

Issues:
- When making a view specification you can only specify the stereotype, and not the base type. I wanted to only expose ArchiMate_Path as Class, not as Connector. But that is not possible
- When spefifying metamodel relations such as a stereotyped relation, you can only set them based on the stereotype. Again if you only want to allow a relation to ArchiMate_Path when used as Class, then it also allow the relation to ArchiMate_Path when used as connector.

I had to completely redefine ArchiMate_Path in our MDG so it would only apply to a Class

Geert
Title: Re: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: Eve on June 09, 2025, 09:50:06 am
As for why I'd want to do this: I, long ago along with a lot of the software world, moved away from putting the "type of the thing in the name of the thing" when it can otherwise be inferred from context - e.g. in code, I don't say
Code: [Select]
int intValue = 1;but instead
Code: [Select]
int value = 1;and it's the same here - it just feels clumsy.

I traced this back to the SysML 1.5 (and 1.7) specification but it doesn't say anything on the matter. It gives an example of applying the same stereotype to different metaclasses and applying the same properties (which is what EA does), but doesn't seem to explicitly include or exclude using the same-named stereotype on different metaclasses.
If it helps, the profile is a Namespace. Two stereotypes with the same name are not distinguishable from each other. (Look for isDistinguishableFrom in the UML specification, which is not overridden by the Stereotype class)

To compare it to your code example, if you needed an int value and a float value in the same namespace/scope you would need to rename one or both.
Title: Re: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: PDC on June 09, 2025, 05:20:07 pm
Even if it would work, it's sometimes kind of annoying.
ArchiMate does that for a few stereotypes (ArchiMate_Path, and ArchiMate_CommunicationNetwork). They are applied on both Class and Connector
...
I had to completely redefine ArchiMate_Path in our MDG so it would only apply to a Class

Interesting... have to admit I've barely scratched the surface of ArchiMate, is this a case where EA treats the ArchiMate profile differently to others like the SysML profile? Or just something fundamentally different about the 2 altogether?
Title: Re: Apply custom stereotype to Class and Connector with different Tagged Values
Post by: Geert Bellekens on June 09, 2025, 05:50:16 pm
Interesting... have to admit I've barely scratched the surface of ArchiMate, is this a case where EA treats the ArchiMate profile differently to others like the SysML profile? Or just something fundamentally different about the 2 altogether?
No, I think they are treated the same. I'm not sure if there are any fundamental differences between the two profiles.

Geert