Search in sources :

Example 1 with IEObjectMatcher

use of org.eclipse.emf.compare.match.eobject.IEObjectMatcher in project tdq-studio-se by Talend.

the class ModelElementMatchEngine method createDQEObjectMatcher.

/**
 * Creates and configures an {@link IEObjectMatcher} with the strategy given by {@code useIDs}. The {@code cache}
 * will be used to cache some expensive computation (should better a LoadingCache).
 *
 * @param useIDs which strategy the return IEObjectMatcher must follow.
 * @param weightProviderRegistry the match engine needs a WeightProvider in case of this match engine do not use
 * identifiers.
 * @return a new IEObjectMatcher.
 */
public static IEObjectMatcher createDQEObjectMatcher(UseIdentifiers useIDs, WeightProvider.Descriptor.Registry weightProviderRegistry) {
    final IEObjectMatcher matcher;
    final ModelElementEditonDistance editionDistance = new ModelElementEditonDistance(weightProviderRegistry);
    final CachingDistance cachedDistance = new CachingDistance(editionDistance);
    switch(useIDs) {
        case NEVER:
            matcher = new ProximityEObjectMatcher(cachedDistance);
            break;
        case ONLY:
            matcher = new IdentifierEObjectMatcher();
            break;
        case WHEN_AVAILABLE:
        // fall through to default
        default:
            // Use an ID matcher, delegating to proximity when no ID is available
            final IEObjectMatcher contentMatcher = new ProximityEObjectMatcher(cachedDistance);
            matcher = new IdentifierEObjectMatcher(contentMatcher);
            break;
    }
    return matcher;
}
Also used : ProximityEObjectMatcher(org.eclipse.emf.compare.match.eobject.ProximityEObjectMatcher) CachingDistance(org.eclipse.emf.compare.match.eobject.CachingDistance) IdentifierEObjectMatcher(org.eclipse.emf.compare.match.eobject.IdentifierEObjectMatcher) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher)

Example 2 with IEObjectMatcher

use of org.eclipse.emf.compare.match.eobject.IEObjectMatcher in project tdq-studio-se by Talend.

the class AbstractComparisonLevel method createDefaultEMFCompare.

/**
 * create a EMFCompare with default configuration.
 *
 * @return
 */
protected EMFCompare createDefaultEMFCompare() {
    // Configure EMF Compare
    IEObjectMatcher matcher = ModelElementMatchEngine.createDQEObjectMatcher(UseIdentifiers.NEVER);
    DefaultEqualityHelperFactory equalityHelperFactory = new DefaultEqualityHelperFactory();
    IComparisonFactory comparisonFactory = new DefaultComparisonFactory(equalityHelperFactory);
    IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
    // IMatchEngine.Factory.Registry matchEngineRegistry =
    // EMFCompareRCPPlugin.getDefault().getMatchEngineFactoryRegistry();
    DQMatchEngineFactory matchEngineFactoryImpl = new DQMatchEngineFactory(matcher, comparisonFactory);
    matchEngineRegistry.add(matchEngineFactoryImpl);
    Builder builder = EMFCompare.builder();
    builder.setDiffEngine(diffEngineWithFilter());
    EMFCompare comparator = builder.setMatchEngineFactoryRegistry(matchEngineRegistry).build();
    return comparator;
}
Also used : DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) EMFCompare(org.eclipse.emf.compare.EMFCompare) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) DiffBuilder(org.eclipse.emf.compare.diff.DiffBuilder) Builder(org.eclipse.emf.compare.EMFCompare.Builder) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) ElementWriterFactory(org.talend.dq.writer.impl.ElementWriterFactory) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) DQMatchEngineFactory(org.talend.cwm.compare.factory.DQMatchEngineFactory) MatchEngineFactoryRegistryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl) DQMatchEngineFactory(org.talend.cwm.compare.factory.DQMatchEngineFactory) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher)

Example 3 with IEObjectMatcher

use of org.eclipse.emf.compare.match.eobject.IEObjectMatcher in project statecharts by Yakindu.

the class SCTMatchEngineFactory method getMatchEngine.

@Override
public IMatchEngine getMatchEngine() {
    final IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
    final IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.WHEN_AVAILABLE);
    return new SCTMatchEngine(matcher, comparisonFactory);
}
Also used : DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher)

Example 4 with IEObjectMatcher

use of org.eclipse.emf.compare.match.eobject.IEObjectMatcher in project tdq-studio-se by Talend.

the class ExampleLauncher method compare.

