Средство сравнения EMF не может определить nestedClassifier при сравнении модели UML

Мы пытаемся использовать инструмент сравнения EMF в Eclipse для сравнения следующей модели UML:

<?xml version="1.0" encoding="UTF-8"?>
    <xmi:XMI xmi:version="20110701" xmlns:xmi="http://www.omg.org/spec/XMI/20110701" xmlns:CDA="http://www.openhealthtools.org/mdht/schemas/cda/4" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML">
      <uml:Package xmi:id="PackageId" name="PackageA">
         <nestedClassifier xmi:type="uml:Class" xmi:id="nestedClassifierId" name="nestedClassifier">
            <ownedComment xmi:id="ownedCommentId">
              <body>Body of the article.</body>
            </ownedComment>
         </nestedClassifier>
      </uml:Package>
    </xmi:XMI>

Следуя документации сравнения EMF: http://www.eclipse.org/emf/compare/documentation/latest/developer/developer-guide.html Мы написали следующий класс для сравнения UML:

 import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.uml2.uml.resource.UMLResource;

public class EMFcompare {
    EList<Diff> differences;

    public static void main(String[] args) {
        // compare two models which are exactly the same
        Comparison comparison = compare("./models/MinimalModel.uml", "./models/MinimalModel.uml");

        // output the comparison result
        System.out.println(comparison.getDifferences().size());
        for (Diff diff : comparison.getDifferences()) {
            System.out.println("Diff");
            System.out.println("Kind is " + diff.getKind());
            System.out.println("State: " + diff.getState());
            System.out.println(diff);
            System.out.println("---------------------------------------------------------------------");
        }
    }

    public static Comparison compare(String uml1, String uml2) {
        // create uri for loading resource set 
        URI uri1 = URI.createFileURI(uml1);
        URI uri2 = URI.createFileURI(uml2);

        // Register the UML format for model comparison
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("uml", UMLResource.Factory.INSTANCE);

        // Load resource sets
        ResourceSet resourceSet1 = new ResourceSetImpl();
        ResourceSet resourceSet2 = new ResourceSetImpl();
        resourceSet1.getResource(uri1, true);
        resourceSet2.getResource(uri2, true);

        // Compare output uml model with the expected uml model
        Comparison comparison = EMFCompare.builder().build().compare(EMFCompare.createDefaultScope(resourceSet1, resourceSet2, null));

        return comparison;
    }
}

В классе мы загружали одну и ту же модель UML дважды, поэтому две сравниваемые модели абсолютно одинаковы. Тем не менее, выходной результат показывает, что между двумя моделями есть некоторые различия:

2
Diff
Kind is ADD
State: UNRESOLVED
AttributeChangeSpec{attribute=AnyType.mixed, value=body=org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@cd2dae5 (mixed: [ecore.xml.type:text=Body of the article.], anyAttribute: null), kind=ADD, source=LEFT, state=UNRESOLVED}
---------------------------------------------------------------------
Diff
Kind is DELETE
State: UNRESOLVED
AttributeChangeSpec{attribute=AnyType.mixed, value=body=org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@53f65459 (mixed: [ecore.xml.type:text=Body of the article.], anyAttribute: null), kind=DELETE, source=LEFT, state=UNRESOLVED}
---------------------------------------------------------------------

Ожидаемый результат должен указывать на отсутствие различий между двумя моделями UML. Похоже, что сравнение EMF не поддерживает сравнение nestedClassifier. Можно ли использовать какой-либо метод для улучшения нашего класса сравнения EMF для решения этой проблемы?

0 ответов

Другие вопросы по тегам