SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
EclipseCon 2011




      What every developer
           EMF Compare ?



             Cédric Brun
             Obeo, France



copyright 2011 Obeo
in action!




●   SVN, CVS, GIT
●   UML, EMF, DSL's
●   History, Compare, Merge
Component of
                    EMF
●   Graduated
●   Stable API
●   pure Java JAR
●   Extensible
The Tool
How is it
Working ?
Matching Strategies

  XMI-ID                                                         GenericMatchEngine

options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.FALSE);
MatchModel match = MatchService.doContentMatch(left,right options);




  ID-Attribute
options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.FALSE);
MatchModel match = MatchService.doContentMatch(left,right options);




                                                defaults are XMI-ID, then ID-attributes and then reflective
Your own matching strategy



 public class AddressBookMatcher extends GenericMatchEngine {

 /**
  * {@inheritDoc}
  */
 @Override
 protected boolean isSimilar(EObject obj1, EObject obj2) throws FactoryException {
 /*
  * If we've got a People, only check the name similarity.
  */
 if (obj1 instanceof People || obj2 instanceof People)
 return nameDistance(obj1, obj2) > 0.8;
 /*
  * Contacts are similar if : the associated people is similar + their content is quite the same.
  */
 if (obj1 instanceof Contact && obj2 instanceof Contact) {
 EObject obj1Parent = obj1.eContainer();
 EObject obj2Parent = obj2.eContainer();
 if (obj1Parent instanceof People && obj2Parent instanceof People)
 return isSimilar(obj1Parent, obj2Parent) && contentDistance(obj1, obj2) > 0.5;
 }

 /*
  * If it's something we don't know about, then use the generic behavior.
  */
 return super.isSimilar(obj1, obj2);
 }
Comparing
People alice = createAlice();
v1Book.getPeoples().add(alice);

v2Book = EcoreUtil.copy(v1Book);

People bob = createBob();
v2Book.getPeoples().add(bob);




MatchModel match = new AddressBookMatcher().contentMatch(v1Book, v2Book, noOptions());

DiffModel delta = DiffService.doDiff(match);

DiffElement addbob = DiffHelper.isAdded(bob, delta);
assertNotNull("the addition of Bob has not been detected", addbob);
Merging




boolean mergeLeftToRight = true;
for (DiffElement diff : delta.getDifferences()) {
MergeService.merge(diff, mergeLeftToRight);
}

match = new AddressBookMatcher().contentMatch(v1Book, v2Book, noOptions());

delta = DiffService.doDiff(match);

assertEquals("We still have a difference whereas we merged all the diff elements", 0,
delta //$NON-NLS-1$
.getDifferences().size());
aliceLocal.setBirthday("07/05/84");
aliceRemote.setBirthday("07/07/84");

MatchModel match = new AddressBookMatcher().contentMatch(v2LocalBook, v2RemoteBook, v1Book,
noOptions());

DiffModel delta = DiffService.doDiff(match, true);
List<DiffElement> conflicts = new ArrayList<DiffElement>();

for (DiffElement diff : delta.getDifferences()) {
if (diff.isConflicting()) {
conflicts.add(diff);
}
}

assertEquals("We should have a conflict on Alice's birthday", 1, conflicts.size());
}
Exporting the delta.
Diff is a model => You can use Acceleo to generate code based on a diff
    e.g : SQL migration scripts based on a entity models comparison
Other usages we've
             heard of ?

Non regression Testing
    Selective assertEquals() on models

Transforming a destructive process in an incremental one
Using the diff + original version as an input for a process
Interactive Model Transformation
    Leveraging the UI + custom Match and Merge
What's
         cooking ?

                     ●   UML dedicated support
                     ●   Enhanced generic editor
                     ●   GMF and Papyrus Integration
References
 Website :
 ●

  ● http://www.eclipse.org/modeling/emf?project=compare

  ● http://wiki.eclipse.org/index.php/EMF ompare
                                        C
                                        _


 Support : EMF newsgroup and mailling list
 ●




 Downloads :
 ●

  ● Indigo Update Site

  ● Eclipse Modeling Package




 Source Code
 ●

  ● git://git.eclipse.org/gitroot/emfcompare/org.eclipse.emf.compare.git

Mais conteúdo relacionado

Semelhante a What every developer should know about EMF Compare

Semelhante a What every developer should know about EMF Compare (20)

Viking academy backbone.js
Viking academy  backbone.jsViking academy  backbone.js
Viking academy backbone.js
 
Eugenia
EugeniaEugenia
Eugenia
 
Formatting ForThe Masses
Formatting ForThe MassesFormatting ForThe Masses
Formatting ForThe Masses
 
