Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] Using OCL Invocation and Setting delegates
[ACCELEO] Using OCL Invocation and Setting delegates [message #813979] Mon, 05 March 2012 22:45 Go to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi,

I have a EMF model that I edited with OCLInEcore. In this model I use a lot derived properties and operations that are implemented using OCL (Pivot metamodel). When I use the model manually it all works fine, but when I use it in ACCELEO the derive properties and operations does not work.

I do the standalone setup:

   // initialize OCL
    OCLinEcoreStandaloneSetup.doSetup()
    OCLstdlib.install()
    OCL.initialize(null)

    // initialize OCL delegation
    val oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
    
    EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE += 
      (oclDelegateURI -> new OCLInvocationDelegateFactory.Global())
    
    EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE += 
      (oclDelegateURI -> new OCLSettingDelegateFactory.Global());
    
    EValidator.ValidationDelegate.Registry.INSTANCE += 
      (oclDelegateURI -> new OCLValidationDelegateFactory.Global()) 


Before I invoke the doGenerate() method from ACCELEO I can navigate through the model using the OCL implemented properties and invoke OCL implemented operations, but when I access a derived property I get:

org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 87 in Module main for block for (controlSystem.mainComposites). Last recorded value of self was fr.unice.salty.core.model.salty.impl.ControlSystemImpl@2857a293.
	at main.main(ControlSystem)(main.mtl:87)
	at main.main(ControlSystem)(main.mtl:83)


If I put a breakpoint to the method that encapsulates this property - the method that has been generated by the genmodel it is not called.

Is this supported in ACCELEO? What do I need to setup in order to have it working?

Thanks a lot for help
Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #814323 is a reply to message #813979] Tue, 06 March 2012 10:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

It should work. Your initialization looks plausible, although I've no
idea what language "val .... += ..." is. You might find
OCLDelegateDomain.initialize easier.

When the underlying infrastructure OCL or Java operations misbehaves,
the Acceleo error messages are not very helpful. Your message looks a
bit strange; are you using the default "Acceleo Plugin" launch? I've not
had any success with it. I always use the Java Application launch. You
can then break on the AcceleoEvaluationException and try to determine
what went wrong. In my experience, it's usually an operation call
interface issue; bad name or bad types. I would suspect an operation
whose parameters or a return are collections or EDataTypes.

If the above doesn't help, please send me something to debug.

Regards

Ed Willink


On 05/03/2012 22:45, Filip Krikava wrote:
> Hi,
>
> I have a EMF model that I edited with OCLInEcore. In this model I use
> a lot derived properties and operations that are implemented using OCL
> (Pivot metamodel). When I use the model manually it all works fine,
> but when I use it in ACCELEO the derive properties and operations does
> not work.
>
> I do the standalone setup:
>
> // initialize OCL
> OCLinEcoreStandaloneSetup.doSetup()
> OCLstdlib.install()
> OCL.initialize(null)
>
> // initialize OCL delegation
> val oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI_PIVOT;
> EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE
> += (oclDelegateURI -> new OCLInvocationDelegateFactory.Global())
>
> EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE
> += (oclDelegateURI -> new OCLSettingDelegateFactory.Global());
> EValidator.ValidationDelegate.Registry.INSTANCE +=
> (oclDelegateURI -> new OCLValidationDelegateFactory.Global())
> Before I invoke the doGenerate() method from ACCELEO I can navigate
> through the model using the OCL implemented properties and invoke OCL
> implemented operations, but when I access a derived property I get:
>
> org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop
> iteration at line 87 in Module main for block for
> (controlSystem.mainComposites). Last recorded value of self was
> fr.unice.salty.core.model.salty.impl.ControlSystemImpl@2857a293.
> at main.main(ControlSystem)(main.mtl:87)
> at main.main(ControlSystem)(main.mtl:83)
>
> If I put a breakpoint to the method that encapsulates this property -
> the method that has been generated by the genmodel it is not called.
> Is this supported in ACCELEO? What do I need to setup in order to have
> it working?
>
> Thanks a lot for help
> Filip
>
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #814363 is a reply to message #814323] Tue, 06 March 2012 11:02 Go to previous messageGo to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi,

Thanks for reply. Unfortunately it did not work for me (or I did not understand it) so I put together some sample project. In test/Tests.java you can find a simple junit testcase that shows what am I trying to accomplish. The testStandlone() uses the OCL delegates successfully, but in Acceleo it keeps failing.

If you can please have a look what I do wrong. I guess it is in the configure method in the test case where I register the delegates.

Thanks a lot for help!


  • Attachment: ocltest3.zip
    (Size: 46.30KB, Downloaded 571 times)
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #814529 is a reply to message #814363] Tue, 06 March 2012 15:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

Thanks for the excellent repro. (if you go to the Common tab of a launch
configuration, you can specify that the launch config is persisted in
perhaps your project .launches or .settings folder).

You picked the correct newsgroup. This is an Acceleo bug
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=373375).

