Search in sources :

Example 1 with Diff

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

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

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

the class AbtractTest method diff.

protected Comparison diff(TableContainer left, TableContainer right) throws Exception {
    Comparison comparison = DatabaseCompareService.compare(left, right);
    assertNotNull(comparison);
    // DatabaseChangeSet databaseChangeSet = null;
    // if (comparison instanceof DatabaseChangeSet) {
    // databaseChangeSet = (DatabaseChangeSet) comparison;
    // }
    // assertNotNull(databaseChangeSet);
    DiffContentService DiffContentService = new DiffContentService();
    System.out.println("---- Print ChangeSet -----");
    for (Diff element : comparison.getDifferences()) {
        System.out.println("\t" + element.eClass().getName());
        List<Diff> subDiffs = DiffContentService.getSubDiffs(element, comparison);
        if (!subDiffs.isEmpty()) {
            for (Diff e : subDiffs) {
                System.out.println("\t\t" + e.eClass().getName() + "(" + e + ")");
            }
        }
    }
    return comparison;
}
Also used : Comparison(org.eclipse.emf.compare.Comparison) Diff(org.eclipse.emf.compare.Diff) DiffContentService(org.obeonetwork.dsl.database.compare.extensions.services.DiffContentService)

Example 4 with Diff

use of org.eclipse.emf.compare.Diff 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 Diff

use of org.eclipse.emf.compare.Diff 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

Diff (org.eclipse.emf.compare.Diff)14 Comparison (org.eclipse.emf.compare.Comparison)7 EList (org.eclipse.emf.common.util.EList)6 EMFCompare (org.eclipse.emf.compare.EMFCompare)6 ReferenceChange (org.eclipse.emf.compare.ReferenceChange)6 DefaultComparisonScope (org.eclipse.emf.compare.scope.DefaultComparisonScope)6 IComparisonScope (org.eclipse.emf.compare.scope.IComparisonScope)6 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)6 ArrayList (java.util.ArrayList)5 List (java.util.List)5 EObject (org.eclipse.emf.ecore.EObject)4 DBDiff (org.obeonetwork.dsl.database.dbevolution.DBDiff)4 Match (org.eclipse.emf.compare.Match)3 HashSet (java.util.HashSet)2 DiffContentService (org.obeonetwork.dsl.database.compare.extensions.services.DiffContentService)2 CompareConfiguration (org.eclipse.compare.CompareConfiguration)1 CompareEditorInput (org.eclipse.compare.CompareEditorInput)1 AdapterFactory (org.eclipse.emf.common.notify.AdapterFactory)1 AttributeChange (org.eclipse.emf.compare.AttributeChange)1 ICompareEditingDomain (org.eclipse.emf.compare.domain.ICompareEditingDomain)1