Search code examples
javaeclipsextextxpandoaw

How to programmatically run an Xpand workflow on a model in a second workbench?


I have an Xtext/Xpand (oAW 4.3, Eclipse 3.4) generator plug-in, which I run together with the editor plug-in in a second workbench. There, I'd like to run Xpand workflows programmatically on the model file I create. If I set the model file using the absolute path of the IFile I have, e.g. with:

String dslFile = file.getLocation().makeAbsolute().toOSString();

Or if I use a file URI retrieved with:

String dslFile = file.getLocationURI().toString();

The file is not found:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Resource '/absolute/path/to/my/existing/dsl.file' does not exist. 
at org.openarchitectureware.xtext.parser.impl.AbstractParserComponent.invokeInternal(AbstractParserComponent.java:55)

To what value should I set the model file attribute (dslFile) in the map I hand to the WorkflowRunner:

Map properties = new HashMap();
properties.put("modelFile", dslFile);

I also tried leaving the properties empty and referencing the model file relative to the workflow file (inside the workflow file), but that yields a FileNotFoundException. Running all of this in a normal app (not in a second workbench) works fine.


Solution

  • I found help at the openArchitectureWare forum. Basically using

    properties.put("modelFile", file.getLocation().makeAbsolute().toOSString());
    

    works, but you need to specify looking it up via URI in the workflow you are calling:

    <component class="org.eclipse.mwe.emf.Reader">
        <uri value='${modelFile}'/>
        <modelSlot value='theModel'/>
    </component>