Invoke QVT In JAVA [message #726033] |
Fri, 16 September 2011 08:55  |
Eclipse User |
|
|
|
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 #727121 is a reply to message #726624] |
Tue, 20 September 2011 09:05   |
Eclipse User |
|
|
|
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 09:59   |
Eclipse User |
|
|
|
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 #815685 is a reply to message #729185] |
Wed, 07 March 2012 18:50   |
Eclipse User |
|
|
|
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] |
Wed, 07 March 2012 21:54   |
Eclipse User |
|
|
|
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 -_-
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06885 seconds