質問

Having 2 models based on the same metamodel. I could use EMF Compare to receive a Diff Model. In my case, one model is the old version of the new one.

a) How do I receive a change model, describing the changes from the old to the new one?

b) If this isn't an instance of the default EMF Change Model, is it possible to create a Command executing these changes on the the old model?

I don't want to replace the EObject elements for various reasons. Using EMF Compare is not mandatory.

役に立ちましたか?

解決

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top