0

有 2 个基于相同元模型的模型。我可以使用EMF 比较来接收差异模型。就我而言,一种模型是新模型的旧版本。

a) 我如何接收变更模型,描述从旧模型到新模型的变化?

b) 如果这不是默认 EMF 更改模型的实例,是否可以创建一个命令在旧模型上执行这些更改?

由于各种原因,我不想替换 EObject 元素。使用 EMF 比较不是强制性的。

4

1 回答 1

1

I also answered you on the Eclipse forum, but for stack overflow users that might stumble upon this question, here was my answer :

  • Using EMF Compare 1.3

    You will need to call the diff process programmatically (MatchService.match then DiffService.diff) to retrieve the DiffModel. After that, you can apply all these diffs from within your own command (encapsulate the call to MergeService.merge within a RecordingCommand). From there, you can merge all diffs from a command and retrieve the corresponding ChangeModel if you need it (we have no conversion from DiffModel to ChangeModel). This is cumbersome, but do-able if you are in a context where you can merge (nothing prevents you from undoing the command afterwards if you only needed the ChangeModel). Probably the safest way until we finish cooking EMF Compare 2.0.

  • Using EMF Compare 2

    EMF Compare 2 is currently in its development phase, and though merging is not yet done within commands, it is our goal with this version. However, you can obtain the ChangeModel more easily with this new version. What you need is to create your own IDiffProcessor and use it to instantiate the DefaultDiffEngine. The Diff Processor will be notified whenever we detect a difference on references or attributes. You can then create the corresponding ChangeModel.

于 2012-08-22T08:24:37.503 回答