Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Merging model files before running XPand
Merging model files before running XPand [message #57170] Mon, 13 July 2009 02:35 Go to next message
Eclipse UserFriend
For maintainablitity reasons I have split the model (based on my TMF Xtext
DSL) over multiple files. Now I want to run xpand using the workflow, but
when I enter all the models separatly in the workflow, each model file is
parsed separatly. Is there a way to configure the workflow in such a way
that all the model files are merged together as one large model?
Re: Merging model files before running XPand [message #57839 is a reply to message #57170] Mon, 13 July 2009 14:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi Peter,

with one large model, you mean a list of all root elements of all
resources? There is some functionality in EcoreUtil doing what you're
looking for.

Unfortunately, there's no out-of-the-box support as of now, so you'll
have to write a very small workflow component doing the conversion.

In order to so so you should subclass 'AbstractWorkflowComponent' and
implement internalInvoke(). There you can grab the small model out of
the WorkflowContext, collect everything you need in a list, and put it
back into the WorkflowContext so that it is available by following
workflow components.

Sven


Peter schrieb:
> For maintainablitity reasons I have split the model (based on my TMF
> Xtext DSL) over multiple files. Now I want to run xpand using the
> workflow, but when I enter all the models separatly in the workflow,
> each model file is parsed separatly. Is there a way to configure the
> workflow in such a way that all the model files are merged together as
> one large model?
>
Re: Merging model files before running XPand [message #60860 is a reply to message #57839] Sun, 19 July 2009 10:49 Go to previous messageGo to next message
Eclipse UserFriend
Creating my own Workflow component is easy. But how do I merge two models?
I can iterate the models, but I can't figure out how to add objects from
one model to another.
Re: Merging model files before running XPand [message #61578 is a reply to message #60860] Mon, 20 July 2009 13:47 Go to previous messageGo to next message
Eclipse UserFriend
I wouldn't change the models, but collect the rrot elements in a list.
Don't know if that would that be ok in your case?

Cheers,
Sven

Peter Baars schrieb:
> Creating my own Workflow component is easy. But how do I merge two
> models? I can iterate the models, but I can't figure out how to add
> objects from one model to another.
>


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Merging model files before running XPand [message #61620 is a reply to message #61578] Mon, 20 July 2009 15:29 Go to previous message
Eclipse UserFriend
This is the code I came up with myself. My model consist out of entities,
services and datalist. This Workflow component is called after each
MweReader. After all models are merged, the Generators are executed.

It works Ok, but I'm not sure if I will get in to trouble later, because
I'm not sure if the model is fully loaded correctly. Uptil now it works ok.

Thanx for the help

------------------------------------------------------------ --------------
package workflow;

import org.eclipse.emf.mwe.core.WorkflowContext;
import org.eclipse.emf.mwe.core.issues.Issues;
import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent;
import org.eclipse.emf.mwe.core.monitor.ProgressMonitor;

import poc.model.businessDomain.impl.BusinessDomainModelImpl;

public class MyWorkflowComponent extends AbstractWorkflowComponent {

@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor
monitor, Issues issues) {

System.out.println("my own workflow component");
BusinessDomainModelImpl model = (BusinessDomainModelImpl)
ctx.get("model");

if (model == null) {
return;
}

// Check if there is a model under a temporary key in the context
if (ctx.get("PBA") == null) {
//Set the model under a temporary key in the context
ctx.set("PBA", model);
} else {

//get the termporary stored model
BusinessDomainModelImpl model2 = (BusinessDomainModelImpl)ctx.get("PBA");

//Add items from store model2 to current model
model.getEntities().addAll(model2.getEntities());
model.getServices().addAll(model2.getServices());
model.getDataLists().addAll(model2.getDataLists());
// set the models to the context
ctx.set("PBA", model);
ctx.set("model", model);
}
}

@Override
public void checkConfiguration(Issues issues) {
// TODO Auto-generated method stub
}

}
Previous Topic:[Xtext] Bidirectional properties handled incorrectly?
Next Topic:Example for linking to imported objects?
Goto Forum:
  


Current Time: Fri May 23 15:33:32 EDT 2025

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

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

Back to the top