Operation Body Expression [message #972270] |
Mon, 05 November 2012 13:48 |
|
I am trying to use Operation Body Expression as they are defined in the OCL specification at section 7.4.6
I created an example ocl file like this
import '[url]http://www.eclipse.org/uml2/4.0.0/UML[/url]'
package UML
context Operation
def: class:Class=self.oclAsType(ocl::OclElement)->closure(oclContainer())->select(oclIsTypeOf(Class))->any(true).oclAsType(Class)
inv testName('this is a test warning'):
class.name='Test'
endpackage
And validated a simple UML model against it. It works properly.
If I modify the ocl in this way
import 'http://www.eclipse.org/uml2/4.0.0/UML'
package UML
context Operation
def: class:Class=self.oclAsType(ocl::OclElement)->closure(oclContainer())->select(oclIsTypeOf(Class))->any(true).oclAsType(Class)
inv testName('this is a test warning'):
class.name='Test'
context Operation::getContainerClass() : Class
body: self.oclAsType(ocl::OclElement)->closure(oclContainer())->select(oclIsTypeOf(Class))->any(true).oclAsType(Class)
endpackage
I get an error depicted on the getContainerClass() Operation Declaration saying
Unresolved 'unknown-type' 'getContainerClass'
What am I doing wrong?
Follow me on Twitter @andreasindico
[Updated on: Mon, 05 November 2012 13:48] Report message to a moderator
|
|
|
|
Re: Operation Body Expression [message #972808 is a reply to message #972270] |
Mon, 05 November 2012 22:45 |
|
Ed there is something I still don't understand
The example in the specification is
context Person::getCurrentSpouse() : Person
pre: self.isMarried = true
body: self.mariages->select( m | m.ended = false ).spouse
and an OCL expression is said may be used to indicate the result of a query operation.
Although I may use a define I'd like to understand why it does not work with an operation. I guess I am not getting what does it mean the operation is pre-existing. My aim was actually to define an operation which did not exist.
Follow me on Twitter @andreasindico
[Updated on: Mon, 05 November 2012 22:46] Report message to a moderator
|
|
|
|
Re: Operation Body Expression [message #973953 is a reply to message #972270] |
Tue, 06 November 2012 19:02 |
|
yes I misunderstood it.
I thought it was a means to define queries (like queries in MOFM2T). Is there any way to do that?
As far as I understand a def is accessible in the context where it is defined.
I would like instead to define a query accessible from different contexts.
Thank you Ed
Follow me on Twitter @andreasindico
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03849 seconds