Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Compare] EMF model instances compare/merge
[Compare] EMF model instances compare/merge [message #99258] Tue, 16 October 2007 14:39 Go to next message
hanys is currently offline hanysFriend
Messages: 188
Registered: July 2009
Senior Member
Hello,

we are creating our own model, which instances we want to compare. It's tree
based like Organization->Group->Person.
Each object is EMF based (we also have some .ecore file for it) and each
object has its own attribute values.
So we have model.ecore file as a meta-model.
And our model instances is saved in some xml format in multiple files. But
it doesn't matter I hope, because I want to do the comparison|merging of the
objects in memory.

What should we do when we want to use EMF compare project for comparing of
our EMF based model instances?

What should we implement? Do we need our structure and content viewers? And
what these viewers has as for interface needed?

Are there any steps to create COMPARE|MERGE editor for 2 model instances
(not only for 2 files, but models consisting of EObjects located in memory)
and visualized in Structure diff and merge viewer?

Thanks for any help.

BTW: Compare project looks very interesting and helpful for many scenarious.
It can be used for finding for example a diferences in a HIBERNATE MAPPINGS
FOR YOUR DATABASE. GOOD WORK :-) But I need some guide line to follow how to
extend it.

Best Regards,
Jan
Re: [Compare] EMF model instances compare/merge [message #99273 is a reply to message #99258] Tue, 16 October 2007 15:07 Go to previous messageGo to next message
Cedric Brun is currently offline Cedric BrunFriend
Messages: 431
Registered: July 2009
Senior Member
Hi,

thanks for your interest in the EMF compare component. I can basically see
two things in your question, tell me if I'm wrong.
You want to compare your own emf elements in memory. To do that you shoud
call the match then the differencing service.
final MatchModel match = new MatchService().doMatch(
eObject1, eObject2, new NullProgressMonitor());
final DiffModel diff = new DiffMaker().doDiff(match);

Then you'll get your diff, and you will be able to merge each difference
contained in the diff model using the Merger API.

DiffElement element;
final AbstractMerger merger = MergeFactory.createMerger(element);
merger.undoInTarget();
// or you could do : merger.applyInOrigin();

Another thing is about showing these differences in the UI. Here you should
have a look on the ModelCompareEditorLauncher which uses
an "ModelInputSnapshot" to open the usual diff/merge UI. The
ModelInputSnapshot is an element containing both the diff and match models.
final ModelInputSnapshot modelInputSnapshot = DiffFactory.eINSTANCE
.createModelInputSnapshot();
modelInputSnapshot.setDiff(input.getDiff());
modelInputSnapshot.setMatch(input.getMatch());
modelInputSnapshot.setDate(Calendar.getInstance(Locale.getDe fault()).getTime());

Then the user will be able to see and merge the differences on his own.


Cédric




eclipsemaniac wrote:

> Hello,
>
> we are creating our own model, which instances we want to compare. It's
> tree based like Organization->Group->Person.
> Each object is EMF based (we also have some .ecore file for it) and each
> object has its own attribute values.
> So we have model.ecore file as a meta-model.
> And our model instances is saved in some xml format in multiple files. But
> it doesn't matter I hope, because I want to do the comparison|merging of
> the objects in memory.
>
> What should we do when we want to use EMF compare project for comparing of
> our EMF based model instances?
>
> What should we implement? Do we need our structure and content viewers?
> And what these viewers has as for interface needed?
>
> Are there any steps to create COMPARE|MERGE editor for 2 model instances
> (not only for 2 files, but models consisting of EObjects located in
> memory) and visualized in Structure diff and merge viewer?
>
> Thanks for any help.
>
> BTW: Compare project looks very interesting and helpful for many
> scenarious. It can be used for finding for example a diferences in a
> HIBERNATE MAPPINGS FOR YOUR DATABASE. GOOD WORK :-) But I need some guide
> line to follow how to extend it.
>
> Best Regards,
> Jan


http://cedric.brun.io news and articles on eclipse and eclipse modeling.
Re: [Compare] EMF model instances compare/merge [message #99288 is a reply to message #99273] Tue, 16 October 2007 16:22 Go to previous message
hanys is currently offline hanysFriend
Messages: 188
Registered: July 2009
Senior Member
Hi C
Re: [Compare] EMF model instances compare/merge [message #610026 is a reply to message #99258] Tue, 16 October 2007 15:07 Go to previous message
Cedric Brun is currently offline Cedric BrunFriend
Messages: 431
Registered: July 2009
Senior Member
Hi,

thanks for your interest in the EMF compare component. I can basically see
two things in your question, tell me if I'm wrong.
You want to compare your own emf elements in memory. To do that you shoud
call the match then the differencing service.
final MatchModel match = new MatchService().doMatch(
eObject1, eObject2, new NullProgressMonitor());
final DiffModel diff = new DiffMaker().doDiff(match);

Then you'll get your diff, and you will be able to merge each difference
contained in the diff model using the Merger API.

DiffElement element;
final AbstractMerger merger = MergeFactory.createMerger(element);
merger.undoInTarget();
// or you could do : merger.applyInOrigin();

Another thing is about showing these differences in the UI. Here you should
have a look on the ModelCompareEditorLauncher which uses
an "ModelInputSnapshot" to open the usual diff/merge UI. The
ModelInputSnapshot is an element containing both the diff and match models.
final ModelInputSnapshot modelInputSnapshot = DiffFactory.eINSTANCE
.createModelInputSnapshot();
modelInputSnapshot.setDiff(input.getDiff());
modelInputSnapshot.setMatch(input.getMatch());
modelInputSnapshot.setDate(Calendar.getInstance(Locale.getDe fault()).getTime());

Then the user will be able to see and merge the differences on his own.


Cédric




eclipsemaniac wrote:

> Hello,
>
> we are creating our own model, which instances we want to compare. It's
> tree based like Organization->Group->Person.
> Each object is EMF based (we also have some .ecore file for it) and each
> object has its own attribute values.
> So we have model.ecore file as a meta-model.
> And our model instances is saved in some xml format in multiple files. But
> it doesn't matter I hope, because I want to do the comparison|merging of
> the objects in memory.
>
> What should we do when we want to use EMF compare project for comparing of
> our EMF based model instances?
>
> What should we implement? Do we need our structure and content viewers?
> And what these viewers has as for interface needed?
>
> Are there any steps to create COMPARE|MERGE editor for 2 model instances
> (not only for 2 files, but models consisting of EObjects located in
> memory) and visualized in Structure diff and merge viewer?
>
> Thanks for any help.
>
> BTW: Compare project looks very interesting and helpful for many
> scenarious. It can be used for finding for example a diferences in a
> HIBERNATE MAPPINGS FOR YOUR DATABASE. GOOD WORK :-) But I need some guide
> line to follow how to extend it.
>
> Best Regards,
> Jan


http://cedric.brun.io news and articles on eclipse and eclipse modeling.
Re: [Compare] EMF model instances compare/merge [message #610029 is a reply to message #99273] Tue, 16 October 2007 16:22 Go to previous message
hanys is currently offline hanysFriend
Messages: 188
Registered: July 2009
Senior Member
Hi C
Previous Topic:[Compare] EMF model instances compare/merge
Next Topic:[CDO] all tests successfull, next step ?
Goto Forum:
  


Current Time: Thu Apr 25 05:01:40 GMT 2024

Powered by FUDForum. Page generated in 0.03078 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top