Programmatically "merge without deletions" [message #1393101] |
Thu, 03 July 2014 08:35 |
Cioran Naroic Messages: 18 Registered: December 2013 |
Junior Member |
|
|
Hello everyone,
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
diffs.filter[
kind != DifferenceKind.ADD
&& !requires.exists[r | r.kind == DifferenceKind.ADD]
].forEach[
discard
]
val mergerRegistry = IMerger.RegistryImpl.createStandaloneInstance
val merger = new BatchMerger(mergerRegistry)
merger.copyAllLeftToRight(diffs, null)
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?
Thank you,
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04248 seconds