use of org.eclipse.emf.compare.scope.DefaultComparisonScope 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;
}
use of org.eclipse.emf.compare.scope.DefaultComparisonScope 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;
}
use of org.eclipse.emf.compare.scope.DefaultComparisonScope 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;
}
use of org.eclipse.emf.compare.scope.DefaultComparisonScope 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;
}
use of org.eclipse.emf.compare.scope.DefaultComparisonScope 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);
}
Aggregations