Search in sources :

Example 1 with ReferenceChange

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

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

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

use of org.eclipse.emf.compare.ReferenceChange in project statecharts by Yakindu.

the class EdgeChangePostProcessor method postProcessEdgeDeletion.

/**
 * In this case by default following dependencies are created:<br>
 * <br>
 * EdgeDeletion <-requires-- OutgoingTransitionDeletion --requires->
 * IncomingTransitionDeletion<br>
 * <br>
 * Needs to be changed into:<br>
 * <br>
 * EdgeDeletion --requires-> OutgoingTransitionDeletion --requires->
 * IncomingTransitionDeletion<br>
 *
 * @param edgeChange
 */
private void postProcessEdgeDeletion(EdgeChange edgeChange) {
    Set<Diff> requiredOutgoingTransitionDeletions = new HashSet<Diff>();
    for (Diff requireds : edgeChange.getRequiredBy()) {
        if (requireds instanceof ReferenceChange) {
            ReferenceChange requiredRefChange = (ReferenceChange) requireds;
            // to add the corresponding change in incoming transition refs
            if (requiredRefChange.getReference() == SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS && requiredRefChange.getKind() == DifferenceKind.DELETE) {
                requiredOutgoingTransitionDeletions.add(requiredRefChange);
            }
        }
    }
    edgeChange.getRequires().addAll(requiredOutgoingTransitionDeletions);
}
Also used : Diff(org.eclipse.emf.compare.Diff) ReferenceChange(org.eclipse.emf.compare.ReferenceChange) HashSet(java.util.HashSet)

Example 5 with ReferenceChange

use of org.eclipse.emf.compare.ReferenceChange in project statecharts by Yakindu.

the class EdgeChangePostProcessor method postProcessEdgeAddition.

/**
 * In this case by default following dependencies are created:<br>
 * <br>
 * EdgeDeletion --requires-> OutgoingTransitionDeletion <-requires--
 * IncomingTransitionDeletion<br>
 * <br>
 * Needs to be changed into:<br>
 * <br>
 * EdgeDeletion --requires-> IncomingTransitionDeletion --requires->
 * OutgoingTransitionDeletion<br>
 *
 * @param edgeChange
 */
private void postProcessEdgeAddition(EdgeChange edgeChange) {
    Set<Diff> requiredIncomingTransitionAdditions = new HashSet<Diff>();
    for (Diff requireds : edgeChange.getRequires()) {
        if (requireds instanceof ReferenceChange) {
            ReferenceChange requiredRefChange = (ReferenceChange) requireds;
            // to add the corresponding change in incoming transition refs
            if (requiredRefChange.getReference() == SGraphPackage.Literals.VERTEX__OUTGOING_TRANSITIONS && requiredRefChange.getKind() == DifferenceKind.ADD) {
                requiredIncomingTransitionAdditions.addAll(findRequiredIncomingTransitionRefChange(requiredRefChange, DifferenceKind.ADD));
            }
        }
    }
    edgeChange.getRequires().addAll(requiredIncomingTransitionAdditions);
}
Also used : Diff(org.eclipse.emf.compare.Diff) ReferenceChange(org.eclipse.emf.compare.ReferenceChange) HashSet(java.util.HashSet)

Aggregations

Diff (org.eclipse.emf.compare.Diff)6 ReferenceChange (org.eclipse.emf.compare.ReferenceChange)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 EList (org.eclipse.emf.common.util.EList)3 Comparison (org.eclipse.emf.compare.Comparison)3 EMFCompare (org.eclipse.emf.compare.EMFCompare)3 DefaultComparisonScope (org.eclipse.emf.compare.scope.DefaultComparisonScope)3 IComparisonScope (org.eclipse.emf.compare.scope.IComparisonScope)3 EObject (org.eclipse.emf.ecore.EObject)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 HashSet (java.util.HashSet)2 AttributeChange (org.eclipse.emf.compare.AttributeChange)1 Match (org.eclipse.emf.compare.Match)1 DBDiff (org.obeonetwork.dsl.database.dbevolution.DBDiff)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 TdTable (org.talend.cwm.relational.TdTable)1 TaggedValue (orgomg.cwm.objectmodel.core.TaggedValue)1