Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL and JAVA code calling (alternative QVT...)(ATL & making a call on ECORE OPERATION for PROPERTIES)
ATL and JAVA code calling (alternative QVT...) [message #1201300] Thu, 21 November 2013 17:25 Go to next message
cyril dufrechou is currently offline cyril dufrechouFriend
Messages: 35
Registered: September 2013
Member
My context:
-----------

I make a M2M transformation from XX.format1 to YY.format2 models.
In XX.format1 model a textual field is treated with ANTL parser (JAVA code generated)

I search a way to call a JAVA function from an ATL or QVT script to take the result of textual field parsed in order to insert in YY.format2 model.

I can't do this in the definition project of *.format1 because the eclipse project defining the parser taking this *.format as dependance.

So I will have a cycle of dependance in this case.

Finally my only way to succeed is to be able to call the parser from ATL or other M2M API (I tried QVT but I don't find)

My question:
------------

Find a way to call A JAVA code function from ATL or QVT script.
=> This function returns an object and is not void
=> This function is an operation defined in the entry metamodel definition but without its body (the body is defined with ANTLR parser)

Regards,
Cyril
Re: ATL and JAVA code calling (alternative QVT...) [message #1202693 is a reply to message #1201300] Fri, 22 November 2013 09:12 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
You can create an eOperation in your metamodel. This can then be called just like any method inside the ATL code in a to or do section. When you have created the eOperation on the desired type in your model just re-run the EMF GenModel code generator. You *must* implement the body for the eOperation in your java code. An impl stud will be created for you by the EMF GenModel code generator. Just fill that in and be impressed when it runs Smile
Regards,
Ronan
Re: ATL and JAVA code calling (alternative QVT...) [message #1205855 is a reply to message #1202693] Sat, 23 November 2013 21:10 Go to previous messageGo to next message
cyril dufrechou is currently offline cyril dufrechouFriend
Messages: 35
Registered: September 2013
Member
Thank you for your answer but in my case I can't simply add implementation of eOperation in JAVA code.
Because my metamodel is used to generate in another ANTLR project the function to be called by my eOperation...
So a cycle in eclipse projects is created trying to add in project dependancies the package to be used...
This is why I search a way to call java code from ATL or QVT and not from my metamodel...

Do you think it's possible?
Re: ATL and JAVA code calling (alternative QVT...) [message #1206825 is a reply to message #1205855] Sun, 24 November 2013 08:26 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Your explanation is not very convincing. Adding an EOperation should not
be difficult. Cycles can uisually be broken though you haven't explained
why you have one in the first place.

Regards

Ed Willink


On 23/11/2013 21:10, cyril dufrechou wrote:
> Thank you for your answer but in my case I can't simply add
> implementation of eOperation in JAVA code.
> Because my metamodel is used to generate in another ANTLR project the
> function to be called by my eOperation...
> So a cycle in eclipse projects is created trying to add in project
> dependancies the package to be used...
> This is why I search a way to call java code from ATL or QVT and not
> from my metamodel...
>
> Do you think it's possible?
Re: ATL and JAVA code calling (alternative QVT...) [message #1207528 is a reply to message #1206825] Sun, 24 November 2013 16:36 Go to previous messageGo to next message
cyril dufrechou is currently offline cyril dufrechouFriend
Messages: 35
Registered: September 2013
Member
I will try to explain more precisely my dependence cycle:

I create one EMF project:
This first project contain the ecore definition of my MODEL1 format
In this definition I create an eOperation to get a field form my model.

I create a second ANTLR project to define the parsing of the field using ANTLR advantages.
This second project defines a JAVA method to be called by the eOperation.
This second project takes EMF project in dependence META_INF.

Now if I try to add in my EMF project dependence to ANTLR project to be able to access the JAVA method parser, eclipse tell me it's impossible to generate the model via genmodel tool.

This is the dependence cycle I try to correct...

My final goal is to transform MODEL1 in ATL or QVT to obtain MODEL2.
And the parsing of the field via ANTLR is also a goal in my transformation.

I choose to make 2 projects to be modular and separate objectives.
But I don't succeed in integration of these modules.

Regards
Cyril
Re: ATL and JAVA code calling (alternative QVT...) [message #1208802 is a reply to message #1207528] Mon, 25 November 2013 07:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

I don't doubt that you have a cycle. My earlier comment was that most
cycles can usually be broken.

Approach 1: redesign the steps so that they don't form a loop
Approach 2: factor some common step out of the loop so that the cycle
vanishes

Note that many many users have been defining EMF code for many years so
I'm not clear why you cannot define an EMF Operation body as youir final
activity without a loop.

Regards

Ed Willink


On 24/11/2013 16:36, cyril dufrechou wrote:
> I will try to explain more precisely my dependence cycle:
>
> I create one EMF project:
> This first project contain the ecore definition of my MODEL1 format
> In this definition I create an eOperation to get a field form my model.
> I create a second ANTLR project to define the parsing of the field
> using ANTLR advantages.
> This second project defines a JAVA method to be called by the eOperation.
> This second project takes EMF project in dependence META_INF.
>
> Now if I try to add in my EMF project dependence to ANTLR project to
> be able to access the JAVA method parser, eclipse tell me it's
> impossible to generate the model via genmodel tool.
>
> This is the dependence cycle I try to correct...
>
> My final goal is to transform MODEL1 in ATL or QVT to obtain MODEL2.
> And the parsing of the field via ANTLR is also a goal in my
> transformation.
>
> I choose to make 2 projects to be modular and separate objectives.
> But I don't succeed in integration of these modules.
>
> Regards
> Cyril
Re: ATL and JAVA code calling (alternative QVT...) [message #1209007 is a reply to message #1208802] Mon, 25 November 2013 09:40 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
Yes I agree. This isn't an ATL issue as it is a project seteup issue.

In general I find it hard to undersatnd your question. What is a field in your world?

I'll take a stab and guess that you have a grammar which has an underlying EMF Model. You want the EMF model in one project and the grammar parser in another. I don't see any problem with doing that. Actually, why don't you use XText instead of ANTLR directly? XText is great at seperating these concerns. It will parse your grammar instance for you and leave your EMF model pure i.e. Just managing the data concern.
ATL and XText work beautifully together.

So take a step back and reconsider how you are doing this.

Regards,
Ronan
Re: ATL and JAVA code calling (alternative QVT...) [message #1209677 is a reply to message #1209007] Mon, 25 November 2013 16:46 Go to previous messageGo to next message
cyril dufrechou is currently offline cyril dufrechouFriend
Messages: 35
Registered: September 2013
Member
Hi Ronan, Ed,

A field in my model is a property, an attribute, ... an element of my model which is TEXTUAL, and the parser objective is to convert this part of text into model element define in my model itself.

I choose ANTLR because I know it and it was the best way to define a parser from text.

Before deciding to change from ANTLR to XTEXT, I would be assured it can solve my problem...

So can I find somewhere an example of a link between XTEXT and ATL transformation?
And a tutorial for XTEXT => to be able to convert text to model...
Is it the same link possible between XTEXT and QVT? (because I can do the same transformation with QVT-o...)
Because if I have to redesign all my application, I hope to consider all techno!

I tried to explain the best I can my problem, and I don't find how to redesign it to break the loop...

EMF PROJECT ANTLR, XTEXT, ... project
-------------------- --------------------------
| model def | | <textfield> |
| | | || |
| elemX def | | \/ |
| with <textfield> | => | other elem object |
| & | | conform to EMF project |
| other elem def | | EXTERN PARSER |
-------------------- --------------------------
||
\/
ATL (...or QVT)
---------------------------
| the goal is to |
| convert model |
| |
| taking account |
| <texfield> is |
| is not text after ANTLR |
---------------------------

My problem is :
as ATL doesn't know JAVA, I must have EOperation in my model !
but this is why I have a cycle...
and the only needs for the EOperation is ATL request to access <textfield> converted.

Re: ATL and JAVA code calling (alternative QVT...) [message #1209831 is a reply to message #1209677] Mon, 25 November 2013 18:25 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Xtext is orthogonal to MtoM tools.

Xtext just provides an alternative and often better way of preparing
your models using a textual user interface.

MtoM tools transform them. They should not care how they were prepared.

Regards

Ed Willink


On 25/11/2013 16:46, cyril dufrechou wrote:
> Hi Ronan, Ed,
>
> A field in my model is a property, an attribute, ... an element of my
> model which is TEXTUAL, and the parser objective is to convert this
> part of text into model element define in my model itself.
>
> I choose ANTLR because I know it and it was the best way to define a
> parser from text.
>
> Before deciding to change from ANTLR to XTEXT, I would be assured it
> can solve my problem...
>
> So can I find somewhere an example of a link between XTEXT and ATL
> transformation?
> And a tutorial for XTEXT => to be able to convert text to model...
> Is it the same link possible between XTEXT and QVT? (because I can do
> the same transformation with QVT-o...)
> Because if I have to redesign all my application, I hope to consider
> all techno!
>
> I tried to explain the best I can my problem, and I don't find how to
> redesign it to break the loop...
>
> EMF PROJECT ANTLR, XTEXT, ... project
> -------------------- --------------------------
> | model def | | <textfield> |
> | | | || |
> | elemX def | | \/ |
> | with <textfield> | => | other elem object |
> | & | | conform to EMF project |
> | other elem def | | EXTERN PARSER |
> -------------------- --------------------------
> ||
> \/
> ATL (...or QVT)
> --------------------------- | the goal is to | |
> convert model |
> | |
> | taking account |
> | <texfield> is |
> | is not text after ANTLR |
> ---------------------------
> My problem is : as ATL doesn't know JAVA, I must have EOperation in my
> model !
> but this is why I have a cycle...
> and the only needs for the EOperation is ATL request to access
> <textfield> converted.
>
>
Re: ATL and JAVA code calling (alternative QVT...) [message #1211209 is a reply to message #1209831] Tue, 26 November 2013 10:12 Go to previous messageGo to next message
cyril dufrechou is currently offline cyril dufrechouFriend
Messages: 35
Registered: September 2013
Member
Thanks for your answers,
In fact if I understand that I need is a T2M tool (text to model...)
Is it one of XTEXT goal?
Regards
Re: ATL and JAVA code calling (alternative QVT...) [message #1211445 is a reply to message #1211209] Tue, 26 November 2013 12:43 Go to previous message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
XText is a tool which allows you to seperate a textual concrete syntax from the model which represents the data structures. So it will look after parsing your text into a model instance that is compliant to your Ecore Meta-Model. You can then use whatever Eclipse based transformation langauge to transform your model to something else.

You can still use ANTLR if you like but I like XText. Regardless I still don't see why you can't fix your dependency cycle. I have many Ecore eOperations which I run the code generator off and then implemented the method to use classes in other projects without any problems.
Regards,
Ronan
Previous Topic:Type filtering
Next Topic:[EMFTVM] null pointer exception when executing transformation
Goto Forum:
  


Current Time: Fri Apr 19 14:27:59 GMT 2024

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

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

Back to the top