The only workaround I can see without editing the Acceleo code is to the
Juno OCL release and give the experimental OCL to Java code generator a
try. This will avoid the need for Acceleo to parse the OCL.

Regards

Ed Willink


On 06/03/2012 11:02, Filip Krikava wrote:
> Hi,
>
> Thanks for reply. Unfortunately it did not work for me (or I did not understand it) so I put together some sample project. In test/Tests.java you can find a simple junit testcase that shows what am I trying to accomplish. The testStandlone() uses the OCL delegates successfully, but in Acceleo it keeps failing.
>
> If you can please have a look what I do wrong. I guess it is in the configure method in the test case where I register the delegates.
>
> Thanks a lot for help!
>
>
>
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #814835 is a reply to message #814529] Tue, 06 March 2012 23:35 Go to previous messageGo to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi,

Thanks a lot for such a fat response. That is very unfortunate (I guess that even if the self was not hidden if it interprets OCL it will not likely use the Pivot meta-model, right?).

I just don't understand why Acceleo does not use the generated java method? I mean if I add and operation or derived property that I implement manually in java it will work. Would it be possible to change the behavior so it does use it? I would be more than happy to hack it somehow if I knew where Smile.

I cannot change to Juno and I'd love to have the project be built on the OMG stds rather than some other M2T toolkit Smile

/cheers
Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815060 is a reply to message #814835] Wed, 07 March 2012 07:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

This issue is nothing to do with the new Pivot model.

[The editing activities use the Pivot model and persist the OCL
expression as a String within an EAnnotation. When Acceleo runs, the OCL
string is processed by the legacy Ecore support.]

Acceleo does use the generated method; it just gets a parse error while
doing so.

There is a good chance that changing line 111 of
org.eclipse.acceleo.engine.internal.environment.AcceleoEnvironmentFactory from

AcceleoEnvironment result = new
AcceleoEnvironment(getEPackageRegistry());

to

AcceleoEnvironment result = new AcceleoEnvironment(parent);

and introducing the missing constructor

protected AcceleoEnvironment(Environment<EPackage, EClassifier,
EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject,
CallOperationAction, SendSignalAction, Constraint, EClass, EObject>
parent) {
super(parent);
}

will cure the problem.

Perhaps someone from Obeo can be more helpful.

Regards

Ed Willink


On 06/03/2012 23:35, Filip Krikava wrote:
> Hi,
>
> Thanks a lot for such a fat response. That is very unfortunate (I
> guess that even if the self was not hidden if it interprets OCL it
> will not likely use the Pivot meta-model, right?).
>
> I just don't understand why Acceleo does not use the generated java
> method? I mean if I add and operation or derived property that I
> implement manually in java it will work. Would it be possible to
> change the behavior so it does use it? I would be more than happy to
> hack it somehow if I knew where :).
> I cannot change to Juno and I'd love to have the project be built on
> the OMG stds rather than some other M2T toolkit :)
>
> /cheers
> Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815129 is a reply to message #815060] Wed, 07 March 2012 09:10 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Ed, Filip,

