Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » Newbie Guide to Creating Custom Matching Strategy
Newbie Guide to Creating Custom Matching Strategy [message #1759249] Sat, 08 April 2017 09:58 Go to next message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 12
Registered: March 2017
Junior Member
I'm a noob to EMF Compare and relatively new to EMF in general and I'm trying to figure out how to create a custom matcher.

I've found these presentations:
*https://www.slideshare.net/cbrun/what-every-developer-should-know-about-emf-compare
* https://www.youtube.com/watch?v=7NhEiV_bTA0

But they both talk more about what can be done versus how to do it and the code snippets seem to assume a level of knowledge I don't yet I have.

I was able to figure out how to add a custom MatchEngine but based on this post: https://www.eclipse.org/forums/index.php/m/1723853/ that seems like a lot more work than I need for what I'm trying to do.

Really all I think I'm trying to do is add a custom identifier for a number of the model objects. Currently, EMF Compare is using the UUID to match model objects. However, in some situations I want the UUIDs to be different and I want to match using the object name or a generated identifier.

I found this code snippet about defining custom identifiers: https://www.eclipse.org/emf/compare/documentation/latest/developer/developer-guide.html#Defining_custom_identifiers

But I don't understand where this code is supposed to go. Maybe I am missing something obvious.

Also, I'm trying to keep all the EMF Compare extension in a separate project / plugin. Right now all that plugin does is register my model file extension to allow for EMF's default behavior. I'm not sure if this is adding to my complications.



[Updated on: Sat, 08 April 2017 09:59]

Report message to a moderator

Re: Newbie Guide to Creating Custom Matching Strategy [message #1759513 is a reply to message #1759249] Wed, 12 April 2017 13:01 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 99
Registered: March 2015
Location: Vienna, Austria
Member

Hi Nicholas,

the code from the developer guide can only be used if you are invoking the model comparison programmatically using the EMF Compare API. However, it sounds like you would like to have your custom matching behavior being used for comparisons that are started using the Eclipse/EMFCompare UI, right?

if yes, you'll have to register your own match engine via the extension point org.eclipse.emf.compare.rcp.matchEngine. E.g.
   <extension
         point="org.eclipse.emf.compare.rcp.matchEngine">
      <engineFactory
            class="org.eclipse.emf.compare.rcp.internal.match.DefaultRCPMatchEngineFactory"
            description="Default implementation of the Matching engine provided by EMF Compare. Any user-provided engine should have a ranking &gt; 0."
            label="Default Match engine"
            ranking="0">
      </engineFactory>
   </extension>


I hope that helps!

Best wishes,

Philip

--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Newbie Guide to Creating Custom Matching Strategy [message #1759692 is a reply to message #1759513] Sun, 16 April 2017 05:34 Go to previous messageGo to next message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 12
Registered: March 2017
Junior Member
Quote:
it sounds like you would like to have your custom matching behavior being used for comparisons that are started using the Eclipse/EMFCompare UI, right?

Yes. That's what I'd like.

Quote:
if yes, you'll have to register your own match engine via the extension point org.eclipse.emf.compare.rcp.matchEngine.

Ah.. ok. I figured out how to do that but another forum post made it seem like implementing my own match engine was a lot of work / a lot of duplication of code that the default match engine does so I was hoping there was a way to just extend parts of the default match engine.

With a little mote looking, I see there is a DefaultMatchEngine class. Seems like I can I inherit from that class and just extend/override the match method(s)?

Thanks for the help.
Re: Newbie Guide to Creating Custom Matching Strategy [message #1759749 is a reply to message #1759692] Tue, 18 April 2017 07:46 Go to previous messageGo to next message
Philip Langer is currently offline Philip LangerFriend
Messages: 99
Registered: March 2015
Location: Vienna, Austria
Member

Hi Nicholas,

Quote:
With a little mote looking, I see there is a DefaultMatchEngine class. Seems like I can I inherit from that class and just extend/override the match method(s)?


Yes, exactly. In your case, it seems like overwriting DefaultMatchEngine.getEObjectMatcher() and returning a custom subclass of IdentifierEObjectMatcher taking your ID attribute into account should be sufficient.

Best wishes,

Philip

--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/


--
Philip Langer

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: Newbie Guide to Creating Custom Matching Strategy [message #1760080 is a reply to message #1759513] Sat, 22 April 2017 02:23 Go to previous message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 12
Registered: March 2017
Junior Member
Thanks! I'll try it out when I get a chance.
Previous Topic:Comparing two structurally equal EObjects yields PSEUDO conflict [updated]
Next Topic:Resolving EGit Conflicts with EMF Compare
Goto Forum:
  


Current Time: Thu Apr 25 12:32:08 GMT 2024

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

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

Back to the top