Home » Modeling » OCL » Reusing OCL in a profile
Reusing OCL in a profile [message #1587384] |
Tue, 27 January 2015 10:02 |
Eclipse User |
|
|
|
Dear all,
When adding OCL to a profile in Papyrus, I would like to factorize OCL
code to improve maintainability. For instance, if I have in two
stereotypes an attribute of type TypeA, I would like to write just once
the constraints and then invoke them from both stereotypes.
Is it possible when specifying the constraints in the profile?
Regards,
Víctor
|
|
| |
Re: Reusing OCL in a profile [message #1587567 is a reply to message #1587527] |
Tue, 27 January 2015 12:22 |
Eclipse User |
|
|
|
Thanks Ed.
I don't know exactly how to create helpers in the Constraint element in
the profile specification. Since it is a helper function, Should I need
to specify a Context or I should use a parameter instead with no Context
specification. I guess a parameter would be the right way. However, I
can't find the exact syntax to create helper functions in the profile.
Regards,
Víctor
El 27/01/2015 a las 12:50, Ed Willink escribió:
> Hi
>
> UML Constraints are not re-useable, which is clearly very irritating.
> Graphically there is no problem in drawing multiple lines from a
> Constraint and functionally these could be the various
> Constraint.constrainedElement values. Unfortunately the
> Constraint.constrainedElement values are underspecified and almost an
> irrelevance. It is the one Constraint.context that defines the context
> of the Constraint and consequently makes it un-reuseable.
>
> You can define a helper operation that can be invoked from multiple
> constraints and so avoid repetitive complex OCL expressions.
>
> Regards
>
> Ed Willink
>
>
> On 27/01/2015 10:02, "V. López" wrote:
>> Dear all,
>> When adding OCL to a profile in Papyrus, I would like to factorize OCL
>> code to improve maintainability. For instance, if I have in two
>> stereotypes an attribute of type TypeA, I would like to write just
>> once the constraints and then invoke them from both stereotypes.
>> Is it possible when specifying the constraints in the profile?
>>
>> Regards,
>>
>> Víctor
>
|
|
|
Re: Reusing OCL in a profile [message #1587718 is a reply to message #1587567] |
Tue, 27 January 2015 14:15 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
A helper 'function' is just a query Operation, probably with an
OCL-defined body. It can have as many parameters as you like.
Regards
Ed Willink
On 27/01/2015 12:22, "V. López" wrote:
> Thanks Ed.
>
> I don't know exactly how to create helpers in the Constraint element
> in the profile specification. Since it is a helper function, Should I
> need to specify a Context or I should use a parameter instead with no
> Context specification. I guess a parameter would be the right way.
> However, I can't find the exact syntax to create helper functions in
> the profile.
>
> Regards,
>
> Víctor
>
> El 27/01/2015 a las 12:50, Ed Willink escribió:
>> Hi
>>
>> UML Constraints are not re-useable, which is clearly very irritating.
>> Graphically there is no problem in drawing multiple lines from a
>> Constraint and functionally these could be the various
>> Constraint.constrainedElement values. Unfortunately the
>> Constraint.constrainedElement values are underspecified and almost an
>> irrelevance. It is the one Constraint.context that defines the context
>> of the Constraint and consequently makes it un-reuseable.
>>
>> You can define a helper operation that can be invoked from multiple
>> constraints and so avoid repetitive complex OCL expressions.
>>
>> Regards
>>
>> Ed Willink
>>
>>
>> On 27/01/2015 10:02, "V. López" wrote:
>>> Dear all,
>>> When adding OCL to a profile in Papyrus, I would like to factorize OCL
>>> code to improve maintainability. For instance, if I have in two
>>> stereotypes an attribute of type TypeA, I would like to write just
>>> once the constraints and then invoke them from both stereotypes.
>>> Is it possible when specifying the constraints in the profile?
>>>
>>> Regards,
>>>
>>> Víctor
>>
>
|
|
|
Re: Reusing OCL in a profile [message #1587865 is a reply to message #1587718] |
Tue, 27 January 2015 16:00 |
Eclipse User |
|
|
|
Thanks again Ed for your quick answer.
I've used queries in Acceleo, the problem is that I don't how to do it
in the profile specification.
Please, find attached two images. In the first one (OCL01.png) there is
a OCL constraints which works OK. Now what I would like to achieve is
what is shown in OCL02.png. That is, factorize the constraint by
invoking the query, but I must be missing something or the syntax I'm
using it's not OK.
I wonder if it is possible.
Best,
Víctor
El 27/01/2015 a las 15:15, Ed Willink escribió:
> Hi
>
> A helper 'function' is just a query Operation, probably with an
> OCL-defined body. It can have as many parameters as you like.
>
> Regards
>
> Ed Willink
>
>
> On 27/01/2015 12:22, "V. López" wrote:
>> Thanks Ed.
>>
>> I don't know exactly how to create helpers in the Constraint element
>> in the profile specification. Since it is a helper function, Should I
>> need to specify a Context or I should use a parameter instead with no
>> Context specification. I guess a parameter would be the right way.
>> However, I can't find the exact syntax to create helper functions in
>> the profile.
>>
>> Regards,
>>
>> Víctor
>>
>> El 27/01/2015 a las 12:50, Ed Willink escribió:
>>> Hi
>>>
>>> UML Constraints are not re-useable, which is clearly very irritating.
>>> Graphically there is no problem in drawing multiple lines from a
>>> Constraint and functionally these could be the various
>>> Constraint.constrainedElement values. Unfortunately the
>>> Constraint.constrainedElement values are underspecified and almost an
>>> irrelevance. It is the one Constraint.context that defines the context
>>> of the Constraint and consequently makes it un-reuseable.
>>>
>>> You can define a helper operation that can be invoked from multiple
>>> constraints and so avoid repetitive complex OCL expressions.
>>>
>>> Regards
>>>
>>> Ed Willink
>>>
>>>
>>> On 27/01/2015 10:02, "V. López" wrote:
>>>> Dear all,
>>>> When adding OCL to a profile in Papyrus, I would like to factorize OCL
>>>> code to improve maintainability. For instance, if I have in two
>>>> stereotypes an attribute of type TypeA, I would like to write just
>>>> once the constraints and then invoke them from both stereotypes.
>>>> Is it possible when specifying the constraints in the profile?
>>>>
>>>> Regards,
>>>>
>>>> Víctor
>>>
>>
>
|
|
|
Re: Reusing OCL in a profile [message #1587904 is a reply to message #1587865] |
Tue, 27 January 2015 16:31 |
Eclipse User |
|
|
|
Sorry, forgot to attached the images.
Please, find them attached.
Víctor,
El 27/01/2015 a las 17:00, "V. López" escribió:
> Thanks again Ed for your quick answer.
>
> I've used queries in Acceleo, the problem is that I don't how to do it
> in the profile specification.
> Please, find attached two images. In the first one (OCL01.png) there is
> a OCL constraints which works OK. Now what I would like to achieve is
> what is shown in OCL02.png. That is, factorize the constraint by
> invoking the query, but I must be missing something or the syntax I'm
> using it's not OK.
> I wonder if it is possible.
>
> Best,
>
> Víctor
>
> El 27/01/2015 a las 15:15, Ed Willink escribió:
>> Hi
>>
>> A helper 'function' is just a query Operation, probably with an
>> OCL-defined body. It can have as many parameters as you like.
>>
>> Regards
>>
>> Ed Willink
>>
>>
>> On 27/01/2015 12:22, "V. López" wrote:
>>> Thanks Ed.
>>>
>>> I don't know exactly how to create helpers in the Constraint element
>>> in the profile specification. Since it is a helper function, Should I
>>> need to specify a Context or I should use a parameter instead with no
>>> Context specification. I guess a parameter would be the right way.
>>> However, I can't find the exact syntax to create helper functions in
>>> the profile.
>>>
>>> Regards,
>>>
>>> Víctor
>>>
>>> El 27/01/2015 a las 12:50, Ed Willink escribió:
>>>> Hi
>>>>
>>>> UML Constraints are not re-useable, which is clearly very irritating.
>>>> Graphically there is no problem in drawing multiple lines from a
>>>> Constraint and functionally these could be the various
>>>> Constraint.constrainedElement values. Unfortunately the
>>>> Constraint.constrainedElement values are underspecified and almost an
>>>> irrelevance. It is the one Constraint.context that defines the context
>>>> of the Constraint and consequently makes it un-reuseable.
>>>>
>>>> You can define a helper operation that can be invoked from multiple
>>>> constraints and so avoid repetitive complex OCL expressions.
>>>>
>>>> Regards
>>>>
>>>> Ed Willink
>>>>
>>>>
>>>> On 27/01/2015 10:02, "V. López" wrote:
>>>>> Dear all,
>>>>> When adding OCL to a profile in Papyrus, I would like to factorize OCL
>>>>> code to improve maintainability. For instance, if I have in two
>>>>> stereotypes an attribute of type TypeA, I would like to write just
>>>>> once the constraints and then invoke them from both stereotypes.
>>>>> Is it possible when specifying the constraints in the profile?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Víctor
>>>>
>>>
>>
>
-
Attachment: OCL01.png
(Size: 17.60KB, Downloaded 264 times) -
Attachment: OCL02.png
(Size: 32.64KB, Downloaded 274 times)
|
|
|
Re: Reusing OCL in a profile [message #1588002 is a reply to message #1587718] |
Tue, 27 January 2015 17:46 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
to be clearer
A helper 'function' is a UML Operation that is a query and has a body
'constraint' defined using OCL.
Regards
Ed Willink
On 27/01/2015 14:15, Ed Willink wrote:
> Hi
>
> A helper 'function' is just a query Operation, probably with an
> OCL-defined body. It can have as many parameters as you like.
>
> Regards
>
> Ed Willink
>
>
> On 27/01/2015 12:22, "V. López" wrote:
>> Thanks Ed.
>>
>> I don't know exactly how to create helpers in the Constraint element
>> in the profile specification. Since it is a helper function, Should I
>> need to specify a Context or I should use a parameter instead with no
>> Context specification. I guess a parameter would be the right way.
>> However, I can't find the exact syntax to create helper functions in
>> the profile.
>>
>> Regards,
>>
>> Víctor
>>
>> El 27/01/2015 a las 12:50, Ed Willink escribió:
>>> Hi
>>>
>>> UML Constraints are not re-useable, which is clearly very irritating.
>>> Graphically there is no problem in drawing multiple lines from a
>>> Constraint and functionally these could be the various
>>> Constraint.constrainedElement values. Unfortunately the
>>> Constraint.constrainedElement values are underspecified and almost an
>>> irrelevance. It is the one Constraint.context that defines the context
>>> of the Constraint and consequently makes it un-reuseable.
>>>
>>> You can define a helper operation that can be invoked from multiple
>>> constraints and so avoid repetitive complex OCL expressions.
>>>
>>> Regards
>>>
>>> Ed Willink
>>>
>>>
>>> On 27/01/2015 10:02, "V. López" wrote:
>>>> Dear all,
>>>> When adding OCL to a profile in Papyrus, I would like to factorize OCL
>>>> code to improve maintainability. For instance, if I have in two
>>>> stereotypes an attribute of type TypeA, I would like to write just
>>>> once the constraints and then invoke them from both stereotypes.
>>>> Is it possible when specifying the constraints in the profile?
>>>>
>>>> Regards,
>>>>
>>>> Víctor
>>>
>>
>
|
|
|
Re: Reusing OCL in a profile [message #1589424 is a reply to message #1588002] |
Wed, 28 January 2015 12:36 |
Eclipse User |
|
|
|
Thanks Ed, now I found some documentation on the topic here:
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FOCLinPapyrus.html
However, there are some issues I can't solve.
In the image attached I try to add a Helper class with a query operation
that I try to call from another Constraint in a Stereotype.
But I'm not able to find out how to do it properly.
Is there an example somewhere where the invocation of the query is shown.
Regards,
Víctor López-Jaquero
El 27/01/2015 a las 18:46, Ed Willink escribió:
> Hi
>
> to be clearer
>
> A helper 'function' is a UML Operation that is a query and has a body
> 'constraint' defined using OCL.
>
> Regards
>
> Ed Willink
>
> On 27/01/2015 14:15, Ed Willink wrote:
>> Hi
>>
>> A helper 'function' is just a query Operation, probably with an
>> OCL-defined body. It can have as many parameters as you like.
>>
>> Regards
>>
>> Ed Willink
>>
>>
>> On 27/01/2015 12:22, "V. López" wrote:
>>> Thanks Ed.
>>>
>>> I don't know exactly how to create helpers in the Constraint element
>>> in the profile specification. Since it is a helper function, Should I
>>> need to specify a Context or I should use a parameter instead with no
>>> Context specification. I guess a parameter would be the right way.
>>> However, I can't find the exact syntax to create helper functions in
>>> the profile.
>>>
>>> Regards,
>>>
>>> Víctor
>>>
>>> El 27/01/2015 a las 12:50, Ed Willink escribió:
>>>> Hi
>>>>
>>>> UML Constraints are not re-useable, which is clearly very irritating.
>>>> Graphically there is no problem in drawing multiple lines from a
>>>> Constraint and functionally these could be the various
>>>> Constraint.constrainedElement values. Unfortunately the
>>>> Constraint.constrainedElement values are underspecified and almost an
>>>> irrelevance. It is the one Constraint.context that defines the context
>>>> of the Constraint and consequently makes it un-reuseable.
>>>>
>>>> You can define a helper operation that can be invoked from multiple
>>>> constraints and so avoid repetitive complex OCL expressions.
>>>>
>>>> Regards
>>>>
>>>> Ed Willink
>>>>
>>>>
>>>> On 27/01/2015 10:02, "V. López" wrote:
>>>>> Dear all,
>>>>> When adding OCL to a profile in Papyrus, I would like to factorize OCL
>>>>> code to improve maintainability. For instance, if I have in two
>>>>> stereotypes an attribute of type TypeA, I would like to write just
>>>>> once the constraints and then invoke them from both stereotypes.
>>>>> Is it possible when specifying the constraints in the profile?
>>>>>
>>>>> Regards,
>>>>>
>>>>> Víctor
>>>>
>>>
>>
>
-
Attachment: OCL03.png
(Size: 28.79KB, Downloaded 276 times)
|
|
|
Re: Reusing OCL in a profile [message #1589531 is a reply to message #1589424] |
Wed, 28 January 2015 13:59 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
It's a normal OO functional call
someObject.someFunction()
Regards
Ed Willink
On 28/01/2015 12:36, "V. López" wrote:
> Thanks Ed, now I found some documentation on the topic here:
>
> http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FOCLinPapyrus.html
>
>
> However, there are some issues I can't solve.
> In the image attached I try to add a Helper class with a query
> operation that I try to call from another Constraint in a Stereotype.
> But I'm not able to find out how to do it properly.
>
> Is there an example somewhere where the invocation of the query is shown.
>
> Regards,
>
> Víctor López-Jaquero
>
> El 27/01/2015 a las 18:46, Ed Willink escribió:
>> Hi
>>
>> to be clearer
>>
>> A helper 'function' is a UML Operation that is a query and has a body
>> 'constraint' defined using OCL.
>>
>> Regards
>>
>> Ed Willink
>>
>> On 27/01/2015 14:15, Ed Willink wrote:
>>> Hi
>>>
>>> A helper 'function' is just a query Operation, probably with an
>>> OCL-defined body. It can have as many parameters as you like.
>>>
>>> Regards
>>>
>>> Ed Willink
>>>
>>>
>>> On 27/01/2015 12:22, "V. López" wrote:
>>>> Thanks Ed.
>>>>
>>>> I don't know exactly how to create helpers in the Constraint element
>>>> in the profile specification. Since it is a helper function, Should I
>>>> need to specify a Context or I should use a parameter instead with no
>>>> Context specification. I guess a parameter would be the right way.
>>>> However, I can't find the exact syntax to create helper functions in
>>>> the profile.
>>>>
>>>> Regards,
>>>>
>>>> Víctor
>>>>
>>>> El 27/01/2015 a las 12:50, Ed Willink escribió:
>>>>> Hi
>>>>>
>>>>> UML Constraints are not re-useable, which is clearly very irritating.
>>>>> Graphically there is no problem in drawing multiple lines from a
>>>>> Constraint and functionally these could be the various
>>>>> Constraint.constrainedElement values. Unfortunately the
>>>>> Constraint.constrainedElement values are underspecified and almost an
>>>>> irrelevance. It is the one Constraint.context that defines the
>>>>> context
>>>>> of the Constraint and consequently makes it un-reuseable.
>>>>>
>>>>> You can define a helper operation that can be invoked from multiple
>>>>> constraints and so avoid repetitive complex OCL expressions.
>>>>>
>>>>> Regards
>>>>>
>>>>> Ed Willink
>>>>>
>>>>>
>>>>> On 27/01/2015 10:02, "V. López" wrote:
>>>>>> Dear all,
>>>>>> When adding OCL to a profile in Papyrus, I would like to
>>>>>> factorize OCL
>>>>>> code to improve maintainability. For instance, if I have in two
>>>>>> stereotypes an attribute of type TypeA, I would like to write just
>>>>>> once the constraints and then invoke them from both stereotypes.
>>>>>> Is it possible when specifying the constraints in the profile?
>>>>>>
>>>>>> Regards,
>>>>>>
>>>>>> Víctor
>>>>>
>>>>
>>>
>>
>
|
|
|
Re: Reusing OCL in a profile [message #1591341 is a reply to message #1589531] |
Thu, 29 January 2015 13:22 |
Eclipse User |
|
|
|
Hi,
I got it working with a test example by using operations as queries. I
added an stereotype (abstractStereotype) where the operations are
defined. The other stereotype (relationshipC) has a generalization
relationship with this abstractStereotype. This abstractStereotype is an
extension of the metaclass Dependency. Then I write something like after
specifying the operation in the abstractStereotype:
CheckProfiles(self.base_Dependency) (as an OCL in relationshipC
stereotype).
This works.
Nevertheless, when I try to do the same with a model where the profile
is within a package it doesn't work.
Should I change something when calling the operation? I always get the
same error:
The 'RelationshipC::ConstraintTest' constraint result is invalid for
'«RelationshipC»profile::0'
- Failed to evaluate
profile::Test::AbstractDependency::CheckProfiles(UML::Dependency) :
Boolean <<RelationshipC>> <Dependency> 0 profile EMF Problem
I checked the OCL body of the operation by using a regular constraint
and it works.
Regards,
Víctor
El 28/01/2015 a las 14:59, Ed Willink escribió:
> Hi
>
> It's a normal OO functional call
>
> someObject.someFunction()
>
> Regards
>
> Ed Willink
>
>
> On 28/01/2015 12:36, "V. López" wrote:
>> Thanks Ed, now I found some documentation on the topic here:
>>
>> http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FOCLinPapyrus.html
>>
>>
>> However, there are some issues I can't solve.
>> In the image attached I try to add a Helper class with a query
>> operation that I try to call from another Constraint in a Stereotype.
>> But I'm not able to find out how to do it properly.
>>
>> Is there an example somewhere where the invocation of the query is shown.
>>
>> Regards,
>>
>> Víctor López-Jaquero
>>
>> El 27/01/2015 a las 18:46, Ed Willink escribió:
>>> Hi
>>>
>>> to be clearer
>>>
>>> A helper 'function' is a UML Operation that is a query and has a body
>>> 'constraint' defined using OCL.
>>>
>>> Regards
>>>
>>> Ed Willink
>>>
>>> On 27/01/2015 14:15, Ed Willink wrote:
>>>> Hi
>>>>
>>>> A helper 'function' is just a query Operation, probably with an
>>>> OCL-defined body. It can have as many parameters as you like.
>>>>
>>>> Regards
>>>>
>>>> Ed Willink
>>>>
>>>>
>>>> On 27/01/2015 12:22, "V. López" wrote:
>>>>> Thanks Ed.
>>>>>
>>>>> I don't know exactly how to create helpers in the Constraint element
>>>>> in the profile specification. Since it is a helper function, Should I
>>>>> need to specify a Context or I should use a parameter instead with no
>>>>> Context specification. I guess a parameter would be the right way.
>>>>> However, I can't find the exact syntax to create helper functions in
>>>>> the profile.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Víctor
>>>>>
>>>>> El 27/01/2015 a las 12:50, Ed Willink escribió:
>>>>>> Hi
>>>>>>
>>>>>> UML Constraints are not re-useable, which is clearly very irritating.
>>>>>> Graphically there is no problem in drawing multiple lines from a
>>>>>> Constraint and functionally these could be the various
>>>>>> Constraint.constrainedElement values. Unfortunately the
>>>>>> Constraint.constrainedElement values are underspecified and almost an
>>>>>> irrelevance. It is the one Constraint.context that defines the
>>>>>> context
>>>>>> of the Constraint and consequently makes it un-reuseable.
>>>>>>
>>>>>> You can define a helper operation that can be invoked from multiple
>>>>>> constraints and so avoid repetitive complex OCL expressions.
>>>>>>
>>>>>> Regards
>>>>>>
>>>>>> Ed Willink
>>>>>>
>>>>>>
>>>>>> On 27/01/2015 10:02, "V. López" wrote:
>>>>>>> Dear all,
>>>>>>> When adding OCL to a profile in Papyrus, I would like to
>>>>>>> factorize OCL
>>>>>>> code to improve maintainability. For instance, if I have in two
>>>>>>> stereotypes an attribute of type TypeA, I would like to write just
>>>>>>> once the constraints and then invoke them from both stereotypes.
>>>>>>> Is it possible when specifying the constraints in the profile?
>>>>>>>
>>>>>>> Regards,
>>>>>>>
>>>>>>> Víctor
>>>>>>
>>>>>
>>>>
>>>
>>
>
|
|
|
Goto Forum:
Current Time: Thu Sep 26 05:22:54 GMT 2024
Powered by FUDForum. Page generated in 0.04494 seconds
|