|Programmatically "merge without deletions" [message #1393101]
||Thu, 03 July 2014 08:35
| Cioran Naroic
Registered: December 2013
I would like to use EMF/Compare programmatically to "merge" two models (in my case, Ecore models). By "merge", I mean actually adding (or merging if classes already exist) all classes/datatypes/enums/features/operations of one Ecore model into another one, without removing anything from the base Ecore model.
However, this is not the default behavior in Compare, as some elements may be removed from the base model if they don't get matched by elements of the other model.
I tried some things, such as discarding all non-ADD diff elements (thus preventing deletions): (this is Xtend code, but I'm sure you'll get it )
val EPackage pkg1 = ...
val EPackage pkg2 = ...
val scope = new DefaultComparisonScope(pkg1, pkg2, null)
val comparison = EMFCompare.builder.build.compare(scope)
val diffs = comparison.differences
kind != DifferenceKind.ADD
&& !requires.exists[r | r.kind == DifferenceKind.ADD]
val mergerRegistry = IMerger.RegistryImpl.createStandaloneInstance
val merger = new BatchMerger(mergerRegistry)
However, this does not meet the expected behavior, e.g. new datatypes are not added into the base model, etc.
Is there any way I can "properly" implement this behavior? I cannot find the appropriate filter/merger for such purpose. Alternatively, do you have some ideas on how I should filter my diffs in order to meet the expected behavior?
Powered by FUDForum
. Page generated in 0.02686 seconds