Specification of operation bodies in 'plain Java' + OCL-based constraints [message #1696494] |
Tue, 26 May 2015 17:15 |
Matthias Freund Messages: 8 Registered: May 2014 |
Junior Member |
|
|
Hi all,
this is my situation:
In my metamodel, I have introduced some custom operations and specified their body via annotations with source 'http://www.eclipse.org/emf/2002/Ecore', key = "body" and a value in plain Java. Additionally, I have defined some OCL constraints for the parent EClass (The ".../OCL/Pivot" delegates are used just as in the "OCLin EcoreTutorial"). If I generate the model code, everything works fine and the constraints are validated properly in the editor.
Up to now, I have set the OCL preference "Realisation of OCL embedded within Ecore models" to "Delegate for interpretation at runtime." Now, I want to generate Java code for the OCL constraints by setting the value of the preference to "Generate Java Code in *Impl classes".
However, when I regenerate the model code, the custom operations are not generated properly any more -- instead, they only contain a "throw new UnsupportedOperationException();" statement.
My question is whether this is a bug or if it is now allowed to mix OCL-based invariants with operation body specifications in plain Java. Do I have to specify the bodies of my operations in OCL as well or is there any other solution?
Thanks in advance!
Matthias
|
|
|
Re: Specification of operation bodies in 'plain Java' + OCL-based constraints [message #1696502 is a reply to message #1696494] |
Tue, 26 May 2015 19:10 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
I hadn't considered this, but it should just work.
The OCLinEcore CG just does what you do, it adds
'http://www.eclipse.org/emf/2002/Ecore' "body" EAnnotations to an
in-memory copy of the model in a pre-generate phase.
But beware, you need to restart the GenModel editor after making model
changes, since the additions to the in-memory model do not work well if
added a second time. This is a known bug.
Regards
Ed Willink
On 26/05/2015 18:15, Matthias Freund wrote:
> Hi all,
>
> this is my situation:
> In my metamodel, I have introduced some custom operations and
> specified their body via annotations with source
> 'http://www.eclipse.org/emf/2002/Ecore', key = "body" and a value in
> plain Java. Additionally, I have defined some OCL constraints for the
> parent EClass (The ".../OCL/Pivot" delegates are used just as in the
> "OCLin EcoreTutorial"). If I generate the model code, everything works
> fine and the constraints are validated properly in the editor.
>
> Up to now, I have set the OCL preference "Realisation of OCL embedded
> within Ecore models" to "Delegate for interpretation at runtime." Now,
> I want to generate Java code for the OCL constraints by setting the
> value of the preference to "Generate Java Code in *Impl classes".
>
> However, when I regenerate the model code, the custom operations are
> not generated properly any more -- instead, they only contain a "throw
> new UnsupportedOperationException();" statement.
>
> My question is whether this is a bug or if it is now allowed to mix
> OCL-based invariants with operation body specifications in plain Java.
> Do I have to specify the bodies of my operations in OCL as well or is
> there any other solution?
>
> Thanks in advance!
> Matthias
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03072 seconds