Refactoring
RefactoringRefactoring
Refactoring
 
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling FrameworkEclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
Dojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspectiveDojo Toolkit from a Flex developer's perspective
Dojo Toolkit from a Flex developer's perspective
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
[E-Dev-Day 2014][4/16] Review of Eolian, Eo, Bindings, Interfaces and What's ...
[E-Dev-Day 2014][4/16] Review of Eolian, Eo, Bindings, Interfaces and What's ...[E-Dev-Day 2014][4/16] Review of Eolian, Eo, Bindings, Interfaces and What's ...
[E-Dev-Day 2014][4/16] Review of Eolian, Eo, Bindings, Interfaces and What's ...
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
 
Refactoring
RefactoringRefactoring
Refactoring
 
Koin Quickstart
Koin QuickstartKoin Quickstart
Koin Quickstart
 
iOS overview
iOS overviewiOS overview
iOS overview
 
Front End Development: The Important Parts
Front End Development: The Important PartsFront End Development: The Important Parts
Front End Development: The Important Parts
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
An Introduction to the SOLID Principles
An Introduction to the SOLID PrinciplesAn Introduction to the SOLID Principles
An Introduction to the SOLID Principles
 
Web technologies-course 12.pptx
Web technologies-course 12.pptxWeb technologies-course 12.pptx
Web technologies-course 12.pptx
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Tdd is not about testing
Tdd is not about testingTdd is not about testing
Tdd is not about testing
 

Mais de Cédric Brun

EcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessibleEcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessible
Cédric Brun
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ fr
Cédric Brun
 
Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the world
Cédric Brun
 
From Acceleo.org To Eclipse Modeling
From Acceleo.org To Eclipse ModelingFrom Acceleo.org To Eclipse Modeling
From Acceleo.org To Eclipse Modeling
Cédric Brun
 
Acceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code GenerationAcceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code Generation
Cédric Brun
 

Mais de Cédric Brun (20)

Integrating Xtext and Sirius: Strategies and Pitfalls
Integrating Xtext and Sirius: Strategies and PitfallsIntegrating Xtext and Sirius: Strategies and Pitfalls
Integrating Xtext and Sirius: Strategies and Pitfalls
 
Eclipse Modeling Guided Tour - EMF Compare
Eclipse Modeling Guided Tour - EMF CompareEclipse Modeling Guided Tour - EMF Compare
Eclipse Modeling Guided Tour - EMF Compare
 
Eclipse Modeling Guided Tour - Acceleo Query Language (AQL)
Eclipse Modeling Guided Tour - Acceleo Query Language (AQL)Eclipse Modeling Guided Tour - Acceleo Query Language (AQL)
Eclipse Modeling Guided Tour - Acceleo Query Language (AQL)
 
Eclipse Modeling Guided Tour - EcoreTools
Eclipse Modeling Guided Tour - EcoreToolsEclipse Modeling Guided Tour - EcoreTools
Eclipse Modeling Guided Tour - EcoreTools
 
EcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessibleEcoreTools-Next: Executable DSL made (more) accessible
EcoreTools-Next: Executable DSL made (more) accessible
 
Integrating Xtext and Sirius: Strategies and Pitfalls
Integrating  Xtext and Sirius:  Strategies and PitfallsIntegrating  Xtext and Sirius:  Strategies and Pitfalls
Integrating Xtext and Sirius: Strategies and Pitfalls
 
Roadmap - SiriusCon2016
Roadmap - SiriusCon2016Roadmap - SiriusCon2016
Roadmap - SiriusCon2016
 
Modeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ frModeling avengers – open source technology mix for saving the world econ fr
Modeling avengers – open source technology mix for saving the world econ fr
 
Modeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the worldModeling avengers – open source technology mix for saving the world
Modeling avengers – open source technology mix for saving the world
 
15 EMF projects in 25 minutes
15 EMF projects in 25 minutes15 EMF projects in 25 minutes
15 EMF projects in 25 minutes
 
What the heck is Eclipse Modeling and why should you care !
What the heck is Eclipse Modeling and why should you care !What the heck is Eclipse Modeling and why should you care !
What the heck is Eclipse Modeling and why should you care !
 
Breathe life into your designer!
Breathe life into your designer!Breathe life into your designer!
Breathe life into your designer!
 
Sirius : origins, present, future
Sirius : origins, present, futureSirius : origins, present, future
Sirius : origins, present, future
 
Xtext + Sirius = ♥ / EclipseCon Europe 2014
Xtext + Sirius = ♥  / EclipseCon Europe 2014Xtext + Sirius = ♥  / EclipseCon Europe 2014
Xtext + Sirius = ♥ / EclipseCon Europe 2014
 
Xtext + Sirius = &lt;3
Xtext + Sirius = &lt;3Xtext + Sirius = &lt;3
Xtext + Sirius = &lt;3
 
Ecore Tools 2.0 : The Luna Revival
Ecore Tools 2.0 : The Luna RevivalEcore Tools 2.0 : The Luna Revival
Ecore Tools 2.0 : The Luna Revival
 