What exactly am I to test here? If I launch the provided unit test with Helios :

- as JUnit test : testStandalone fails, testMTT is in error (as the template's first parameter is a proxy, I suppose due to testStandalone's failure.
- as JUnit plug-in test : testStandalone fails, testMTT passes.

testStandalone's failure is the same for both runs :

arrays first differed at element [0]; expected:<[B]> but was:<[C]>
at org.junit.internal.ComparisonCriteria.arrayEquals(ComparisonCriteria.java:52)
at org.junit.Assert.internalArrayEquals(Assert.java:414)
at org.junit.Assert.assertArrayEquals(Assert.java:166)
at org.junit.Assert.assertArrayEquals(Assert.java:183)
at Tests.testStandalone(Tests.java:44)

I'll try and launch the Acceleo generator itself, but here are my results with the unit test.

Laurent Goubet
Obeo
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815151 is a reply to message #815129] Wed, 07 March 2012 09:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi Laurent

When I run the attached launch config on 3.7.2, I get

org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop
iteration at line 14 in Module main for block for (system.allTested).
Last recorded value of self was
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@16614e7 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@16546ef (name: System)
(instanceClassName: null) (abstract: false, interface: false)). Problem
found while generating the file
'C:\Development\Admin\Workspace3.6\ocltest3\output\system.txt'.
at main.main(System)(main.mtl:14)
at main.main(System)(main.mtl:7)
at main.main(System)(main.mtl:4)
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop
iteration at line 18 in Module main for block for
(system.allTestedNames). Last recorded value of self was
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@16614e7 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@16546ef (name: System)
(instanceClassName: null) (abstract: false, interface: false)). Problem
found while generating the file
'C:\Development\Admin\Workspace3.6\ocltest3\output\system.txt'.
at main.main(System)(main.mtl:18)
at main.main(System)(main.mtl:7)
at main.main(System)(main.mtl:4)

If you run with a Breakpoint on NPE you will see the underlying failure
to resolve 'self' that causes a ParseException that causes the eventual
diagnostic.

Regards

Ed

