Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to run an MWE2 workflow from Java
How to run an MWE2 workflow from Java [message #882888] Thu, 07 June 2012 12:11 Go to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi,

we have an MWE2 workflow which we run from a launch configuration under eclipse. So far so good.

Now we want to run it from a Java class. Previously with MWE we used the class WorkflowEngine to run the workflow. What should we replace this class by? Is there an example we can follow? We also need to get access to the Issues for the output.

We are looking for any tips and/or links on how to do this.

Thanks

Andy

[Updated on: Thu, 07 June 2012 12:11]

Report message to a moderator

Re: How to run an MWE2 workflow from Java [message #882896 is a reply to message #882888] Thu, 07 June 2012 12:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

have a look at
org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher

~Christian
Re: How to run an MWE2 workflow from Java [message #883222 is a reply to message #882896] Fri, 08 June 2012 04:42 Go to previous messageGo to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Chris,

thanks for the tip. It looks close to what I need. I found the run method but how can I get the errors from running the workflow? In MWE there was a class called Issues which enabled me to extract the output from running the workflow. I cannot find this in MWE2.

Thanks

Andy
Re: How to run an MWE2 workflow from Java [message #883246 is a reply to message #883222] Fri, 08 June 2012 06:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

Mwe2 is not a full / 1:1 replacement of mwe.
Mwe2 has no Isse Support. It only logs them (trough Mwe2Bridge)
feels free to file a bug/enhancementrequest whatever ...

~Christian
Re: How to run an MWE2 workflow from Java [message #883434 is a reply to message #883246] Fri, 08 June 2012 14:21 Go to previous messageGo to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Christian,

OK I get it. We are now running the MWE2 workflow from our Java/Swing application using a launch configuration from the Eclipse workbench. Any errors are returned as exceptions which is fine for now i.e. we can live without the Issues class.

However we have an issue exporting our application as a standalone jar we have a problem specifying the URI to the MWE2 workflow. How to specify a file via a URI which is in a directory in a plugin e.g. x.y.z/mydir/myworkflow.mwe2?

We are not used to using URI's to specify resources inside plugins.

Thanks

Andy
Re: How to run an MWE2 workflow from Java [message #883439 is a reply to message #883434] Fri, 08 June 2012 14:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi I am not quite sure what you want to do? Standalone you have no
plugins
Re: How to run an MWE2 workflow from Java [message #883486 is a reply to message #883439] Fri, 08 June 2012 16:35 Go to previous messageGo to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Mmm I did not think of that. Maybe there is a way of specifying a file in a jar using a URI? If not I only see a solution (hack) using the file system and stroing the file in a known place wrt to the jar. But I would prefer a way of getting it out of the jar however.

With MWE we stored the workflow in the jar and specified its path as "x/y/z/mydir/myworkflow.mwe"

This does not work with MWE2.

Any ideas?
Re: How to run an MWE2 workflow from Java [message #883503 is a reply to message #883486] Fri, 08 June 2012 17:19 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

giving the workflow "by name" instead of "by uri" doesnt work?
Re: How to run an MWE2 workflow from Java [message #893947 is a reply to message #883503] Fri, 06 July 2012 07:23 Go to previous messageGo to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi,

this problem (how to run our Xtend workflow from a standalone Swing application) has become a blocking problem. Please, if anyone can help us we will be grateful!

Here is the code we are using in our Swing appli:

private static String backend =
"/fr/esrf/tango/pogo/generator/PogoDslGeneratorMWE.mwe2";
//========================================================================
//========================================================================
private void runWorkflow(Map<String, String> params) throws DevFailed {
try {
Injector injector = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
Mwe2Runner mweRunner = injector.getInstance(Mwe2Runner.class);
java.net.URL url = getClass().getResource(backend);
System.out.println("url="+url);
URI uri = URI.createURI(url.toString());
System.out.println("uri="+uri);

mweRunner.run(uri, params);
}
catch (Exception e) {
e.printStackTrace();
Except.throw_exception("WORKFLOW_FAILED", e.toString(),
"OAWutils.runWorkflow()");
}
}

When we run from an Eclipse workbench configuration it works. When we run it from an exported jar as a Swing appli we get this exception:


Running Workflow for Code files
url=jar:file:/mntdirect/_users/verdier/org.tango.pogo.jar!/fr/esrf/tango/pogo/generator/PogoDslGeneratorMWE.mwe2
uri=jar:file:/mntdirect/_users/verdier/org.tango.pogo.jar!/fr/esrf/tango/pogo/generator/PogoDslGeneratorMWE.mwe2
java.lang.IllegalArgumentException: Unsupported path : (only folders and archives are supported).
at org.eclipse.xtext.mwe.PathTraverser.findAllResourceUris(PathTraverser.java:46)
at org.eclipse.xtext.mwe.PathTraverser.resolvePathes(PathTraverser.java:33)
at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getPathToUriMap(RuntimeResourceSetInitializer.java:54)
at org.eclipse.xtext.mwe.RuntimeResourceSetInitializer.getInitializedResourceSet(RuntimeResourceSetInitializer.java:72)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.findModule(Mwe2Runner.java:112)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:77)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55)
at org.tango.pogo.pogo_gui.tools.OAWutils.runWorkflow(OAWutils.java:291)
at org.tango.pogo.pogo_gui.tools.OAWutils.generate(OAWutils.java:229)
at org.tango.pogo.pogo_gui.Pogo.generateSourceFiles(Pogo.java:132)
at org.tango.pogo.pogo_gui.Pogo.main(Pogo.java:281)

All help appreciated!

Andy
Re: How to run an MWE2 workflow from Java [message #894020 is a reply to message #893947] Fri, 06 July 2012 12:11 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Hi,

would you provide a simple preproducable example
e.g. a project + an ant script that sticks something together?

~Christian

[Updated on: Fri, 06 July 2012 12:49]

Report message to a moderator

Re: How to run an MWE2 workflow from Java [message #894138 is a reply to message #894020] Fri, 06 July 2012 21:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 6550
Registered: July 2009
Senior Member
Just gave it a try myself. as i already suggested the following works fine for me

package test;

import java.util.HashMap;

import org.eclipse.emf.mwe2.language.Mwe2StandaloneSetup;
import org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner;

import com.google.inject.Injector;

public class Main {
	
	public static void main(String[] args) {
		Injector i = new Mwe2StandaloneSetup().createInjectorAndDoEMFRegistration();
		Mwe2Runner runner = i.getInstance(Mwe2Runner.class);
		runner.run("test.TestModule", new HashMap<String, String>());
	}

}
Re: How to run an MWE2 workflow from Java [message #894285 is a reply to message #894138] Sun, 08 July 2012 05:06 Go to previous messageGo to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Christian,

thanks a lot for your example. We will try it - it looks easy when you do it. We will prepare an example for you if we are still stuck. I am out of town so there will be some delay in getting back to you.

Andy
Re: How to run an MWE2 workflow from Java [message #894289 is a reply to message #894138] Sun, 08 July 2012 05:07 Go to previous messageGo to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
I notice a small difference between your example and ours. We are trying to load the backend file from inside a jar. You have specified a file directly with a relative path. We will try to reproduce your example and then work from there.

Andy
Re: How to run an MWE2 workflow from Java [message #894295 is a reply to message #894138] Sun, 08 July 2012 05:06 Go to previous messageGo to next message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Christian,

thanks a lot for your example. We will try it - it looks easy when you do it. We will prepare an example for you if we are still stuck. I am out of town so there will be some delay in getting back to you.

Andy
Re: How to run an MWE2 workflow from Java [message #894296 is a reply to message #894138] Sun, 08 July 2012 05:07 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
I notice a small difference between your example and ours. We are trying to load the backend file from inside a jar. You have specified a file directly with a relative path. We will try to reproduce your example and then work from there.

Andy
Re: How to run an MWE2 workflow from Java [message #894301 is a reply to message #894138] Sun, 08 July 2012 05:06 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Christian,

thanks a lot for your example. We will try it - it looks easy when you do it. We will prepare an example for you if we are still stuck. I am out of town so there will be some delay in getting back to you.

Andy
Re: How to run an MWE2 workflow from Java [message #894302 is a reply to message #894138] Sun, 08 July 2012 05:07 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
I notice a small difference between your example and ours. We are trying to load the backend file from inside a jar. You have specified a file directly with a relative path. We will try to reproduce your example and then work from there.

Andy
Re: How to run an MWE2 workflow from Java [message #894307 is a reply to message #894138] Sun, 08 July 2012 05:06 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Christian,

thanks a lot for your example. We will try it - it looks easy when you do it. We will prepare an example for you if we are still stuck. I am out of town so there will be some delay in getting back to you.

Andy
Re: How to run an MWE2 workflow from Java [message #894308 is a reply to message #894138] Sun, 08 July 2012 05:07 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
I notice a small difference between your example and ours. We are trying to load the backend file from inside a jar. You have specified a file directly with a relative path. We will try to reproduce your example and then work from there.

Andy
Re: How to run an MWE2 workflow from Java [message #894312 is a reply to message #894138] Sun, 08 July 2012 05:06 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Christian,

thanks a lot for your example. We will try it - it looks easy when you do it. We will prepare an example for you if we are still stuck. I am out of town so there will be some delay in getting back to you.

Andy
Re: How to run an MWE2 workflow from Java [message #894313 is a reply to message #894138] Sun, 08 July 2012 05:07 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
I notice a small difference between your example and ours. We are trying to load the backend file from inside a jar. You have specified a file directly with a relative path. We will try to reproduce your example and then work from there.

Andy
Re: How to run an MWE2 workflow from Java [message #894314 is a reply to message #894138] Sun, 08 July 2012 05:06 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
Hi Christian,

thanks a lot for your example. We will try it - it looks easy when you do it. We will prepare an example for you if we are still stuck. I am out of town so there will be some delay in getting back to you.

Andy
Re: How to run an MWE2 workflow from Java [message #894315 is a reply to message #894138] Sun, 08 July 2012 05:07 Go to previous message
Andy Gotz is currently offline Andy GotzFriend
Messages: 32
Registered: July 2010
Member
I notice a small difference between your example and ours. We are trying to load the backend file from inside a jar. You have specified a file directly with a relative path. We will try to reproduce your example and then work from there.

Andy
Previous Topic:Mixing grammars
Next Topic:Mixing grammars
Goto Forum:
  


Current Time: Sun Dec 21 13:32:07 GMT 2014

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

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