Sirius Role Playing Game - Build diagram, table and tree editors in 20 minutes
Sirius Role Playing Game  - Build diagram, table and tree editors in 20 minutesSirius Role Playing Game  - Build diagram, table and tree editors in 20 minutes
Sirius Role Playing Game - Build diagram, table and tree editors in 20 minutes
 
From Acceleo.org To Eclipse Modeling
From Acceleo.org To Eclipse ModelingFrom Acceleo.org To Eclipse Modeling
From Acceleo.org To Eclipse Modeling
 
Acceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code GenerationAcceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code Generation
 
Team Work With Models Web
Team Work With Models WebTeam Work With Models Web
Team Work With Models Web
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

What every developer should know about EMF Compare

  • 1. EclipseCon 2011 What every developer EMF Compare ? Cédric Brun Obeo, France copyright 2011 Obeo
  • 2. in action! ● SVN, CVS, GIT ● UML, EMF, DSL's ● History, Compare, Merge
  • 3. Component of EMF ● Graduated ● Stable API ● pure Java JAR ● Extensible
  • 6.
  • 7. Matching Strategies XMI-ID GenericMatchEngine options.put(MatchOptions.OPTION_IGNORE_XMI_ID, Boolean.FALSE); MatchModel match = MatchService.doContentMatch(left,right options); ID-Attribute options.put(MatchOptions.OPTION_IGNORE_ID, Boolean.FALSE); MatchModel match = MatchService.doContentMatch(left,right options); defaults are XMI-ID, then ID-attributes and then reflective
  • 8. Your own matching strategy public class AddressBookMatcher extends GenericMatchEngine { /** * {@inheritDoc} */ @Override protected boolean isSimilar(EObject obj1, EObject obj2) throws FactoryException { /* * If we've got a People, only check the name similarity. */ if (obj1 instanceof People || obj2 instanceof People) return nameDistance(obj1, obj2) > 0.8; /* * Contacts are similar if : the associated people is similar + their content is quite the same. */ if (obj1 instanceof Contact && obj2 instanceof Contact) { EObject obj1Parent = obj1.eContainer(); EObject obj2Parent = obj2.eContainer(); if (obj1Parent instanceof People && obj2Parent instanceof People) return isSimilar(obj1Parent, obj2Parent) && contentDistance(obj1, obj2) > 0.5; } /* * If it's something we don't know about, then use the generic behavior. */ return super.isSimilar(obj1, obj2); }
  • 9. Comparing People alice = createAlice(); v1Book.getPeoples().add(alice); v2Book = EcoreUtil.copy(v1Book); People bob = createBob(); v2Book.getPeoples().add(bob); MatchModel match = new AddressBookMatcher().contentMatch(v1Book, v2Book, noOptions()); DiffModel delta = DiffService.doDiff(match); DiffElement addbob = DiffHelper.isAdded(bob, delta); assertNotNull("the addition of Bob has not been detected", addbob);
  • 10. Merging boolean mergeLeftToRight = true; for (DiffElement diff : delta.getDifferences()) { MergeService.merge(diff, mergeLeftToRight); } match = new AddressBookMatcher().contentMatch(v1Book, v2Book, noOptions()); delta = DiffService.doDiff(match); assertEquals("We still have a difference whereas we merged all the diff elements", 0, delta //$NON-NLS-1$ .getDifferences().size());
  • 11. aliceLocal.setBirthday("07/05/84"); aliceRemote.setBirthday("07/07/84"); MatchModel match = new AddressBookMatcher().contentMatch(v2LocalBook, v2RemoteBook, v1Book, noOptions()); DiffModel delta = DiffService.doDiff(match, true); List<DiffElement> conflicts = new ArrayList<DiffElement>(); for (DiffElement diff : delta.getDifferences()) { if (diff.isConflicting()) { conflicts.add(diff); } } assertEquals("We should have a conflict on Alice's birthday", 1, conflicts.size()); }
  • 12. Exporting the delta. Diff is a model => You can use Acceleo to generate code based on a diff e.g : SQL migration scripts based on a entity models comparison
  • 13. Other usages we've heard of ? Non regression Testing Selective assertEquals() on models Transforming a destructive process in an incremental one Using the diff + original version as an input for a process Interactive Model Transformation Leveraging the UI + custom Match and Merge
  • 14. What's cooking ? ● UML dedicated support ● Enhanced generic editor ● GMF and Papyrus Integration
  • 15. References Website : ● ● http://www.eclipse.org/modeling/emf?project=compare ● http://wiki.eclipse.org/index.php/EMF ompare C _ Support : EMF newsgroup and mailling list ● Downloads : ● ● Indigo Update Site ● Eclipse Modeling Package Source Code ● ● git://git.eclipse.org/gitroot/emfcompare/org.eclipse.emf.compare.git