On 07/03/2012 09:10, Laurent Goubet wrote:
> Ed, Filip,
>
> What exactly am I to test here? If I launch the provided unit test
> with Helios :
>
> - as JUnit test : testStandalone fails, testMTT is in error (as the
> template's first parameter is a proxy, I suppose due to
> testStandalone's failure.
> - as JUnit plug-in test : testStandalone fails, testMTT passes.
>
> testStandalone's failure is the same for both runs :
>
> arrays first differed at element [0]; expected:<[B]> but was:<[C]>
> at
> org.junit.internal.ComparisonCriteria.arrayEquals(ComparisonCriteria.java:52)
> at org.junit.Assert.internalArrayEquals(Assert.java:414)
> at org.junit.Assert.assertArrayEquals(Assert.java:166)
> at org.junit.Assert.assertArrayEquals(Assert.java:183)
> at Tests.testStandalone(Tests.java:44)
>
> I'll try and launch the Acceleo generator itself, but here are my
> results with the unit test.
>
> Laurent Goubet
> Obeo
  • Attachment: Main.launch
    (Size: 1.32KB, Downloaded 352 times)
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815170 is a reply to message #815151] Wed, 07 March 2012 10:08 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Ed,

Launching the generator itself did yield the expected failure indeed. Running the test, however, did not. That's why I asked.

As for the fix, it is indeed as you surmised with the broken parent/child relation on the evaluation's environment. This was an overlook (I used the same constructor for both methods of the factory ... which is somewhat stupid Razz). It will be fixed in both of the incoming versions (3.2 and 3.3).

Laurent Goubet
Obeo
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815184 is a reply to message #815170] Wed, 07 March 2012 10:26 Go to previous messageGo to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi Laurent,

Sorry for the tests - that was meant to be more a quick way to start the code rather than a real test.

I'm bit confused by your response - the 3.2 release is already available no? But you are saying that it will be available so I guess even if I upgrade to 3.2, the problem will still be there? If so, is there any easy way how to fix the problem adhoc?

Thanks a lot for help,
Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815205 is a reply to message #815184] Wed, 07 March 2012 10:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi Filip

Today, you can import the relevant Acceleo plugins into your workspace,
do the edits I suggested and then run in a nested workspace so that the
improved Acceleo is in use. (Or you can checkout
http://git.eclipse.org/c/m2t/org.eclipse.acceleo.git). This is often
useful for debugging anyway.

As soon as a 3.2 N-build including the fix is built you can download it
from http://eclipse.org/modeling/m2t/downloads/?project=acceleo or if
you're impatient from
https://hudson.eclipse.org/hudson/job/m2t-acceleo-3.2/lastSuccessfulBuild/artifact/Acceleo.downloads/

Regards

Ed Willink

On 07/03/2012 10:26, Filip Krikava wrote:
> Hi Laurent,
>
> Sorry for the tests - that was meant to be more a quick way to start
> the code rather than a real test.
>
> I'm bit confused by your response - the 3.2 release is already
> available no? But you are saying that it will be available so I guess
> even if I upgrade to 3.2, the problem will still be there? If so, is
> there any easy way how to fix the problem adhoc?
>
> Thanks a lot for help,
> Filip
>
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815209 is a reply to message #815205] Wed, 07 March 2012 11:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
> Today, you can import the relevant Acceleo plugins into your
> workspace, do the edits I suggested and then run in a nested workspace
> so that the improved Acceleo is in use. (Or you can checkout
> http://git.eclipse.org/c/m2t/org.eclipse.acceleo.git). This is often
> useful for debugging anyway.
And if you expect to make significant contributions you can create a
fork on https://github.com/eclipse/acceleo/network.

Regards

Ed Willink
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815386 is a reply to message #815209] Wed, 07 March 2012 15:42 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Filip,

A build with these changes is available on the interim update site : http://download.eclipse.org/modeling/m2t/acceleo/updates/interim/3.2

Do note that this is an integration build.

Laurent Goubet
Obeo
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815414 is a reply to message #815386] Wed, 07 March 2012 16:24 Go to previous messageGo to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi Laurent,

Thanks for getting back to me. I immediately gave it a try, but I still see the same problem:

org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 18 in Module main for block for (system.allTestedNames). Last recorded value of self was me.impl.SystemImpl@28d320d6. Problem found while generating the file '/Users/krikava/Development/workspaces/salty-fresh/ocltest3/output/system.txt'.
	at main.main(System)(main.mtl:18)
	at main.main(System)(main.mtl:7)
	at main.main(System)(main.mtl:4)


The version is: 3.2.1.v20120307-0859

Either I do something wrong in my setup or the problem is somewhere else.

/cheers
Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815429 is a reply to message #815414] Wed, 07 March 2012 16:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi Filip

It's not the same problem. Previously there were errors at line 14 and
18. The line 14 problem is fixed (parsing-wise). Line 18 is more
challenging, a derived property invocation from a derived property.

One possibility is the type; you have declared allTestedNames to return
a Set but collect gives you a Bag. Either Acceleo or OCL may be barfing
on this.

Investigating the actual exception behind the AcceleoEvaluationException
could be revealing.

Regards

Ed Willink


On 07/03/2012 16:24, Filip Krikava wrote:
> Hi Laurent,
>
> Thanks for getting back to me. I immediately gave it a try, but I
> still see the same problem:
>
> org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop
> iteration at line 18 in Module main for block for
> (system.allTestedNames). Last recorded value of self was
> me.impl.SystemImpl@28d320d6. Problem found while generating the file
> '/Users/krikava/Development/workspaces/salty-fresh/ocltest3/output/system.txt'.
> at main.main(System)(main.mtl:18)
> at main.main(System)(main.mtl:7)
> at main.main(System)(main.mtl:4)
>
>
> The version is: 3.2.1.v20120307-0859
>
> Either I do something wrong in my setup or the problem is somewhere else.
>
> /cheers
> Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815506 is a reply to message #815429] Wed, 07 March 2012 18:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

On 07/03/2012 16:50, Ed Willink wrote:
> One possibility is the type; you have declared allTestedNames to
> return a Set but collect gives you a Bag. Either Acceleo or OCL may be
> barfing on this.
Internally an OCLDelegateException is thrown with the message:

org.eclipse.ocl.ecore.delegate.OCLDelegateException: Initial or derived
value expression type (Bag(String)) does not conform to property
"allTestedNames" type (Set(String))

This gets turned into a blank invalid. (The new pivot model has invalid
with embedded cause chains.)

If I put in an asSet()

derivation: allTested->collect(name)->asSet();

and put in .name for component outputs I get

System:
- all components:
- A
- B
- C
- all tested components:
- B
- C
- all tested names:
- B (B)
- C (C)
- component A:
A

The missing editor warning for the type mismatch is work in progress.

Regards

Ed Willink
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815665 is a reply to message #815506] Wed, 07 March 2012 23:12 Go to previous messageGo to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
This time it was me who replied too fast Smile

It works, I also tried in the project and so far so good.

Amazing, thanks a lot guys, I really appreciate it!
Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #815933 is a reply to message #815665] Thu, 08 March 2012 08:15 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Yeah, sorry about that, I did fix the errors in your expressions while testing this to make sure it worked, but forgot to mention them here.

Glad you sorted it out Smile.

Laurent Goubet
Obeo
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #816163 is a reply to message #815933] Thu, 08 March 2012 13:57 Go to previous messageGo to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi,

I'm afraid I was too fast. I'm hitting another problem, this time with oclContainer(). I guess I must have misunderstood Ed's reply concerning the Pivot meta-model.

In the example project if I wanted to add a derived property like this:

	class Component
	{
		property parent : System[1] { derived readonly transient volatile }
		{
			derivation: oclContainer().oclAsType(System);
		}
	}


And I use it in the mtt file like

[component.parent /]


I get

(parent: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1df6bc1a (eClass: org.eclipse.emf.ecore.impl.EClassImpl@31b75e54 (name: OclInvalid_Class) (instanceClassName: null) (abstract: false, interface: false)))


This time I tried find the cause of this and I got an exception: org.eclipse.ocl.ecore.delegate.OCLDelegateException: illegal operation signature: (oclContainer()) in org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression():246
I understand why the exception is there, the "oclContainer()" operation is not part of the standard OCL it is part of the new pivot meta-model. I should have seen that coming since Acceleo evaluates the OCL expression with the regular OCL implementation.

The solution to my problem (at least in my case) lies in the OCLDelegateDomain.getDelegateAnnotation(). If I change it in the way that I remove the second for loop i.e. it will not consider Pivot annotations then the generated methods are called instead and they use the correct OCL Pivot delegates. If I'm not completely off, is there any fix I can do?

Thanks a lot for all this help!
Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #816196 is a reply to message #816163] Thu, 08 March 2012 14:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

Try

....eContainer()

or

....oclAsType(EObject).eContainer()

for which you may need to import Ecore.

Regards

Ed Willink

On 08/03/2012 13:57, Filip Krikava wrote:
> Hi,
>
> I'm afraid I was too fast. I'm hitting another problem, this time with
> oclContainer(). I guess I must have misunderstood Ed's reply
> concerning the Pivot meta-model.
>
> In the example project if I wanted to add a derived property like this:
>
>
> class Component
> {
> property parent : System[1] { derived readonly transient
> volatile }
> {
> derivation: oclContainer().oclAsType(System);
> }
> }
>
>
> And I use it in the mtt file like
> [component.parent /]
>
> I get
> (parent: org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1df6bc1a
> (eClass: org.eclipse.emf.ecore.impl.EClassImpl@31b75e54 (name:
> OclInvalid_Class) (instanceClassName: null) (abstract: false,
> interface: false)))
>
> This time I tried find the cause of this and I got an exception:
> org.eclipse.ocl.ecore.delegate.OCLDelegateException: illegal operation
> signature: (oclContainer()) in
> org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression():246
> I understand why the exception is there, the "oclContainer()"
> operation is not part of the standard OCL it is part of the new pivot
> meta-model. I should have seen that coming since Acceleo evaluates the
> OCL expression with the regular OCL implementation.
>
> The solution to my problem (at least in my case) lies in the
> OCLDelegateDomain.getDelegateAnnotation(). If I change it in the way
> that I remove the second for loop i.e. it will not consider Pivot
> annotations then the generated methods are called instead and they use
> the correct OCL Pivot delegates. If I'm not completely off, is there
> any fix I can do?
>
> Thanks a lot for all this help!
> Filip
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #816214 is a reply to message #816196] Thu, 08 March 2012 15:06 Go to previous messageGo to next message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi,

Thanks again for fast response!

I already tried eContainer(), I should have mentioned it, the error is the same:

org.eclipse.ocl.ecore.delegate.OCLDelegateException: illegal operation signature: (eContainer())


Not to mention that it get changed to oclBadOperation() behind the scene every time I close/open the document Smile

Your second suggestion also does not work. This time it is related to the package issue we have discussed yesterday [1]. I would need to write it as:

oclAsType(ecore::EObject).eContainer() 


having added

import ecore : '/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#/';


Actually not only this but also the import then disappears since the Ecore meta-model is not references from any element. I guess I will go with some aspect around the OCLDelegateDomain.getDelegateAnnotation().

[1] http[:]//www.eclipse.org/forums/index.php/t/305202/
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #816224 is a reply to message #816214] Thu, 08 March 2012 15:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7680
Registered: July 2009
Senior Member
Hi

The easiest solution is to have a modeled container that is the opposite
of the child, then you can just do "my.parent". This costs just about
nothing since EMF recognises it as a named container.

If you really want eContainer() then you may need to explicitly inherit
from EObject since I doubt that you can get at the programatic implicit
root class option.

Regards

Ed Willink


On 08/03/2012 15:06, Filip Krikava wrote:
> Hi,
>
> Thanks again for fast response!
>
> I already tried eContainer(), I should have mentioned it, the error is
> the same:
>
> org.eclipse.ocl.ecore.delegate.OCLDelegateException: illegal operation
> signature: (eContainer())
>
> Not to mention that it get changed to oclBadOperation() behind the
> scene every time I close/open the document :)
>
> Your second suggestion also does not work. This time it is related to
> the package issue we have discussed yesterday [1]. I would need to
> write it as:
>
> oclAsType(ecore::EObject).eContainer()
> having added
> import ecore : '/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#/';
>
> Actually not only this but also the import then disappears since the
> Ecore meta-model is not references from any element. I guess I will go
> with some aspect around the OCLDelegateDomain.getDelegateAnnotation().
>
> [1] http[:]//www.eclipse.org/forums/index.php/t/305202/
Re: [ACCELEO] Using OCL Invocation and Setting delegates [message #816238 is a reply to message #816224] Thu, 08 March 2012 15:37 Go to previous message
Filip Krikava is currently offline Filip KrikavaFriend
Messages: 45
Registered: January 2012
Member
Hi Ed,

That is true, adding parent as a regular reference will fix this particular problem, but in this case it will make the model parser more difficult. Anyway, I might be facing similar issue later that will be due the the difference between Pivot and the regular OCL meta-model like when I would use oclContents() or something. That's why I think making the change that will prevent Acceleo (and potentially other tools) to evaluate expression that was not meant for them will fix the problem.

/cheers
Filip
Previous Topic:how to get a list of import packages
Next Topic:MWE: Couldn't load resource under platform:/resource
Goto Forum:
  


Current Time: Thu Dec 12 11:41:08 GMT 2024

Powered by FUDForum. Page generated in 0.06148 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top