示例#1
0
  private Comparison setupComparison(Resource resource1, Resource resource2) {
    IDiffProcessor customDiffProcessor =
        new DiffBuilder() {
          @Override
          public void attributeChange(
              Match match,
              EAttribute attribute,
              Object value,
              DifferenceKind kind,
              DifferenceSource source) {

            // System.out.println("attributeChange diff algo called. Attribute type : " +
            // attribute.getName());
            if (attribute.getName().equals("id")) {
              // System.out.println("ignored");
              return;
            } else {
              // System.out.println("considered");
              super.attributeChange(match, attribute, value, kind, source);
            }
          }
        };

    IDiffEngine diffEngine = new DefaultDiffEngine(customDiffProcessor);

    IComparisonScope scope = new DefaultComparisonScope(resource1, resource2, null);

    IEObjectMatcher fallBackMatcher =
        DefaultMatchEngine.createDefaultEObjectMatcher(UseIdentifiers.NEVER);
    IEObjectMatcher customIDMatcher = new IdentifierEObjectMatcher(fallBackMatcher, getMatcher());

    IComparisonFactory comparisonFactory =
        new DefaultComparisonFactory(new DefaultEqualityHelperFactory());

    IMatchEngine.Factory matchEngineFactory =
        new MatchEngineFactoryImpl(customIDMatcher, comparisonFactory);
    matchEngineFactory.setRanking(20);

    IMatchEngine.Factory.Registry matchEngineRegistry = new MatchEngineFactoryRegistryImpl();
    matchEngineRegistry.add(matchEngineFactory);

    EMFCompare comparator =
        EMFCompare.builder()
            .setDiffEngine(diffEngine)
            .setMatchEngineFactoryRegistry(matchEngineRegistry)
            .build();

    Comparison comparison = comparator.compare(scope);
    return comparison;
  }
示例#2
0
 public Comparison match(UseIdentifiers useIDs) {
   final IMatchEngine matchEngine = DefaultMatchEngine.create(useIDs);
   comparison = matchEngine.match(scope, new BasicMonitor());
   return comparison;
 }