Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Obtain URI from evaluation environment in RC4
Obtain URI from evaluation environment in RC4 [message #1385848] Wed, 11 June 2014 15:51 Go to next message
Christine Gerpheide is currently offline Christine GerpheideFriend
Messages: 21
Registered: January 2014
Location: Netherlands
Junior Member

Hello,

With Kepler it was possible to obtain the resource URI from the evaluation env as such:

QvtOperationalEvaluationEnv evalEnv = (QvtOperationalEvaluationEnv) getEvaluationEnvironment();
InternalEvaluationEnv internEnv = evalEnv.getAdapter(InternalEvaluationEnv.class);

Module module = internEnv.getCurrentModule().getModule();
URI compiledUri = module.eResource().getURI(); // .qvtox


This no longer works with Luna, since URIs all show up as "qvto:/module.env".

Does anyone know how to get a URI (or anything representing the physical transformation) from the evaluation environment? Specifically I'm working from within a derived QvtGenericVisitorDecorator.

Thank you for any direction,
Chris

Re: Obtain URI from evaluation environment in RC4 [message #1385928 is a reply to message #1385848] Thu, 12 June 2014 09:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5395
Registered: July 2009
Senior Member
Hi Christine

Unhelpful answer: Internal ... is internal so it might change.

Realistically, I don't think it should have changed so please raise a
Bugzilla.

Anything with an AST node will do. Perjhaps your invoking
context/visitor has more to go on. Perhaps
evalEnv.getOperation().eResource().

Regards

Ed Willink

On 11/06/2014 16:51, Christine Gerpheide wrote:
> Hello,
>
> With Kepler it was possible to obtain the resource URI from the
> evaluation env as such:
>
> QvtOperationalEvaluationEnv evalEnv = (QvtOperationalEvaluationEnv)
> getEvaluationEnvironment();
> InternalEvaluationEnv internEnv =
> evalEnv.getAdapter(InternalEvaluationEnv.class);
>
> Module module = internEnv.getCurrentModule().getModule();
> URI compiledUri = module.eResource().getURI(); // .qvtox
>
> This no longer works with Luna, since URIs all show up as
> "qvto:/module.env".
>
> Does anyone know how to get a URI (or anything representing the
> physical transformation) from the evaluation environment? Specifically
> I'm working from within a derived QvtGenericVisitorDecorator.
>
> Thank you for any direction,
> Chris
>
>
Re: Obtain URI from evaluation environment in RC4 [message #1386104 is a reply to message #1385848] Fri, 13 June 2014 12:36 Go to previous message
Sergey Boyko is currently offline Sergey BoykoFriend
Messages: 171
Registered: July 2009
Senior Member
Hi Christine,

Christine Gerpheide wrote on Wed, 11 June 2014 11:51

With Kepler it was possible to obtain the resource URI from the evaluation env as such:

QvtOperationalEvaluationEnv evalEnv = (QvtOperationalEvaluationEnv) getEvaluationEnvironment();
InternalEvaluationEnv internEnv = evalEnv.getAdapter(InternalEvaluationEnv.class);

Module module = internEnv.getCurrentModule().getModule();
URI compiledUri = module.eResource().getURI(); // .qvtox


This no longer works with Luna, since URIs all show up as "qvto:/module.env".


On the runtime the result of the expression 'module.eResource().getURI()' is always "qvto:/module.env" and was not changed between Luna/Kepler/Juno releases.
You probably mixed up it with the JUnit tests execution where 'TransformTests.interpreterSuite()' performs saving of compiled transformation to .qvtox file later loading it and performing the execution of the restored transformation. In JUnit this is done solely for testing purpose.
Anyway it's not correct to utilize internal knowledge that the Module instance is contained by EMF Resource.

Quote:

Does anyone know how to get a URI (or anything representing the physical transformation) from the evaluation environment? Specifically I'm working from within a derived QvtGenericVisitorDecorator.


Try the code below:
InternalEvaluationEnv internEvalEnv = getOperationalEvaluationEnv().getAdapter(InternalEvaluationEnv.class);
Module currentModule = internEvalEnv.getCurrentModule().getModule();
IModuleSourceInfo moduleSource = ASTBindingHelper.getModuleSourceBinding(currentModule);
URI moduleUri = null;
if(moduleSource != null) {
	moduleUri = moduleSource.getSourceURI().appendFragment(currentModule.getName());
}


Note the usage of '.appendFragment()'. This is due to fact that single .qvto source may contain several transformations (see http://git.eclipse.org/c/mmt/org.eclipse.qvto.git/tree/tests/org.eclipse.m2m.tests.qvt.oml/parserTestData/models/bug416584/bug416584.qvto).

Regards,
Sergey.
Previous Topic:How to use QVTo transformation
Next Topic:How to evaluate OCL expression that is part of the input model
Goto Forum:
  


Current Time: Mon Sep 25 13:25:03 GMT 2017

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

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