Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » openArchitectureWare » Executing a workflow (MWE) using a Model.xmi which is not part of a resource
Executing a workflow (MWE) using a Model.xmi which is not part of a resource [message #973729] Tue, 06 November 2012 10:23 Go to next message
vikas yadav is currently offline vikas yadav
Messages: 3
Registered: November 2012
Junior Member
I am trying to execute a workflow using a standalone JAVA program. I want it to dynamically pick up a Model.xmi and generate code based on templates and workflows defined in my plug-in.

However, the only example I found using the following code:

StandaloneSetup setup = new StandaloneSetup();
setup.setPlatformUri("D:/workspace/experimental/");
Reader reader = new Reader();
reader.setModelSlot("model");
reader.setUri("platform:/resource/<<project name>>/src/Model.xmi");
WorkflowContext ctx = new WorkflowContextDefaultImpl();
reader.invoke(ctx, new NullProgressMonitor(), new IssuesImpl());
Map<String, Object> slotContents = new HashMap<String, Object>();
slotContents.put("model", ctx.get("model"));
Map<String, String> properties = new HashMap<String, String>();

String wfFile = "D:/src/workflow/generateAll.mwe";
new WorkflowRunner().run(wfFile, new NullProgressMonitor(), properties,
slotContents);

With this I understand that Model.xmi should always be part of some resource. Is it possible for me to read a standalone Model.xmi and execute my workflow?
Re: Executing a workflow (MWE) using a Model.xmi which is not part of a resource [message #976051 is a reply to message #973729] Thu, 08 November 2012 04:23 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

You can instantiate an EMF model dynamically in your code and register it in the WorkflowContext. It is not required that the EMF model is within a resource.

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Executing a workflow (MWE) using a Model.xmi which is not part of a resource [message #976589 is a reply to message #976051] Thu, 08 November 2012 12:49 Go to previous messageGo to next message
vikas yadav is currently offline vikas yadav
Messages: 3
Registered: November 2012
Junior Member
I believe you are suggesting me to do this -

// Register the meta-model for this model with the package registry
for (String k : (Set<String>) resourceSet.getPackageRegistry().keySet())
EPackage.Registry.INSTANCE.put(k, resourceSet.getPackageRegistry().get(k));

But the problem is that I am unable to read the resource itself when I am opening an instance of Eclipse in PDE -
// Load the model
ResourceSet resourceSet = new ResourceSetImpl();
final String uri = text_modelResourcePath.getText();
Resource res = resourceSet.getResource(URI.createURI(uri), true);

It fails with an exception that the resource is not found. So, I have two parts to it -
1. Even though I am specifying a valid workspace (not the one in the current eclipse instance),
StandaloneSetup setup = new StandaloneSetup();
setup.setPlatformUri("D:/workspace/experimental/");
Why does it fail to pick up the Model.xmi (resource).
2. Why can't I just specify a Model.xmi which is not part of any workspace and have the workflow working?

It would be very helpful if you can give me some code snippet that I can use to read any Model.xmi and have the workflow (MWE) run against that Model to generate code based on my XPAND templates.
Re: Executing a workflow (MWE) using a Model.xmi which is not part of a resource [message #986833 is a reply to message #976589] Wed, 21 November 2012 15:46 Go to previous message
Bhanu Pratap is currently offline Bhanu Pratap
Messages: 13
Registered: April 2010
Junior Member
Hi

I am also having the same problem. Here is my scenario:

I have a xpand based generator which generates some Prolog code for a Model. So far I manually run the workflow by Run As-> MWE Workflow. Now I want to deploy this project as plugin/feature such that a user right clicks on .xmi or .ecore files and invokes this prolog code generator i.e. Xpand workflow file.

So, I need to invoke this workflow file programmatically from my UI plugin's context Menu Action class.

This problem sounds very similar to the one you are having. Did you solve it? If so, please share solution.

Thanks in advance.
Previous Topic:OAW exception
Next Topic:Workflow doesn't read the model
Goto Forum:
  


Current Time: Wed Aug 20 20:25:44 EDT 2014

Powered by FUDForum. Page generated in 0.01980 seconds