Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Problem execution operation defined in meta model
[Acceleo] Problem execution operation defined in meta model [message #559016] Wed, 15 September 2010 10:36 Go to next message
Simon harrer is currently offline Simon harrer
Messages: 25
Registered: August 2010
Junior Member
I have a method defined in my meta model using OCL. This method is invoked in an MTL file and always produces an error evaluating to an dynamic object reference in the text output.

How is the model to generate to enable the execution of operations defined in OCL in Acceleo?

Best regards,
Simon
Re: [Acceleo] Problem execution operation defined in meta model [message #559029 is a reply to message #559016] Wed, 15 September 2010 11:20 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1632
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020709020606030108000501
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Simon,

Could you elaborate on what you'd like to do, and how? I can't really
understand what you're trying to achieve.

Laurent Goubet
Obeo

Simon harrer wrote:
> I have a method defined in my meta model using OCL. This method is
> invoked in an MTL file and always produces an error evaluating to an
> dynamic object reference in the text output.
> How is the model to generate to enable the execution of operations
> defined in OCL in Acceleo?
>
> Best regards,
> Simon


--------------020709020606030108000501
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------020709020606030108000501--
Re: [Acceleo] Problem execution operation defined in meta model [message #559034 is a reply to message #559016] Wed, 15 September 2010 11:36 Go to previous messageGo to next message
Simon harrer is currently offline Simon harrer
Messages: 25
Registered: August 2010
Junior Member
ok, I will explain in some detail now:

my metamodel:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="my"
    nsURI="http://my" nsPrefix="my">
  <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
    <details key="invocationDelegates" value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
    <details key="settingDelegates" value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
    <details key="validationDelegates" value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
  </eAnnotations>
  <eClassifiers xsi:type="ecore:EClass" name="MyTest">
    <eOperations name="testOperation" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
      <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
        <details key="body" value="name.concat('asdf')"/>
      </eAnnotations>
    </eOperations>
    <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
  </eClassifiers>
</ecore:EPackage>


I want to use the operation testOperation() inside my template which is shown here:
[template public generate(m : MyTest)]
	
	[comment @main /]
	[file (m.name, false, 'UTF-8')]
	[m.testOperation()/]
	[/file]
	
[/template]


If I use this as an AcceleoPluginApplication, everything works. If I run this as a JavaApplication, the method could not be instantiated. The output then looks the following:
	org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1fc8efd1 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@40f892a4 (name: OclInvalid_Class) (instanceClassName: null) (abstract: false, interface: false))
Re: [Acceleo] Problem execution operation defined in meta model [message #559038 is a reply to message #559034] Wed, 15 September 2010 11:56 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1632
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020105080708090503020200
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Simon,

Acceleo Plugin applications mean "in Eclipse" while "Java Application"
mean "standalone". When running standalone applications, you have some
more things to setup (the things Eclipse does for you otherwise).

If I am not mistaken, you should have one (or more) report in your error
log (in Eclipse : Windows => show view => Error Log) saying that one (or
more) package(s) couldn't be found. You'll have to register those
packages as explained on
http://wiki.eclipse.org/MDT/UML2/FAQ#What.27s_required_to_lo ad_a_UML_.28.uml.29_resource_from_a_standalone_application.3 F
or
http://eclipsemde.blogspot.com/2010/06/package-with-uri-not- found.html
(these both use UML as an example).

There might also be some more things to setup from an OCL point of view,
but I don't think so.

Laurent Goubet
Obeo

Simon harrer wrote:
> ok, I will explain in some detail now:
>
> my metamodel:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="my"
> nsURI="http://my" nsPrefix="my">
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore">
> <details key="invocationDelegates"
> value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
> <details key="settingDelegates"
> value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
> <details key="validationDelegates"
> value="http://www.eclipse.org/emf/2002/Ecore/OCL"/>
> </eAnnotations>
> <eClassifiers xsi:type="ecore:EClass" name="MyTest">
> <eOperations name="testOperation" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString">
> <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
> <details key="body" value="name.concat('asdf')"/>
> </eAnnotations>
> </eOperations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
> </ecore:EPackage>
>
>
> I want to use the operation testOperation() inside my template which is
> shown here:
>
> [template public generate(m : MyTest)]
>
> [comment @main /]
> [file (m.name, false, 'UTF-8')]
> [m.testOperation()/]
> [/file]
>
> [/template]
>
>
> If I use this as an AcceleoPluginApplication, everything works. If I run
> this as a JavaApplication, the method could not be instantiated. The
> output then looks the following:
>
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1fc8efd1 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@40f892a4 (name: OclInvalid_Class)
> (instanceClassName: null) (abstract: false, interface: false))
>


--------------020105080708090503020200
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------020105080708090503020200--
Re: [Acceleo] Problem execution operation defined in meta model [message #559632 is a reply to message #559016] Fri, 17 September 2010 13:10 Go to previous messageGo to next message
Simon harrer is currently offline Simon harrer
Messages: 25
Registered: August 2010
Junior Member
I had to register OCL delegates. Otherwise, the methods could not be invoked. Maybe, this code should be included into the abstract transformation class which is also generated.

http://wiki.eclipse.org/MDT/OCLinEcore#Standalone
Re: [Acceleo] Problem execution operation defined in meta model [message #559957 is a reply to message #559632] Mon, 20 September 2010 14:31 Go to previous message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1632
Registered: July 2009
Senior Member
Hi Simon,

Thanks for the follow-up, I've raised bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=325760 in order to track this issue and for us to remember that there might be something to do for this.

Laurent Goubet
Obeo
Previous Topic:[XPand/MWE] Error executing workflow - java.lang.NoSuchFieldError: ruleMemo
Next Topic:[Xpand] 3.4 update site's errors
Goto Forum:
  


Current Time: Thu Oct 23 05:15:42 GMT 2014

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

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