Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Invoke QVT In JAVA  () 1 Vote
Invoke QVT In JAVA [message #726033] Fri, 16 September 2011 12:55 Go to next message
Cindy  is currently offline Cindy Friend
Messages: 59
Registered: May 2011
Member
My code are as follows:
/******************************************************************************/
//transformationURI is the URI of qvto file
TransformationExecutor executor = new TransformationExecutor(transformationURI);

//inResource have the vaule of inModel
ModelExtent input = new BasicModelExtent(inResource.getContents());
ModelExtent output = new BasicModelExtent();

ExecutionContextImpl context = new ExecutionContextImpl();

ExecutionDiagnostic diagnostic = executor.execute(context, input, output);

/******************************************************************************/
My problem is that executor.execute(context, input, output) only succeeds occasionally when i can get the right value in output; but most of the time when i call System.out.println(output.getContents().toString()); i only get empty ie [] ...
does anybody know where the problem would be? waiting on line for solution:-)
Thanks
Re: Invoke QVT In JAVA [message #726060 is a reply to message #726033] Fri, 16 September 2011 13:42 Go to previous messageGo to next message
Cindy  is currently offline Cindy Friend
Messages: 59
Registered: May 2011
Member
Since sometimes i could get the right output so i guess the problems doesnot lie in the code.. am i right?
Re: Invoke QVT In JAVA [message #726392 is a reply to message #726060] Sat, 17 September 2011 20:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Philipp Kalb

Hi Cindy

Maybe our problem is related. I posted a topic called "[QVT]
undeterministic behaviour..." some days ago.

Ed Willink suggested (to sum it up...) to test everything again and if
the error occurs (again) create a bugzilla report.
I will do this as soon as I have some time left.

It sounds like a stupid trick but we called the transformation in a loop
and check the result. If it is bad we transform everything again, if it
looks OK we take it :). I hope this helps you a little bit.

cheers
Philipp


Am 16.09.2011 15:42, schrieb Cindy:
> Since sometimes i could get the right output so i guess the problems
> doesnot lie in the code.. am i right?
Re: Invoke QVT In JAVA [message #726527 is a reply to message #726392] Sun, 18 September 2011 13:54 Go to previous messageGo to next message
Cindy  is currently offline Cindy Friend
Messages: 59
Registered: May 2011
Member
hey thank you for your answer:-) do you think is there any possibility that the version conflict cause this problem?
Re: Invoke QVT In JAVA [message #726620 is a reply to message #726392] Mon, 19 September 2011 03:12 Go to previous messageGo to next message
Cindy  is currently offline Cindy Friend
Messages: 59
Registered: May 2011
Member
While i donot know, but i find something weird. when i run a new instance of eclipse , i could only succeed the second time i push "begin to transform" action(where i realized this action to invoke qvt by jave code)..the first time always failed and after the second time too..

does anybody know what this could be?
Re: Invoke QVT In JAVA [message #726624 is a reply to message #726620] Mon, 19 September 2011 03:33 Go to previous messageGo to next message
Cindy  is currently offline Cindy Friend
Messages: 59
Registered: May 2011
Member
Hey i got the solution~~ by changing the position of EPackage.Registry.INSTANCE.put().. actually i put this in the transform.java file where i write the ExecutionDiagnostic diagnostic = executor.execute(context, input, output);code
now i change this to Activator.java where i extends AbstractUIPlugin..
so i guess this EPackage.Registry.INSTANCE.put() could be only done once..
Re: Invoke QVT In JAVA [message #727121 is a reply to message #726624] Tue, 20 September 2011 13:05 Go to previous messageGo to next message
Philipp Zech is currently offline Philipp ZechFriend
Messages: 96
Registered: July 2009
Member
On 09/19/2011 05:33 AM, Cindy wrote:
> Hey i got the solution~~ by changing the position of
> EPackage.Registry.INSTANCE.put().. actually i put this in the
> transform.java file where i write the ExecutionDiagnostic diagnostic =
> executor.execute(context, input, output);code
> now i change this to Activator.java where i extends AbstractUIPlugin..
> so i guess this EPackage.Registry.INSTANCE.put() could be only done once..
Hi,

to join this discussion about possible QvT bugs in combination with
programmatic execution in JAVA, I've developed a transformation and
running it standalone in eclipse via "Run as..." works seamlessly,
however, as soon as the transformation is embedded inside an eclipse
plug-in, somehow only half of the transformation is done, however, I get
no exception or anything else. Could this be another possible bug in QvT?

Cheers,

Philipp
Re: Invoke QVT In JAVA [message #727145 is a reply to message #727121] Tue, 20 September 2011 13:59 Go to previous messageGo to next message
Philipp Zech is currently offline Philipp ZechFriend
Messages: 96
Registered: July 2009
Member
On 09/20/2011 03:05 PM, Philipp Zech wrote:
> On 09/19/2011 05:33 AM, Cindy wrote:
>> Hey i got the solution~~ by changing the position of
>> EPackage.Registry.INSTANCE.put().. actually i put this in the
>> transform.java file where i write the ExecutionDiagnostic diagnostic =
>> executor.execute(context, input, output);code
>> now i change this to Activator.java where i extends AbstractUIPlugin..
>> so i guess this EPackage.Registry.INSTANCE.put() could be only done
>> once..
> Hi,
>
> to join this discussion about possible QvT bugs in combination with
> programmatic execution in JAVA, I've developed a transformation and
> running it standalone in eclipse via "Run as..." works seamlessly,
> however, as soon as the transformation is embedded inside an eclipse
> plug-in, somehow only half of the transformation is done, however, I get
> no exception or anything else. Could this be another possible bug in QvT?
>
> Cheers,
>
> Philipp
hi,

sorry for inconveniences, simply forgot a deepclone in my code.

cheers,

philipp
Re: Invoke QVT In JAVA [message #727806 is a reply to message #727145] Thu, 22 September 2011 01:56 Go to previous messageGo to next message
Cindy  is currently offline Cindy Friend
Messages: 59
Registered: May 2011
Member
Thank you for your attention anyway:-) hope your work goes well~~
Re: Invoke QVT In JAVA [message #729185 is a reply to message #726392] Sun, 25 September 2011 10:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Philipp Kalb

Hi,

Just for your information:
I have now created a bugzilla report for my problem. Since I think that
it is similar to yours I mentioned that in the bugreport.
Here is a link:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=358814

Maybe if you have some more information you could add that to the report :-)

Best wishes
Philipp


Am 17.09.2011 22:00, schrieb Philipp Kalb:
> Hi Cindy
>
> Maybe our problem is related. I posted a topic called "[QVT]
> undeterministic behaviour..." some days ago.
>
> Ed Willink suggested (to sum it up...) to test everything again and if
> the error occurs (again) create a bugzilla report.
> I will do this as soon as I have some time left.
>
> It sounds like a stupid trick but we called the transformation in a loop
> and check the result. If it is bad we transform everything again, if it
> looks OK we take it :). I hope this helps you a little bit.
>
> cheers
> Philipp
>
>
> Am 16.09.2011 15:42, schrieb Cindy:
>> Since sometimes i could get the right output so i guess the problems
>> doesnot lie in the code.. am i right?
>
Re: Invoke QVT In JAVA [message #815685 is a reply to message #729185] Wed, 07 March 2012 23:50 Go to previous messageGo to next message
chadi assem is currently offline chadi assemFriend
Messages: 26
Registered: March 2012
Junior Member
Hi,I am new here and I have a similar problem:

code:
Diagnostic diag = executor.loadTransformation();
//EPackage.Registry.INSTANCE.put(ABCPackage.eNS_URI, ABCPackage.eINSTANCE);
//Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("abc", new XMIResourceFactoryImpl());
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(ABCPackage.eNS_URI, ABCPackage.eINSTANCE);
Resource inResource = resourceSet.getResource(inputFileURI, true);
ModelExtent input = new BasicModelExtent(inResource.getContents());
ModelExtent output = new BasicModelExtent();
ExecutionContextImpl context = new ExecutionContextImpl();
context.setConfigProperty("keepModeling", true);
ExecutionDiagnostic result = executor.execute(context, input, output);
**********************************************************************************
when I call System.out.println(output.getContents().toString());
System.out.println(result.toString());
i get
[]
Diagnostic ERROR source=org.eclipse.m2m.qvt.oml.execution code=130 Compilation errors found in unit 'file:/D:/workspace/org.emf.transformation/NewTransformation1.qvto' data=[] [Diagnostic ERROR source=file:/D:/workspace/org.emf.transformation/NewTransformation1.qvto code=0 Failed to resolve metamodel '///ABC.ecore' (at:1) data=[], Diagnostic ERROR source=file:/D:/workspace/org.emf.transformation/NewTransformation1.qvto code=0 Failed to resolve metamodel '[org.eclipse.ocl.cst.impl.SimpleNameCSImpl@d1c778 (startOffset: 19, endOffset: 21, startToken: null, endToken: null, ast: null) (value: ABC, type: identifier)]' (at:1) data=[], ...............
................................................
................................................

Any idea? I'm stuck with this error -_-
Re: Invoke QVT In JAVA [message #815777 is a reply to message #815685] Thu, 08 March 2012 02:54 Go to previous messageGo to next message
Alan McMorran is currently offline Alan McMorranFriend
Messages: 55
Registered: July 2009
Member
Sohaib,

Could you posted the first few lines of the transform? What I'm
guesing is that you have your meta-models specified explicitly as
references to the ecore. I've found that when running the transform
using the ExecutionDiagnostic you need to reference them by their URI.

e.g. If your ABCPackage.eNS_URI = http://example.com/model

Then your transform would have:

modeltype ABC "strict" uses 'http://example.com/model';

rather than an explicit reference to the ecore. The QVTO compliler
will then find the correct EPackage from the registry when it compiles
the transform.

I'm also not sure if it work successfully on transforms with an
explicit file URI, I think I remember finding that I had to use a
platform URI, so if you're running this as a JUnit plugin test for
example you'd have:
platform:/plugin/org.emf.transformation/NewTransformation1.qvto

As the workspace project will become a plugin at execution. If you're
referring to a workspace QVTO it would be:
platform:/resource/org.emf.transformation/NewTransformation1.qvto

Alan

On 2012-03-07 23:50:37 +0000, sohaib soso said:

> Hi,I am new here and I have a similar problem:
> code: Diagnostic diag = executor.loadTransformation();
> //EPackage.Registry.INSTANCE.put(ABCPackage.eNS_URI,
> ABCPackage.eINSTANCE);
> //Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("abc",
> new XMIResourceFactoryImpl());
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getPackageRegistry().put(ABCPackage.eNS_URI,
> ABCPackage.eINSTANCE);
> Resource inResource = resourceSet.getResource(inputFileURI, true);
> ModelExtent input = new BasicModelExtent(inResource.getContents());
> ModelExtent output = new BasicModelExtent();
> ExecutionContextImpl context = new ExecutionContextImpl();
> context.setConfigProperty("keepModeling", true);
> ExecutionDiagnostic result = executor.execute(context, input, output);
> **********************************************************************************
when
>
> I call System.out.println(output.getContents().toString());
> System.out.println(result.toString());
> i get []
> Diagnostic ERROR source=org.eclipse.m2m.qvt.oml.execution code=130
> Compilation errors found in unit
> 'file:/D:/workspace/org.emf.transformation/NewTransformation1.qvto'
> data=[] [Diagnostic ERROR
> source=file:/D:/workspace/org.emf.transformation/NewTransformation1.qvto
> code=0 Failed to resolve metamodel '///ABC.ecore' (at:1) data=[],
> Diagnostic ERROR
> source=file:/D:/workspace/org.emf.transformation/NewTransformation1.qvto
> code=0 Failed to resolve metamodel
> '[mailto:org.eclipse.ocl.cst.impl.SimpleNameCSImpl@d1c778 (startOffset:
> 19, endOffset: 21, startToken: null, endToken: null, ast: null) (value:
> ABC, type: identifier)]' (at:1) data=[], ...............
> ...............................................
> ...............................................
>
> Any idea? I'm stuck with this error -_-
Re: Invoke QVT In JAVA [message #816305 is a reply to message #815777] Thu, 08 March 2012 17:19 Go to previous messageGo to next message
chadi assem is currently offline chadi assemFriend
Messages: 26
Registered: March 2012
Junior Member
Hi Alan,

Thanks for your reply,

here are the 3 first lines of my trivial transformation:

modeltype ABC "strict" uses "h t t p:///ABC.ecore";
transformation HelloWorld(in source:ABC, out target:ABC);

when I use a platform URI :platform:/resource/org.emf.transformation/NewTransformation1.qvto I get:

Could not find unit 'platform:/resource/org.emf.transformation/NewTransformation1.qvto'
Did i miss something?
Re: Invoke QVT In JAVA [message #816342 is a reply to message #816305] Thu, 08 March 2012 18:33 Go to previous messageGo to next message
Alan McMorran is currently offline Alan McMorranFriend
Messages: 55
Registered: July 2009
Member
> Thanks for your reply,
> here are the 3 first lines of my trivial transformation:
>
> modeltype ABC "strict" uses "http:///ABC.ecore";

As I expected, I think you need to refer to the model by its namespace
URI not the ecore. What is the namespace of the ecore model itself?

> transformation HelloWorld(in source:ABC, out target:ABC);
> when I use a platform URI
> :platform:/resource/org.emf.transformation/NewTransformation1.qvto I
> get:
>
> Could not find unit
> 'platform:/resource/org.emf.transformation/NewTransformation1.qvto'
> Did i miss something?

How are you running this? If it starts up an OSGi runtime then your
current workspace is no longer the running workspace, there will be a
separate one created for the runtime. The chances are your workspace
projects will become runtime plugins so the project
org.emf.transformation wthin your development workspace will become the
plugin org.emf.transformation in the runtime.

How are you executing the code? Is it wrapped in a JUnit test?
IApplication? I it's a Java application with static void main(args[]) I
could not get this to work as too much of QVTO is tied to the OSGI
runtime.

Alan
Re: Invoke QVT In JAVA [message #816480 is a reply to message #816342] Thu, 08 March 2012 22:52 Go to previous messageGo to next message
chadi assem is currently offline chadi assemFriend
Messages: 26
Registered: March 2012
Junior Member
> What is the namespace of the ecore model itself?

"h ttp:///ABC.ecore"

> How are you running this?If it starts up an OSGi runtime then your current
> workspace is no longer the running workspace
> How are you executing the code?

using Java application with static void main

> If it's a Java application with static void main
> (args[]) I could not get this to work as too much of QVTO is tied to the OSGI
> runtime

I see!! so should I use the Eclipse/OSGi runtime and a
platform URI (i.e platform:/plugin/org.emf.transformation/NewTransformation1.qvto)?
Re: Invoke QVT In JAVA [message #816568 is a reply to message #816480] Fri, 09 March 2012 01:46 Go to previous messageGo to next message
Alan McMorran is currently offline Alan McMorranFriend
Messages: 55
Registered: July 2009
Member
On 2012-03-08 22:52:11 +0000, sohaib soso said:

>>
>> What is the namespace of the ecore model itself?
>
> "h ttp:///ABC.ecore"

Okay, I tend to go with something like http://example.com/my/model/ABC
(where the domain is usually something you own) but that will probably
still work if it's registered in the EPackage registry

>
>> How are you running this?If it starts up an OSGi runtime then your
>> current workspace is no longer the running workspace
>> How are you executing the code?
>
> using Java application with static void main
>> If it's a Java application with static void main (args[]) I could not
>> get this to work as too much of QVTO is tied to the OSGI runtime
>
> I see!! so should I use the Eclipse/OSGi runtime and a platform URI
> (i.e platform:/plugin/org.emf.transformation/NewTransformation1.qvto)?

Yes
Re: Invoke QVT In JAVA [message #824983 is a reply to message #816568] Tue, 20 March 2012 10:19 Go to previous messageGo to next message
Harald Mitzi is currently offline Harald MitziFriend
Messages: 1
Registered: March 2012
Junior Member
Hey sohaib, could you solve that issue? because I'm faced with the same problem.
Re: Invoke QVT In JAVA [message #833046 is a reply to message #824983] Fri, 30 March 2012 22:35 Go to previous message
chadi assem is currently offline chadi assemFriend
Messages: 26
Registered: March 2012
Junior Member
hi Harald,

I havn't been here for a while now. I think the Evil or Very Mad trick wich cost me too much time to solve that issue was running the qvt invocation code within a "public static void main" class (launch as java application), but tnx to Alan I used OSGI platform instead and it works Cool
Previous Topic:[Solved][ATL] problem running ATL programmatically
Next Topic:[ATL] Generating an EChar during transformation
Goto Forum:
  


Current Time: Sat Dec 20 08:52:06 GMT 2014

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

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