Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Does EMF supports merge multi-model instance into one, which are based on the same meta-model
Does EMF supports merge multi-model instance into one, which are based on the same meta-model [message #1767239] Tue, 04 July 2017 06:41 Go to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
To Whom It May Concern,

Does EMF supports merge multi-model instance files into one file, which are based on the same meta-model?

Thanks



Example:

Using the family model as sample, which is descripted by Xtext:

Two separated file:
=================================
A.family:

Family test{
Man Tom{
},
Woman Lily{
}
}

B.family:

Family test{
Man Jack{
father Tom
mother Lily
}
}
=================================

Merge into one:
C.family:

Family test{
Man Tom{
},
Woman Lily{
},
Man Jack{
father Tom
mother Lily
}
}

index.php/fa/29847/0/

[Updated on: Wed, 05 July 2017 01:53]

Report message to a moderator

Re: Does EMF supports merge multi-model instance into one, which are based on one same meta-model [message #1767241 is a reply to message #1767239] Tue, 04 July 2017 06:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

Yes and No.

Yes: An EMF model/'instance file' normally contains a single root element so the root of the XML document is a user element. XML allows multiple roots; the root element may be xmi:XMI which may contain many elements possibly of many distinct metamodels. The Sample Reflective Ecore Editor displays these multiple roots and allows you to edit them. EMF can load and save them.

No: Multiple roots is discouraged. The Sample Reflective Ecore Editor has no abilities to create additional roots. Some defective tools assume that a model has a single root.

Regards

Ed Willink
Re: Does EMF supports merge multi-model instance into one, which are based on one same meta-model [message #1767351 is a reply to message #1767241] Wed, 05 July 2017 01:51 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Hi Ed,

Thanks for your reply.

Quote:
Yes: An EMF model/'instance file' normally contains a single root element so the root of the XML document is a user element. XML allows multiple roots; the root element may be xmi:XMI which may contain many elements possibly of many distinct metamodels. The Sample Reflective Ecore Editor displays these multiple roots and allows you to edit them. EMF can load and save them.


Sorry, maybe my description is not clearly. Actually I hope is there a way to merge the same/single root instance models, which are in the separated files, into one file.

I have tried 'Sample Reflective Ecore Editor', but it is not I want.

I prepared a sample for this.
And attache the material under this discussion.

index.php/fa/29846/0/

index.php/fa/29845/0/
Re: Does EMF supports merge multi-model instance into one, which are based on one same meta-model [message #1767374 is a reply to message #1767351] Wed, 05 July 2017 11:43 Go to previous messageGo to next message
Andreas Graf is currently offline Andreas GrafFriend
Messages: 208
Registered: July 2009
Senior Member
Hi Nicholas,

that is a use case that we frequently encounter and that has no built-in solution in EMF. E.g., in your example above you are implicitely assuming that model elements are identified by their (fully qualified) name. That might not be the case. In the general case, they could be identified through arbitrary IDs and be in different containment hierarchies. In addition, you'd need a conflict resolution strategy for attributes that mismatch in both models (Toms age might be different in both models). Handling of references etc. also needs a dedicated strategy. So in all, we see three technological approaches:

* Create a dedicated extra model in a "model merge" step. This could be done through EMF compare or through custom logic
* Use Java proxies to provide an API for a dynamic merged view (that's what Artop tries to do)
* Use AspectJ to provide an API for a dynamic merged view (that's what Artop tries to do)

HTH,

Andreas
Re: Does EMF supports merge multi-model instance into one, which are based on one same meta-model [message #1767382 is a reply to message #1767374] Wed, 05 July 2017 12:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6111
Registered: July 2009
Senior Member
Hi

Maybe I misunderstand the problem but programmatically it's easy.

Resource resource1 = resourceSet.createResource(...uri1...);
Resource resource2 = resourceSet.createResource(...uri2...);
resource1.getContents().addAll(resource2.getContents());
resource1.setURI(....mergedURI....);
resource1.save(null);

If you have xmi:ids to preserve then those need copying across too with a duplicate resolution algorithm.

It's just a pity that EMF doesn't support root DND in the Sample Ecore Editor.

Regards

Ed Willink
Re: Does EMF supports merge multi-model instance into one, which are based on one same meta-model [message #1767428 is a reply to message #1767374] Thu, 06 July 2017 03:27 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
Hi Andreas,

Thanks for your replay, I will research that three technological approaches.

Thanks.
Re: Does EMF supports merge multi-model instance into one, which are based on one same meta-model [message #1767429 is a reply to message #1767382] Thu, 06 July 2017 03:28 Go to previous messageGo to next message
Nicholas Kong is currently offline Nicholas KongFriend
Messages: 59
Registered: July 2016
Location: China
Member
I will try it. Thanks~! ( ;
Re: Does EMF supports merge multi-model instance into one, which are based on the same meta-model [message #1767528 is a reply to message #1767239] Thu, 06 July 2017 20:04 Go to previous message
Aurélien Mora is currently offline Aurélien MoraFriend
Messages: 23
Registered: July 2014
Junior Member
Hello,

I think you should take a look at https://wiki.eclipse.org/EMF_DiffMerge


Previous Topic:Name Collision in Package and its elements
Next Topic:[CDO] MasterServer Crash - macOS
Goto Forum:
  


Current Time: Fri Nov 16 19:53:32 GMT 2018

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

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

Back to the top