如何在Java中以编程方式合并EMF模型?

编程入门 行业动态 更新时间:2024-10-25 18:25:29
本文介绍了如何在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模型?

本文发布于:2023-11-28 13:26:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642592.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中以   模型   方式   如何在   Java

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!