public static void compare() {
    // Load the two input models
    ResourceSet resourceSet1 = new ResourceSetImpl();
    ResourceSet resourceSet2 = new ResourceSetImpl();
    // String xmi1 = "path/to/first/model.xmi";
    // String xmi2 = "path/to/second/model.xmi";
    load(fileName1, resourceSet1);
    load(fileName2, resourceSet2);
    // Configure EMF Compare
    IEObjectMatcher matcher = DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
    IComparisonFactory comparisonFactory = new DefaultComparisonFactory(new DefaultEqualityHelperFactory());
    IMatchEngine.Factory matchEngineFactory = new MatchEngineFactoryImpl(matcher, comparisonFactory);
    matchEngineFactory.setRanking(20);
    IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
    matchEngineRegistry.add(matchEngineFactory);
    EMFCompare comparator = EMFCompare.builder().setMatchEngineFactoryRegistry(matchEngineRegistry).build();
    // Compare the two models
    IComparisonScope scope = new DefaultComparisonScope(resourceSet1, resourceSet2, null);
    Comparison compare = comparator.compare(scope);
    comparator.compare(scope);
    EList<Diff> differences = compare.getDifferences();
    ICompareEditingDomain editingDomain = EMFCompareEditingDomain.create(scope.getLeft(), scope.getRight(), null);
    AdapterFactory adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration());
    CompareEditorInput input = new ComparisonScopeEditorInput(configuration, editingDomain, adapterFactory, comparator, scope);
    // CompareUI.openCompareDialog(input); // or CompareUI.openCompareEditor(input);
    CompareUI.openCompareEditor(input);
}
Also used : MatchEngineFactoryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl) Diff(org.eclipse.emf.compare.Diff) CompareConfiguration(org.eclipse.compare.CompareConfiguration) EMFCompareConfiguration(org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) MatchEngineFactoryRegistryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope) DefaultComparisonFactory(org.eclipse.emf.compare.match.DefaultComparisonFactory) Comparison(org.eclipse.emf.compare.Comparison) AdapterFactory(org.eclipse.emf.common.notify.AdapterFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) ICompareEditingDomain(org.eclipse.emf.compare.domain.ICompareEditingDomain) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) DefaultEqualityHelperFactory(org.eclipse.emf.compare.match.DefaultEqualityHelperFactory) DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) IComparisonFactory(org.eclipse.emf.compare.match.IComparisonFactory) ComposedAdapterFactory(org.eclipse.emf.edit.provider.ComposedAdapterFactory) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) EMFCompareConfiguration(org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration) ComparisonScopeEditorInput(org.eclipse.emf.compare.ide.ui.internal.editor.ComparisonScopeEditorInput) CompareEditorInput(org.eclipse.compare.CompareEditorInput) EMFCompare(org.eclipse.emf.compare.EMFCompare) IEObjectMatcher(org.eclipse.emf.compare.match.eobject.IEObjectMatcher) IMatchEngine(org.eclipse.emf.compare.match.IMatchEngine)

Example 5 with IEObjectMatcher

use of org.eclipse.emf.compare.match.eobject.IEObjectMatcher 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

IEObjectMatcher (org.eclipse.emf.compare.match.eobject.IEObjectMatcher)5 DefaultComparisonFactory (org.eclipse.emf.compare.match.DefaultComparisonFactory)4 DefaultEqualityHelperFactory (org.eclipse.emf.compare.match.DefaultEqualityHelperFactory)4 IComparisonFactory (org.eclipse.emf.compare.match.IComparisonFactory)4 EMFCompare (org.eclipse.emf.compare.EMFCompare)3 MatchEngineFactoryRegistryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl)3 DiffBuilder (org.eclipse.emf.compare.diff.DiffBuilder)2 IMatchEngine (org.eclipse.emf.compare.match.IMatchEngine)2 MatchEngineFactoryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl)2 CompareConfiguration (org.eclipse.compare.CompareConfiguration)1 CompareEditorInput (org.eclipse.compare.CompareEditorInput)1 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)1 Comparison (org.eclipse.emf.compare.Comparison)1 Diff (org.eclipse.emf.compare.Diff)1 Builder (org.eclipse.emf.compare.EMFCompare.Builder)1 DefaultDiffEngine (org.eclipse.emf.compare.diff.DefaultDiffEngine)1 FeatureFilter (org.eclipse.emf.compare.diff.FeatureFilter)1 IDiffEngine (org.eclipse.emf.compare.diff.IDiffEngine)1 IDiffProcessor (org.eclipse.emf.compare.diff.IDiffProcessor)1 ICompareEditingDomain (org.eclipse.emf.compare.domain.ICompareEditingDomain)1