Search in sources :

Example 1 with DiffBuilder

use of org.eclipse.emf.compare.diff.DiffBuilder in project tdq-studio-se by Talend.

the class AbstractComparisonLevel method diffEngineWithFilter.

/**
 * ignore the difference of id(not xmi id) Atrribute.
 *
 * @return
 */
protected IDiffEngine diffEngineWithFilter() {
    IDiffProcessor diffProcessor = new DiffBuilder();
    IDiffEngine diffEngine = new DefaultDiffEngine(diffProcessor) {

        @Override
        protected FeatureFilter createFeatureFilter() {
            return new FeatureFilter() {

                // @Override
                @Override
                public boolean checkForOrderingChanges(EStructuralFeature feature) {
                    return false;
                }

                @Override
                protected boolean isIgnoredAttribute(EAttribute attribute) {
                    // $NON-NLS-1$
                    return "id".equals(attribute.getName()) || attribute.isID() || super.isIgnoredAttribute(attribute);
                }
            };
        }
    };
    return diffEngine;
}
Also used : DiffBuilder(org.eclipse.emf.compare.diff.DiffBuilder) DefaultDiffEngine(org.eclipse.emf.compare.diff.DefaultDiffEngine) EAttribute(org.eclipse.emf.ecore.EAttribute) FeatureFilter(org.eclipse.emf.compare.diff.FeatureFilter) IDiffProcessor(org.eclipse.emf.compare.diff.IDiffProcessor) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) IDiffEngine(org.eclipse.emf.compare.diff.IDiffEngine)

Example 2 with DiffBuilder

use of org.eclipse.emf.compare.diff.DiffBuilder in project InformationSystem by ObeoNetwork.

the class EMFCompareUtils method initializeComparator.

/**
 * Initializes the EMF Compare comparator.
 *
 * @return the EMFCompare comparator.
 */
private static EMFCompare initializeComparator() {
    final IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
    final IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
    final IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
    matchEngineFactory.setRanking(20);
    final IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
    matchEngineRegistry.add(matchEngineFactory);
    final IDiffProcessor diffProcessor = new DiffBuilder();
    final IDiffEngine diffEngine = new DefaultDiffEngine(diffProcessor) {

        @Override
        protected FeatureFilter createFeatureFilter() {
            return new FeatureFilter() {

                @Override
                protected boolean isIgnoredAttribute(EAttribute attribute) {
                    if (attribute == null) {
                        // comparison, do it here.
                        return true;
                    } else {
                        return super.isIgnoredAttribute(attribute);
                    }
                }
            };
        }
    };
    final EMFCompare comparator = EMFCompare.builder().setDiffEngine(diffEngine).setMatchEngineFactoryRegistry(matchEngineRegistry).build();
    return comparator;
}
Also used : DiffBuilder(org.eclipse.emf.compare.diff.DiffBuilder) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) MatchEngineFactoryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl) FeatureFilter(org.eclipse.emf.compare.diff.FeatureFilter) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) MatchEngineFactoryRegistryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl) IDiffEngine(org.eclipse.emf.compare.diff.IDiffEngine) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) DefaultDiffEngine(org.eclipse.emf.compare.diff.DefaultDiffEngine) EAttribute(org.eclipse.emf.ecore.EAttribute) EMFCompare(org.eclipse.emf.compare.EMFCompare) IDiffProcessor(org.eclipse.emf.compare.diff.IDiffProcessor) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher) IMatchEngine(org.eclipse.emf.compare.match.IMatchEngine)

Aggregations

DefaultDiffEngine (org.eclipse.emf.compare.diff.DefaultDiffEngine)2 DiffBuilder (org.eclipse.emf.compare.diff.DiffBuilder)2 FeatureFilter (org.eclipse.emf.compare.diff.FeatureFilter)2 IDiffEngine (org.eclipse.emf.compare.diff.IDiffEngine)2 IDiffProcessor (org.eclipse.emf.compare.diff.IDiffProcessor)2 EAttribute (org.eclipse.emf.ecore.EAttribute)2 EMFCompare (org.eclipse.emf.compare.EMFCompare)1 DefaultComparisonFactory (org.eclipse.emf.compare.match.DefaultComparisonFactory)1 DefaultEqualityHelperFactory (org.eclipse.emf.compare.match.DefaultEqualityHelperFactory)1 IComparisonFactory (org.eclipse.emf.compare.match.IComparisonFactory)1 IMatchEngine (org.eclipse.emf.compare.match.IMatchEngine)1 IEObjectMatcher (org.eclipse.emf.compare.match.eobject.IEObjectMatcher)1 MatchEngineFactoryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl)1 MatchEngineFactoryRegistryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1