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