Search in sources :

Example 6 with DefaultComparisonScope

use of org.eclipse.emf.compare.scope.DefaultComparisonScope in project tdq-studio-se by Talend.

the class FileMetadataTableComparisonLevel method compareWithReloadObject.

@Override
protected boolean compareWithReloadObject() throws ReloadCompareException {
    Map<ResourceSet, List<Resource>> rsJrxmlMap = removeJrxmlsFromResourceSet();
    EMFCompare comparator = createDefaultEMFCompare();
    MetadataTable tempOldTable = (MetadataTable) getTempTableFromOldFile();
    if (tempOldTable == null) {
        return false;
    }
    IComparisonScope scope = new DefaultComparisonScope(tempOldTable, (MetadataTable) selectedObj, null);
    Comparison compare = comparator.compare(scope);
    addJrxmlsIntoResourceSet(rsJrxmlMap);
    EList<Diff> differences = compare.getDifferences();
    for (Diff diff : differences) {
        // ignore the move Kind
        if (diff.getKind() == DifferenceKind.MOVE) {
            continue;
        }
        if (diff instanceof ReferenceChange) {
            ReferenceChange refChange = (ReferenceChange) diff;
            if (diff.getKind() == DifferenceKind.ADD) {
                handleRemoveElement(refChange);
            } else if (diff.getKind() == DifferenceKind.DELETE) {
                handleAddElement(refChange);
            }
        }
    }
    tempMetadataTable.getFeature().clear();
    return true;
}
Also used : DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) EMFCompare(org.eclipse.emf.compare.EMFCompare) Comparison(org.eclipse.emf.compare.Comparison) Diff(org.eclipse.emf.compare.Diff) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ReferenceChange(org.eclipse.emf.compare.ReferenceChange) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope)

Example 7 with DefaultComparisonScope

use of org.eclipse.emf.compare.scope.DefaultComparisonScope in project InformationSystem by ObeoNetwork.

the class DatabaseCompareService method compare.

public static Comparison compare(TableContainer source, TableContainer target) throws Exception {
    // Prepare using specific match engine
    IMatchEngine.Factory matchEngineFactory = new DatabaseMatchEngineFactory();
    matchEngineFactory.setRanking(20);
    IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
    matchEngineRegistry.add(matchEngineFactory);
    // Prepare using post processor
    IPostProcessor customPostProcessor = new DatabasePostProcessor();
    IPostProcessor.Descriptor descriptor = new BasicPostProcessorDescriptorImpl(customPostProcessor, NS_URI_PATTERN_FOR_POST_PROCESSOR, null);
    IPostProcessor.Descriptor.Registry<Object> postProcessorRegistry = new PostProcessorDescriptorRegistryImpl<Object>();
    postProcessorRegistry.put(DatabasePostProcessor.class.getName(), descriptor);
    EMFCompare comparator = EMFCompare.builder().setPostProcessorRegistry(postProcessorRegistry).setMatchEngineFactoryRegistry(matchEngineRegistry).build();
    // Set the "load on demand policy" registry to resolve dependencies to external libraries.
    EMFCompareRCPPlugin.getDefault().getLoadOnDemandPolicyRegistry().addPolicy(new DependenciesLoadOnDemandPolicy());
    // Compare the two models
    IComparisonScope scope = new DefaultComparisonScope(source, target, null);
    return comparator.compare(scope);
}
Also used : PostProcessorDescriptorRegistryImpl(org.eclipse.emf.compare.postprocessor.PostProcessorDescriptorRegistryImpl) DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) IPostProcessor(org.eclipse.emf.compare.postprocessor.IPostProcessor) DatabaseMatchEngineFactory(org.obeonetwork.dsl.database.compare.extensions.match.DatabaseMatchEngineFactory) MatchEngineFactoryRegistryImpl(org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope) DatabasePostProcessor(org.obeonetwork.dsl.database.compare.extensions.processor.DatabasePostProcessor) DependenciesLoadOnDemandPolicy(org.obeonetwork.dsl.database.compare.extensions.policy.DependenciesLoadOnDemandPolicy) DatabaseMatchEngineFactory(org.obeonetwork.dsl.database.compare.extensions.match.DatabaseMatchEngineFactory) EMFCompare(org.eclipse.emf.compare.EMFCompare) BasicPostProcessorDescriptorImpl(org.eclipse.emf.compare.postprocessor.BasicPostProcessorDescriptorImpl) IMatchEngine(org.eclipse.emf.compare.match.IMatchEngine)

Example 8 with DefaultComparisonScope

use of org.eclipse.emf.compare.scope.DefaultComparisonScope in project InformationSystem by ObeoNetwork.

the class EMFCompareUtils method compare.

/**
 * Compares two {@link Notifier} using the EMF Compare engine.
 *
 * @param expected
 * @param actual
 */
public static Comparison compare(Notifier expected, Notifier actual) {
    final IComparisonScope scope = new DefaultComparisonScope(expected, actual, null);
    final Comparison comparison = comparator.compare(scope);
    return comparison;
}
Also used : DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) Comparison(org.eclipse.emf.compare.Comparison) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope)

Aggregations

DefaultComparisonScope (org.eclipse.emf.compare.scope.DefaultComparisonScope)8 IComparisonScope (org.eclipse.emf.compare.scope.IComparisonScope)8 Comparison (org.eclipse.emf.compare.Comparison)7 EMFCompare (org.eclipse.emf.compare.EMFCompare)7 Diff (org.eclipse.emf.compare.Diff)6 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)6 List (java.util.List)5 EList (org.eclipse.emf.common.util.EList)5 ArrayList (java.util.ArrayList)4 ReferenceChange (org.eclipse.emf.compare.ReferenceChange)3 IMatchEngine (org.eclipse.emf.compare.match.IMatchEngine)2 MatchEngineFactoryRegistryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl)2 EObject (org.eclipse.emf.ecore.EObject)2 CompareConfiguration (org.eclipse.compare.CompareConfiguration)1 CompareEditorInput (org.eclipse.compare.CompareEditorInput)1 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)1 ICompareEditingDomain (org.eclipse.emf.compare.domain.ICompareEditingDomain)1 EMFCompareConfiguration (org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration)1 ComparisonScopeEditorInput (org.eclipse.emf.compare.ide.ui.internal.editor.ComparisonScopeEditorInput)1 DefaultComparisonFactory (org.eclipse.emf.compare.match.DefaultComparisonFactory)1