本文介绍了如何在Java中以编程方式合并EMF模型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种方法可以用Java以编程方式在单个Ecore模型中组合多个Ecore模型(2个或更多)?所有模型都遵循相同的元模型.
Is there a way to combine multiple Ecore models (2 or more) in a single Ecore model programmatically in Java? With all models conform to the same metamodel.
在:
Model1 conforming to metamodelX Model2 conforming to metamodelX model3 conforming to metamodelX model4 conforming to metamodelX model5 conforming to metamodelX出局:
modelOut conforming to metamodelX and merge of Model1, Model2, model3, model4, model5 ...推荐答案
有一个用于处理EMF比较和合并的Eclipse项目,称为EMF Compare.
There is Eclipse project for handling EMF comparing and Merging, called EMF Compare.
以下是他们提供的示例:
Here is example provided by them:
// Loading models EObject model1 = ModelUtils.load(model1, resourceSet); EObject model2 = ModelUtils.load(model2, resourceSet); // Matching model elements MatchModel match = MatchService.doMatch(model1, model2, Collections.<String, Object> emptyMap()); // Computing differences DiffModel diff = DiffService.doDiff(match, false); // Merges all differences from model1 to model2 List<DiffElement> differences = new ArrayList<DiffElement>(diff.getOwnedElements()); MergeService.merge(differences, true);这确实提供了很好的方法来处理模型合并和其他比较工作.您也可以手动进行更改.
This really provides very good ways to handle model merging and other compare stuffs. You can also manually go through the changes.
以下是他们提供的完整示例:此处
Here is full example provided by them: Here
更多推荐
如何在Java中以编程方式合并EMF模型?
发布评论