Home » Modeling » Papyrus » Troubles with profiles
Troubles with profiles [message #872339] |
Tue, 15 May 2012 23:42 |
Davide Rossi Messages: 22 Registered: July 2009 |
Junior Member |
|
|
Hi all. I'm trying to set up a profile and use it.
I'm using Papyrus 0.8.2 on Eclipse 3.7.2; available documentation is largely outdated and I'm having troubles with a few details.
I guess that for the most part is just me getting lost in menus and dialogs and not seeing options that are available somewhere.
Just as an example let's say that my profile has a "Semaphore" stereotype extending metaclass Class and I defined a Semaphore's Counter property as an Integer (so Counter is a tagged value).
1. How do I associate a constraint to that tagged value (to, say, enforce Counter to be > 0)? To my knowledge this should be possible by (i) adding a constraint child to the stereotype or by (ii) defining a model-level constraint and link it to the stereotype.
As far as I saw (i) can only be accomplished by adding the constraint from the contextual menu in the model view (right click on Semaphore, New Child/Create a new Constraint); but then I found no way to show a constraints compartment, so the constraint does not appear anywhere in the diagram (well, I can drag the constraint from the model into the diagram and it is represented as a model-level constraint but then this becomes solution (ii)).
As for (ii), a solution I do not like but that allow the constraint to appear in the diagram: it is sufficient to write "self.Counter > 0" as the specification or have I also to explicitly define a context (my guess is "Semaphore") and/or a constrained element (my guess is no)?
2. If I apply the profile to a class diagram and I use the Semaphore stereotype on a class, how can I make the Counter tagged value appear in the diagram? BTW: I just found a way before submitting this message: you can click on the display icons on the right side of "Applied stereotypes" in the Appearance tab of the Properties view after having selected "Counter" from the list right under the icons. But that way a new compartment is created (which cannot be selected from the usual show/hide compartment dialog) while I'd like the more usual annotation notation. Can this be done?
3. How can I validate a model adopting my profile (so that I know that all semaphores have counters that are greater than zero)? I guess the Validation sub-menu for the contextual menu of the model in the Model view has something to do with that but I've not been able to make it work (or I do not know where to look for its output).
Since I'm at it, that's quite OT since it's mostly about OCL but... is it possible to define a constraint for a stereotype extending ControlFlow so that it can be only used to connect OpaqueActions to which specific stereotypes have been applied?
Also: I tried to apply a profile to an activity diagram but I had to do it via the Model view since the "Profile" tab is not available in the diagram properties, is that by design?
Thanks,
Davide.
|
|
|
Re: Troubles with profiles [message #872471 is a reply to message #872339] |
Wed, 16 May 2012 07:33 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hello,
1) I guess the first option is not available in the Papyrus profile diagram. There are still missing features, so this wouldn't surprise me.
The constraint does not always need a context. Most of the time, the context will simply be the constrained element. However, in some cases, it may be useful to define a specific context (For example when you have more than one constrained element).
2) Theoretically, there are three ways to display a stereotype :
- A new compartment, which is the default option (BTW, In the next Papyrus version in June, the stereotype compartments will appear in the show/hide compartment menu)
- A Comment associated to the stereotyped element
- Between braces in the stereotyped element's label
If you cannot use one or another of these options, then this is a bug. They are available in the appearance tab of the property view.
3) Currently, the validation tool only works with standard UML constraints. The profile constraints are not taken into account yet. Profile constraint validation is planed for the next version of Papyrus.
Quote:Since I'm at it, that's quite OT since it's mostly about OCL but... is it possible to define a constraint for a stereotype extending ControlFlow so that it can be only used to connect OpaqueActions to which specific stereotypes have been applied?
I guess so. The UML Metamodel defines operations to access the stereotypes applied to an Element, and OCL can use these operations. Something like that:
self.getAppliedStereotypes()->exists(e | e.name = "MyStereotype")
Camille Letavernier
|
|
|
Re: Troubles with profiles [message #872585 is a reply to message #872471] |
Wed, 16 May 2012 11:57 |
Davide Rossi Messages: 22 Registered: July 2009 |
Junior Member |
|
|
Camille, thanks for the prompt reply.
Camille Letavernier wrote on Wed, 16 May 2012 03:33Hello,
2) Theoretically, there are three ways to display a stereotype :
- A new compartment, which is the default option (BTW, In the next Papyrus version in June, the stereotype compartments will appear in the show/hide compartment menu)
- A Comment associated to the stereotyped element
- Between braces in the stereotyped element's label
If you cannot use one or another of these options, then this is a bug. They are available in the appearance tab of the property view.
Must be a bug then, "Compartment" and "With brace" both work but if I select "Comment" nothing is shown. For sure something like "Properties display place" or "Tagged values display place" in place of "Display place" would help in understanding what the option is about.
Camille Letavernier wrote on Wed, 16 May 2012 03:33
3) Currently, the validation tool only works with standard UML constraints. The profile constraints are not taken into account yet. Profile constraint validation is planed for the next version of Papyrus.
Good to know, at least I can stop trying to understand how to use it.
Camille Letavernier wrote on Wed, 16 May 2012 03:33
I guess so. The UML Metamodel defines operations to access the stereotypes applied to an Element, and OCL can use these operations. Something like that:
self.getAppliedStereotypes()->exists(e | e.name = "MyStereotype")
Yup, seems reasonable. As far as you know is there an interactive OCL shell that can be used on model elements?
Thanks,
Davide.
[Updated on: Wed, 16 May 2012 12:00] Report message to a moderator
|
|
| | |
Re: Troubles with profiles [message #1007626 is a reply to message #872471] |
Wed, 06 February 2013 19:16 |
Ed Willink Messages: 7658 Registered: July 2009 |
Senior Member |
|
|
Hi
Comments in line.
On 16/05/2012 08:33, Camille Letavernier wrote:
> Hello,
>
> 1) I guess the first option is not available in the Papyrus profile
> diagram. There are still missing features, so this wouldn't surprise me.
>
> The constraint does not always need a context. Most of the time, the
> context will simply be the constrained element. However, in some
> cases, it may be useful to define a specific context (For example when
> you have more than one constrained element).
Any (OCL) constraint that references the model needs a context to define
the 'self' object. The constrainedElements can be ignored by OCL; they
are just a documentation courtesy.
> 3) Currently, the validation tool only works with standard UML
> constraints. The profile constraints are not taken into account yet.
> Profile constraint validation is planed for the next version of Papyrus.
The Kepler M5 release finally provides plausible Constraint editing for
Stereotypes and profiles.
Validation should be available in M6.
> Quote:
>> Since I'm at it, that's quite OT since it's mostly about OCL but...
>> is it possible to define a constraint for a stereotype extending
>> ControlFlow so that it can be only used to connect OpaqueActions to
>> which specific stereotypes have been applied?
>
>
> I guess so. The UML Metamodel defines operations to access the
> stereotypes applied to an Element, and OCL can use these operations.
> Something like that:
>
> self.getAppliedStereotypes()->exists(e | e.name = "MyStereotype")
self.extension_MyStereotype <> null
Regards
Ed Willink
|
|
|
Goto Forum:
Current Time: Mon May 13 08:13:53 GMT 2024
Powered by FUDForum. Page generated in 0.04513 seconds
|