|
Re: Operation, Instantiation and post clause: Invalid Class? [message #516389 is a reply to message #516383] |
Tue, 23 February 2010 20:17 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Alexandre
There is no problem parsing your example.
MDT/OCL currently has no evaluation support for pre or postconditions,
so evaluation will have proceded and just ignored your post conditions.
I presume this is what you describe as 'working'. Eventually you try to
use the return value, which was not constructed so you got an Invalid Class.
OCL 2.2 does not support construction of arbitrary objects.
OMG Issue 13057 suggests introduction of type constructors. This might
happen for OCL 2.3 when I proptotype it and write up a resolution.
This would allow you perhaps to do
context OrderWindow::retrieveOrderForm(o:small::domain::Order) : OrderForm
body: result = OrderForm {date = o.date, customer = o.customer.name,
order = o }
Regards
Ed Willink
On 23/02/2010 19:48, Alexandre Torres wrote:
> Hi, I was testing the use of post clauses with my operation with
> MDT-OCL. I'm running against an EMF model created from an UML metamodel,
> exported as an ECORE and generated automatically by eclipse.
>
> I defined in my metamodel class an operation called retrieveOrderForm:
>
> context OrderWindow::retrieveOrderForm(o:small::domain::Order): OrderForm
> post: result.date = o.date post: result.customer = o.customer.name
> post: result.order = o
> This was inspired by the example in section 8.3.8 of OCL spec. The
> objective is instantiate an OrderForm object.
> And it parsed and the operation worked! That was unexpected :) Great
> work folks 8) cooool But I got a DynamicEObjectImpl with Invalid_Class
> as result.
> :roll: mailto:org.eclipse.emf.ecore.impl.DynamicEObjectImpl@105ef53
> (eClass: mailto:org.eclipse.emf.ecore.impl.EClassImpl@905eba (name:
> Invalid_Class) (instanceClassName: null) (abstract: false, interface:
> false))
>
> What happened ?
> This was also unexpected 8o , I did not expect the instantiation to work
> in the first place (that old dogma about ocl not producing
> side-effects), but this kind of puzzle me. Maybe it's a configuration
> issue? or I just called some undocumented feature? If so, any way around
> to instantiate objects with pure OCL?
>
> initializing with
> OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
> and parsing ocl as a file.
>
> thanks in advance.
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04616 seconds