如何在Java中以编程方式合并EMF模型? [英] How to merge EMF models programmatically in Java?
本文介绍了如何在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模型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文