Skip to main content



      Home
Home » Modeling » UML2 » RE: steretype on multiple different attributes
RE: steretype on multiple different attributes [message #1852559] Mon, 23 May 2022 12:54 Go to next message
Eclipse UserFriend
Hi,

I am trying to use stereotypes to define unique indexes on a Class's properties.
An index can span over multiple properties.

Eg,
Class: Person {firstName, lastName, nickName, idNumber}

I'd like to create 3 unique indexes on Person.
1) [firstName, lastName]
2) [nickName]
3) [idNumber]

I know how to create a stereotype on Person that allows me to define one index, but how to do multiple unique indexes.

I tried to create a new Class called "Index" with an array or properties in the profile but I have no idea of to create the "Index" when applied to my model?

Is this possible?
Thanks
Pieter
Re: RE: steretype on multiple different attributes [message #1852560 is a reply to message #1852559] Mon, 23 May 2022 14:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I'm not sure that you need to use Stereotypes at all. Why not just use qualified associations? The modeling should work. How well code generators work is another matter.

Regards

Ed Willink
Re: RE: steretype on multiple different attributes [message #1852561 is a reply to message #1852560] Mon, 23 May 2022 15:40 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Ok, I can do it with qualifiers, however is it possible with stereotypes?

I have no idea how to use/instantiate the classes I model in the profile.
Once applied there seems to be no way to instantiate the classes modelled in the profile.

I am using Papyrus but even in the UML tree view I can find no support for the classes modelled in the profile.

Thanks
Pieter
Re: RE: steretype on multiple different attributes [message #1852567 is a reply to message #1852561] Tue, 24 May 2022 03:32 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The stereotype classes in your profile will be automatically instantiated when you apply the profile.

If you have other classes in your profile, they have to be reachable from the sterotype instances via composite associations.


I joining a project inspired by your question, so you can test by yourself.

In the picture you can see the profile definition

index.php/fa/42089/0/

Papyrus proposes some clumsy, incomplete support for creating the instances of the profile classes and editing them.

If i apply the stereotype <<indexed>> to a class, and select the class, in the properties view I can create new indexes, however I was not able to edit them (there seems to be a bug or missing feature in Payrus, but I could not figure it out)

index.php/fa/42091/0/


I know the profile definitions are right because if I open the uml model with the tree UML Model Editor, I can see the instantiated indexes and can edit them

index.php/fa/42092/0/

Hope this helps

G. Vega
Re: RE: steretype on multiple different attributes [message #1852583 is a reply to message #1852567] Wed, 25 May 2022 03:31 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Thanks for the information and example.

However I am not able to replicate your example.
index.php/fa/42098/0/
index.php/fa/42099/0/

I added the composite association but for some reason its not instantiating the "Index"

The only way I can manage to get to add properties is to add properties directly to the "Indexed" Stereotype.
index.php/fa/42100/0/
index.php/fa/42101/0/
index.php/fa/42102/0/

I am on the latest papyrus "Version: 2022-03 (4.23)"

In your example, does the "Index" get created when applying the Stereotype.
If so, how do you create a second and third "Index"?

Thanks
Pieter
Re: RE: steretype on multiple different attributes [message #1852584 is a reply to message #1852583] Wed, 25 May 2022 04:34 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Quote:

I added the composite association but for some reason its not instantiating the "Index"
The only way I can manage to get to add properties is to add properties directly to the "Indexed" Stereotype.


Yes, I forgot to tell you that when you create the association you have to be sure that the composite member end is owned by the stereotype class, otherwise Papyrus doesn't show it.

index.php/fa/42103/0/

Quote:

In your example, does the "Index" get created when applying the Stereotype.
If so, how do you create a second and third "Index"?


No, the "index" doesn't get created automatically, I created it by hand using the Papyrus toolbar at the right panel, similarly for the second and third indexes.

index.php/fa/42104/0/

I have discovered all of this by trial and error, I do not know if this is documented somewhere in Papyrus. But my profiles are much simpler than what you want to achieve, so perhaps you should ask for further details directly in the papyrus forum

Regards

German

Re: RE: steretype on multiple different attributes [message #1852589 is a reply to message #1852584] Wed, 25 May 2022 08:22 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Great, its working.
Thanks.

Is is possible to create the "Index" using the generic UML Editor?
You say you discovered this by trail and error, is this documented anywhere at all?

Thanks again,
Pieter
Re: RE: steretype on multiple different attributes [message #1852654 is a reply to message #1852589] Mon, 30 May 2022 03:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The documentation I know about profiles are

1) For the UML Editor

https://wiki.eclipse.org/MDT/UML2/Introduction_to_UML2_Profiles

2) For Papyrus

https://www.eclipse.org/papyrus/resources/PapyrusUserGuideSeries_AboutUMLProfile_v1.0.0_d20120606.pdf

There may be variations with respect to the latest versions of the tools, but the general instructions are still valid.

In both documents there are sections about stereotype property values (what was used to be called "tagged values" in previous UML versions).

But in most examples the properties of the stereotypes are primitive values, not instances of a class (like in your case the indexes). How this case is handled in the different editors is what I have discovered by trial and error.

I would like to add that this is not a limitation of the UML2 metamodel that can handle this perfectly well, it is a limitation of the designer tools (UML Model editor, Papyrus, etc ...) that make choices on how to edit stereotype information

Regards

[Updated on: Mon, 30 May 2022 03:37] by Moderator

Re: RE: steretype on multiple different attributes [message #1852692 is a reply to message #1852654] Tue, 31 May 2022 14:21 Go to previous message
Eclipse UserFriend
Thanks for the info and help.
Regards
Previous Topic:[SOLVED] Why a stereotype application breaks when the same profile is re-applied?
Next Topic:Exception raised when applying stereotype
Goto Forum:
  


Current Time: Fri Jul 18 20:10:11 EDT 2025

Powered by FUDForum. Page generated in 0.07332 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top