Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] Running a QVT transformation from a program
[QVTo] Running a QVT transformation from a program [message #641437] Thu, 25 November 2010 13:16 Go to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
Hi,

I'm building a eclipse plugin for transformations of UML models. What I'd like to do is to provide a menu entry in the context menu of a model (via right-clicking) and selecting a transformation. In some cases I'd like to provide the user with the option of sending a parameter (maybe string) as well, do you know how I would import these parameters in the QVT file?
Re: [QVTo] Running a QVT transformation from a program [message #641493 is a reply to message #641437] Thu, 25 November 2010 16:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: koen.yskout.cs.kuleuven.be

See http://wiki.eclipse.org/QVTOML/Examples/InvokeInJava to invoke a
transformation directly from Java.

For parameters, I think (not sure) you can use the context properties
(like 'keepModeling' in the example), and retrieve those in your QVT
file. Alternatively, you can always create a separate model that
represents your configuration/parameters, and add that as a second input
to your transformation.

Kind regards,

Koen


On 25/11/10 14:16, Haffi wrote:
> Hi,
>
> I'm building a eclipse plugin for transformations of UML models. What
> I'd like to do is to provide a menu entry in the context menu of a model
> (via right-clicking) and selecting a transformation. In some cases I'd
> like to provide the user with the option of sending a parameter (maybe
> string) as well, do you know how I would import these parameters in the
> QVT file?
Re: [QVTo] Running a QVT transformation from a program [message #642224 is a reply to message #641493] Tue, 30 November 2010 13:02 Go to previous messageGo to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
Hi, thanks for your reply. There's just one thing that I don't understand in the "Invoke In Java" example; the reference to the variable resourceSet without it ever being initialized. The ResourceSet is just an abstract class so I don't know how to initialize it.

[Updated on: Tue, 30 November 2010 13:02]

Report message to a moderator

Re: [QVTo] Running a QVT transformation from a program [message #642226 is a reply to message #642224] Tue, 30 November 2010 13:21 Go to previous messageGo to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
OK, I got rid of this error thanks to Dennis Hendriks, and when I try to run the Tranformation I get the error: "The JAR of this class file belongs to a container "Plugin Depenedencies" which does not allow modifications to source attachements on its entries" when it tries to get the resources. I'm developing this as a plugin and I guess this is not exactly a QVTo related problem but if anyone knows what to do then I'm open to suggestions.
Re: [QVTo] Running a QVT transformation from a program [message #642232 is a reply to message #642224] Tue, 30 November 2010 13:13 Go to previous messageGo to next message
Dennis HendriksFriend
Messages: 74
Registered: January 2010
Location: The Netherlands
Member
Haffi wrote:
> Hi, thanks for your reply. There's just one thing that I don't
> understand in the "Invoke In Java" example; the reference to the
> variable resourceSet without it ever being initialized. The ResourceSet
> is just an abstract class so I don't know how to initialize it.

Resource sets are just basic EMF functionality; nothing QVTo specific.
The example assumes you know EMF.

You can create one like this:

ResourceSet resourceSet = new ResourceSetImpl();

Dennis
Re: [QVTo] Running a QVT transformation from a program [message #642233 is a reply to message #642226] Tue, 30 November 2010 13:54 Go to previous messageGo to next message
Dennis HendriksFriend
Messages: 74
Registered: January 2010
Location: The Netherlands
Member
Haffi wrote:
> OK, I got rid of this error thanks to Dennis Hendriks, and when I try to
> run the Tranformation I get the error: "The JAR of this class file
> belongs to a container "Plugin Depenedencies" which does not allow
> modifications to source attachements on its entries" when it tries to
> get the resources. I'm developing this as a plugin and I guess this is
> not exactly a QVTo related problem but if anyone knows what to do then
> I'm open to suggestions.

It kind of sounds like you're trying to modify a class file's sources,
while the class file is a plug-in dependency of your project. This class
file is then probably a class from EMF or QVTo or something like that.
In that case, it wouldn't make sense to modify that code, only your own
code. I also would not expect this when running the transformation, but
maybe you have some kind of autosave on run feature turned on?

You could try to debug, stepping through your code, trying to find out
where things go wrong.

If this doesn't help, then I think we need to see more of your code to
better answer your question.

Dennis
Re: [QVTo] Running a QVT transformation from a program [message #642238 is a reply to message #642233] Tue, 30 November 2010 14:07 Go to previous messageGo to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
This is the code below. It's just like the code from the TransformationExecutor example, except that I added the initialization of the resourceSet variable. The line that fails is the one where it tries to create the inResource from a URI. The error I mentioned earlier about the JAR file might just be something the debugger gives me and I noticed later that a get an exception which reads:
!ENTRY org.eclipse.ui 4 0 2010-11-30 13:51:43.662
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.net.MalformedURLException: Unsupported "platform:" protocol variation "resources".[...]


	public void run(IAction action) {
		URI transformationURI = URI.createURI("platform:/resources/is.hi.cs.umlrefactoring.core.transformations/transforms/ClassDiagram/RenameClass.qvto");
		TransformationExecutor executor = new TransformationExecutor(transformationURI);

		// define the transformation input
		// Remark: we take the objects from a resource, however
		// a list of arbitrary in-memory EObjects may be passed
		ResourceSetImpl resourceSet = new ResourceSetImpl();
		Resource inResource = resourceSet.getResource(URI.createURI("platform:/resources/QVTTESTS/test.uml"), true);		
		EList<EObject> inObjects = inResource.getContents();

		// create the input extent with its initial contents
		ModelExtent input = new BasicModelExtent(inObjects);		
		// create an empty extent to catch the output
		ModelExtent output = new BasicModelExtent();
		[...]
Re: [QVTo] Running a QVT transformation from a program [message #642251 is a reply to message #642238] Tue, 30 November 2010 15:29 Go to previous messageGo to next message
Dennis HendriksFriend
Messages: 74
Registered: January 2010
Location: The Netherlands
Member
It's platform:/resource/... not platform:/resources/...

Dennis

Haffi wrote:
> This is the code below. It's just like the code from the
> TransformationExecutor example, except that I added the initialization
> of the resourceSet variable. The line that fails is the one where it
> tries to create the inResource from a URI. The error I mentioned earlier
> about the JAR file might just be something the debugger gives me and I
> noticed later that a get an exception which reads: !ENTRY org.eclipse.ui
> 4 0 2010-11-30 13:51:43.662
> !MESSAGE Unhandled event loop exception
> !STACK 0
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1Diagnos ticWrappedException:
> java.net.MalformedURLException: Unsupported "platform:" protocol
> variation "resources".[...]
>
> public void run(IAction action) {
> URI transformationURI =
> URI.createURI(" platform:/resources/is.hi.cs.umlrefactoring.core.transformat ions/transforms/ClassDiagram/RenameClass.qvto ");
>
> TransformationExecutor executor = new
> TransformationExecutor(transformationURI);
>
> // define the transformation input
> // Remark: we take the objects from a resource, however
> // a list of arbitrary in-memory EObjects may be passed
> ResourceSetImpl resourceSet = new ResourceSetImpl();
> Resource inResource =
> resourceSet.getResource(URI.createURI("platform:/resources/QVTTESTS/test.uml "),
> true);
> EList<EObject> inObjects = inResource.getContents();
>
> // create the input extent with its initial contents
> ModelExtent input = new BasicModelExtent(inObjects);
> // create an empty extent to catch the output
> ModelExtent output = new BasicModelExtent();
> [...]
>
Re: [QVTo] Running a QVT transformation from a program [message #642252 is a reply to message #642251] Tue, 30 November 2010 15:41 Go to previous message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
Oops, my bad. I just didn't notice that. I have fixed this in the "Invoke in Java" wiki so this shouldn't happen to other people who won't notice the error.
Previous Topic:[QVTo] Errors importing a blackbox library
Next Topic:refining mode programmatically
Goto Forum:
  


Current Time: Fri Apr 19 19:51:21 GMT 2024

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

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

Back to the top