Search in sources :

Example 1 with EMFCompare

use of org.eclipse.emf.compare.EMFCompare 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 2 with EMFCompare

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

the class DataProviderComparisonLevel method compareWithReloadObject.

@Override
protected boolean compareWithReloadObject() throws ReloadCompareException {
    Map<ResourceSet, List<Resource>> rsJrxmlMap = removeJrxmlsFromResourceSet();
    EMFCompare comparator = createDefaultEMFCompare();
    IComparisonScope scope = new DefaultComparisonScope(oldDataProvider, getSavedReloadObject(), null);
    Comparison compare = comparator.compare(scope);
    // add the jrxml into the ResourceSet after doMatch
    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) {
            EObject value = ((ReferenceChange) diff).getValue();
            if (isCatalogOrSchema(value)) {
                copyRightToLeft(diff);
            }
        }
    }
    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) EObject(org.eclipse.emf.ecore.EObject) ReferenceChange(org.eclipse.emf.compare.ReferenceChange) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope)

Example 3 with EMFCompare

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

the class TableViewComparisonLevel method compareWithReloadObject.

@Override
protected boolean compareWithReloadObject() throws ReloadCompareException {
    // remove the jrxml from the ResourceSet before doMatch
    Map<ResourceSet, List<Resource>> rsJrxmlMap = removeJrxmlsFromResourceSet();
    DBColumnFolderRepNode columnFolderRepNode = (DBColumnFolderRepNode) selectedObj;
    // Compare the two models
    EMFCompare comparator = createDefaultEMFCompare();
    IComparisonScope scope = new DefaultComparisonScope(columnFolderRepNode.getColumnSet(), getSavedReloadObject(), null);
    Comparison compare = comparator.compare(scope);
    // add the jrxml into the ResourceSet after doMatch
    addJrxmlsIntoResourceSet(rsJrxmlMap);
    EList<Diff> differences = compare.getDifferences();
    for (Diff diff : differences) {
        // ignore the move Kind
        if (diff.getKind() == DifferenceKind.MOVE) {
            continue;
        }
        // copy right to left
        copyRightToLeft(diff);
    }
    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) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode)

Example 4 with EMFCompare

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

the class CatalogSchemaComparisonLevel method compareWithReloadObject.

@Override
protected boolean compareWithReloadObject() throws ReloadCompareException {
    // remove the jrxml from the ResourceSet before doMatch
    Map<ResourceSet, List<Resource>> rsJrxmlMap = removeJrxmlsFromResourceSet();
    EMFCompare comparator = createDefaultEMFCompare();
    IComparisonScope scope = new DefaultComparisonScope(getPackageFromObject(selectedObj), getSavedReloadObject(), null);
    Comparison compare = comparator.compare(scope);
    // add the jrxml into the ResourceSet after doMatch
    addJrxmlsIntoResourceSet(rsJrxmlMap);
    EList<Diff> differences = compare.getDifferences();
    for (Diff diff : differences) {
        // ignore the move Kind
        if (diff.getKind() == DifferenceKind.MOVE) {
            continue;
        }
        // ignore others except TdTable and TdView and Related TaggetValue
        if (diff instanceof ReferenceChange) {
            EObject value = ((ReferenceChange) diff).getValue();
            boolean isIgnore = true;
            if (value instanceof TaggedValue) {
                TdTable tableContianer = SwitchHelpers.TABLE_SWITCH.doSwitch(value.eContainer());
                if (tableContianer != null) {
                    isIgnore = false;
                }
            } else if (isValidTableHandle(value) || isValidViewHandle(value)) {
                isIgnore = false;
            }
            if (!isIgnore) {
                copyRightToLeft(diff);
            }
        }
    }
    return true;
}
Also used : TdTable(org.talend.cwm.relational.TdTable) DefaultComparisonScope(org.eclipse.emf.compare.scope.DefaultComparisonScope) Diff(org.eclipse.emf.compare.Diff) TaggedValue(orgomg.cwm.objectmodel.core.TaggedValue) ReferenceChange(org.eclipse.emf.compare.ReferenceChange) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope) EMFCompare(org.eclipse.emf.compare.EMFCompare) Comparison(org.eclipse.emf.compare.Comparison) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 5 with EMFCompare

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

the class AbstractComparisonLevel method compareWithReloadObject.

/**
 * Compare the old selected object with reload object(rightResource), and updated the content of old selected
 * object.
 *
 * @param rightResource
 * @return
 * @throws ReloadCompareException
 */
protected boolean compareWithReloadObject() throws ReloadCompareException {
    Map<ResourceSet, List<Resource>> rsJrxmlMap = removeJrxmlsFromResourceSet();
    EMFCompare comparator = createDefaultEMFCompare();
    IComparisonScope scope = new DefaultComparisonScope(oldDataProvider, getSavedReloadObject(), null);
    Comparison compare = comparator.compare(scope);
    // add the jrxml into the ResourceSet after doMatch
    addJrxmlsIntoResourceSet(rsJrxmlMap);
    EList<Diff> differences = compare.getDifferences();
    for (Diff diff : differences) {
        // ignore the move Kind
        if (diff.getKind() == DifferenceKind.MOVE) {
            continue;
        }
        copyRightToLeft(diff);
    }
    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) List(java.util.List) EList(org.eclipse.emf.common.util.EList) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IComparisonScope(org.eclipse.emf.compare.scope.IComparisonScope)

Aggregations

EMFCompare (org.eclipse.emf.compare.EMFCompare)9 DefaultComparisonScope (org.eclipse.emf.compare.scope.DefaultComparisonScope)7 IComparisonScope (org.eclipse.emf.compare.scope.IComparisonScope)7 Comparison (org.eclipse.emf.compare.Comparison)6 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 MatchEngineFactoryRegistryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryRegistryImpl)4 ReferenceChange (org.eclipse.emf.compare.ReferenceChange)3 DefaultComparisonFactory (org.eclipse.emf.compare.match.DefaultComparisonFactory)3 DefaultEqualityHelperFactory (org.eclipse.emf.compare.match.DefaultEqualityHelperFactory)3 IComparisonFactory (org.eclipse.emf.compare.match.IComparisonFactory)3 IMatchEngine (org.eclipse.emf.compare.match.IMatchEngine)3 IEObjectMatcher (org.eclipse.emf.compare.match.eobject.IEObjectMatcher)3 DiffBuilder (org.eclipse.emf.compare.diff.DiffBuilder)2 MatchEngineFactoryImpl (org.eclipse.emf.compare.match.impl.MatchEngineFactoryImpl)2 EObject (org.eclipse.emf.ecore.EObject)2 CompareConfiguration (org.eclipse.compare.CompareConfiguration)1