Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MDT (Model Development Tools) » Programatically merge two models(How can I merge to models programatically?)
Programatically merge two models [message #546989] Wed, 14 July 2010 16:47 Go to next message
Roshan S. is currently offline Roshan S.
Messages: 125
Registered: July 2009
Senior Member
Hi,

If I have two models "A" and "B" of type org.eclipse.uml2.uml.Model. Is there a way to merge the two models programatically?

Model A is the master model, which means conflicting changes would take A's values, BUT I need to use model B for its packaging structure. Which means B may have several packages and I need to make sure that the structure stays the same.

If Anyone knows how to do this, then it would help greatly.

Thanks,
Roshan
Re: Programatically merge two models [message #547196 is a reply to message #546989] Thu, 15 July 2010 18:06 Go to previous messageGo to next message
Stephan Eberle is currently offline Stephan Eberle
Messages: 35
Registered: July 2009
Member

Hi,

you could use EMF Compare and call it programatically in the following way:

try {
MatchModel matchModel =
MatchService.doContentMatch(leftEObject, rightEObject, null);
DiffModel diffModel = DiffService.doDiff(matchModel);

MergeService.merge(diffModel.getOwnedElements(), leftToRight);
} catch (InterruptedException ex) {
// TODO Handle exception
}

What you get is an automatic merge based on EMF Compare's built-in
default behavior which may or may not fit with your requirements
described below. However you can tweak EMF Compare in many ways by
contributing your own match and diff engines (which override and
customize the generic ones). Consider to ask e.t.emf for details about that.

Cheers,

Stephan


Le 14/07/2010 22:47, Roshan Soni a écrit :
> Hi,
> If I have two models "A" and "B" of type org.eclipse.uml2.uml.Model. Is
> there a way to merge the two models programatically?
> Model A is the master model, which means conflicting changes would take
> A's values, BUT I need to use model B for its packaging structure. Which
> means B may have several packages and I need to make sure that the
> structure stays the same.
> If Anyone knows how to do this, then it would help greatly.
>
> Thanks,
> Roshan
Re: Programatically merge two models [message #547197 is a reply to message #546989] Thu, 15 July 2010 18:07 Go to previous message
Stephan Eberle is currently offline Stephan Eberle
Messages: 35
Registered: July 2009
Member

Hi,

you could use EMF Compare and call it programatically in the following way:

try {
MatchModel matchModel =
MatchService.doContentMatch(leftEObject, rightEObject, null);
DiffModel diffModel = DiffService.doDiff(matchModel);

MergeService.merge(diffModel.getOwnedElements(), leftToRight);
} catch (InterruptedException ex) {
// TODO Handle exception
}

What you get is an automatic merge based on EMF Compare's built-in
default behavior which may or may not fit with your requirements
described below. However you can tweak EMF Compare in many ways by
contributing your own match and diff engines (which override and
customize the generic ones). Consider to ask e.t.emf for details about that.

Cheers,

Stephan


Le 14/07/2010 22:47, Roshan Soni a écrit :
> Hi,
> If I have two models "A" and "B" of type org.eclipse.uml2.uml.Model. Is
> there a way to merge the two models programatically?
> Model A is the master model, which means conflicting changes would take
> A's values, BUT I need to use model B for its packaging structure. Which
> means B may have several packages and I need to make sure that the
> structure stays the same.
> If Anyone knows how to do this, then it would help greatly.
>
> Thanks,
> Roshan
Previous Topic:Programatically merge two models
Next Topic:Meta-Model Spy Suggestion
Goto Forum:
  


Current Time: Wed Aug 27 17:10:29 EDT 2014

Powered by FUDForum. Page generated in 0.04571 seconds