Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Compare] Exception while merge(): "The feature XY does not exist in Project"
[EMF Compare] Exception while merge(): "The feature XY does not exist in Project" [message #673921] Wed, 25 May 2011 03:43 Go to next message
philipp.hauer is currently offline philipp.hauer
Messages: 13
Registered: February 2010
Junior Member
Hello,

I want to compare two modells of the same metamodel with EMFCompare.
The first model originates from a xtext-DSL-Model. The second one is a model I checkout out from EMFStore. So they differ completely in their resource types.

My Code looks like this:
EcoreUtil2.resolveAll(newKMModel);
EcoreUtil2.resolveAll(oldRepoModel);
System.out.println("res newKMModel: " + newKMModel.eResource());
//org.eclipse.xtext.linking.lazy.LazyLinkingResource@1ac0d45 uri='/de.siv.kvasy.client.appl.crm.gui/src/main/model/customer_CustomerDisplayComponent.km'
System.out.println("res oldRepoModel: " + oldRepoModel.eResource());
//org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl@1bd1302 uri='file:/C:/Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_jAXNEIaeEeC4dqMKH95AxA/project/0.upf'
                    
EMFCOMPARE_OPTIONS.put(MatchOptions.OPTION_DISTINCT_METAMODELS, false);
                    
MatchModel match = MatchService.doMatch(newKMModel, oldRepoModel,EMFCOMPARE_OPTIONS);
ModelUtils.save(match,"C:/Match.diff");
DiffModel diff = DiffService.doDiff(match, false);
ModelUtils.save(diff,"C:/Diff.diff");
List<DiffElement> differences = new ArrayList<DiffElement>(diff.getOwnedElements());
MergeService.merge(differences, true);


Running the Code, I get an FactoryExeption at the line "MergeService.merge(differences, true);":
org.eclipse.emf.compare.FactoryException: The feature guiDomain does not exist in Project.
	at org.eclipse.emf.compare.util.EFactory.eStructuralFeature(EFactory.java:262)
	at org.eclipse.emf.compare.util.EFactory.eGet(EFactory.java:128)
	at org.eclipse.emf.compare.util.EFactory.eGetAsList(EFactory.java:162)
	at org.eclipse.emf.compare.diff.engine.check.ReferencesCheck.checkContainmentReferenceOrderChange(ReferencesCheck.java:139)
	at org.eclipse.emf.compare.diff.engine.check.ReferencesCheck.checkReferencesUpdates(ReferencesCheck.java:79)
	at org.eclipse.emf.compare.diff.engine.GenericDiffEngine.checkForDiffs(GenericDiffEngine.java:330)
	at org.eclipse.emf.compare.diff.engine.GenericDiffEngine.doDiffDelegate(GenericDiffEngine.java:884)
	at org.eclipse.emf.compare.diff.engine.GenericDiffEngine.doDiffTwoWay(GenericDiffEngine.java:566)
	at org.eclipse.emf.compare.diff.engine.GenericDiffEngine.doDiff(GenericDiffEngine.java:105)
	at org.eclipse.emf.compare.diff.service.DiffService.doDiff(DiffService.java:102)
	at de.archtech.kvasy.ide.core.ui.navigator.internal.actions.provider.RefreshActionProvider$7$1.compare(RefreshActionProvider.java:416)
	at de.archtech.kvasy.ide.core.ui.navigator.internal.actions.provider.RefreshActionProvider$7$1.run(RefreshActionProvider.java:345)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)



The Matchmodel Match.diff looks like this:
<?xml version="1.0" encoding="UTF8"?>
<match:MatchModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:match="http://www.eclipse.org/emf/compare/match/1.1">
  <matchedElements xsi:type="match:Match2Elements" similarity="0.012048192771084338">
    <leftElement href="/de.siv.kvasy.client.appl.crm.gui/src/main/model/customer_CustomerDisplayComponent.km#/"/>
    <rightElement href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#/0"/>
  </matchedElements>
  <unmatchedElements>
    <element href="/de.siv.kvasy.client.appl.crm.gui/src/main/model/customer_CustomerDisplayComponent.km#//@guiDomain"/>
  </unmatchedElements>
  <unmatchedElements side="Right">
    <element href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#_9dqdEIXYEeCc868P523i2w"/>
  </unmatchedElements>
  <leftRoots href="/de.siv.kvasy.client.appl.crm.gui/src/main/model/customer_CustomerDisplayComponent.km#/"/>
  <rightRoots href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#/0"/>
  <rightRoots href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#_9dqdEIXYEeCc868P523i2w"/>
</match:MatchModel>



The Diffmodel Diff.diff looks like this:
<?xml version="1.0" encoding="UTF8"?>
<diff:DiffModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:diff="http://www.eclipse.org/emf/compare/diff/1.1">
  <ownedElements xsi:type="diff:DiffGroup">
    <subDiffElements xsi:type="diff:DiffGroup">
      <subDiffElements xsi:type="diff:ModelElementChangeLeftTarget">
        <rightParent href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#/0"/>
        <leftElement href="/de.siv.kvasy.client.appl.crm.gui/src/main/model/customer_CustomerDisplayComponent.km#//@guiDomain"/>
      </subDiffElements>
      <subDiffElements xsi:type="diff:ModelElementChangeRightTarget">
        <leftParent href="/de.siv.kvasy.client.appl.crm.gui/src/main/model/customer_CustomerDisplayComponent.km#/"/>
        <rightElement href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#_9dqdEIXYEeCc868P523i2w"/>
      </subDiffElements>
      <rightParent href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#/0"/>
    </subDiffElements>
  </ownedElements>
  <leftRoots href="/de.siv.kvasy.client.appl.crm.gui/src/main/model/customer_CustomerDisplayComponent.km#/"/>
  <rightRoots href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#/0"/>
  <rightRoots href="Dokumente%20und%20Einstellungen/phauer/.unicase/client/profiles/default/ps-_dyoSAIagEeC-QtnliX5fSA/project/0.upf#_9dqdEIXYEeCc868P523i2w"/>
</diff:DiffModel>


To get an impression of the Metamodel and the correct result I serialized once both models via ModelUtils.save() and compared the files via the EMFCompare eclipse plugin:
http://dl.dropbox.com/u/14402576/compare.png

I'm looking forward for any reponse, since this comparison is extremely important for our project.

Best regards
Philipp
Re: [EMF Compare] Exception while merge(): "The feature XY does not exist in Project" [message #673958 is a reply to message #673921] Wed, 25 May 2011 05:42 Go to previous messageGo to next message
philipp.hauer is currently offline philipp.hauer
Messages: 13
Registered: February 2010
Junior Member
Even when I copy a model (for instance newKMModel) twice and change an attribute of one copy manually, I still get an exception, while merging the both copys.

Model copy1 = EcoreUtil.copy(newKMModel);
Model copy2 = EcoreUtil.copy(newKMModel);

System.out.println("Text before: "+getGuiTextProperty(copy2).getDraft());
getGuiTextProperty(copy1).setDraft("WOOOOH");
                    
ModelUtils.save(copy1, "C:/copy1.bla");
ModelUtils.save(copy2, "C:/copy2.bla");
                                       
MatchModel match = MatchService.doMatch(copy1, copy2, EMFCOMPARE_OPTIONS);
ModelUtils.save(match, "C:/ManuellMatch.diff");
DiffModel diff = DiffService.doDiff(match, false);
ModelUtils.save(diff, "C:/ManuellDiff.diff");
List<DiffElement> differences = new ArrayList<DiffElement>(diff.getOwnedElements());
MergeService.merge(differences, true);
                    
System.out.println("Text after: "+getGuiTextProperty(copy2).getDraft());

//getGuiTextProperty() is just a util method to get a specific attribute.


Exception:
Caused by: java.lang.NullPointerException
	at org.eclipse.emf.compare.diff.internal.merge.impl.ModelElementChangeRightTargetMerger.undoInTarget(ModelElementChangeRightTargetMerger.java:96)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger.undoInTarget(DiffGroupMerger.java:48)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger.undoInTarget(DiffGroupMerger.java:48)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger.undoInTarget(DiffGroupMerger.java:48)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger.undoInTarget(DiffGroupMerger.java:48)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger.undoInTarget(DiffGroupMerger.java:48)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger.undoInTarget(DiffGroupMerger.java:48)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at org.eclipse.emf.compare.diff.internal.merge.impl.DiffGroupMerger.undoInTarget(DiffGroupMerger.java:48)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.doMerge(MergeService.java:166)
	at org.eclipse.emf.compare.diff.merge.service.MergeService.merge(MergeService.java:130)
	at de.archtech.kvasy.ide.core.ui.navigator.internal.actions.provider.RefreshActionProvider$7$1.copyAndChangeManuelleyThenDiff(RefreshActionProvider.java:473)
	at de.archtech.kvasy.ide.core.ui.navigator.internal.actions.provider.RefreshActionProvider$7$1.run(RefreshActionProvider.java:351)
	... 1 more


Strangely, when I compare the copy1.bla with copy2.bla with the emf compare plug-in the differences are correctly found. Consequently the way I use the API has to be wrong.

Best Regards
Philipp

[Updated on: Wed, 25 May 2011 05:43]

Report message to a moderator

Re: [EMF Compare] Exception while merge(): "The feature XY does not exist in Project" [message #674246 is a reply to message #673958] Thu, 26 May 2011 05:38 Go to previous messageGo to next message
philipp.hauer is currently offline philipp.hauer
Messages: 13
Registered: February 2010
Junior Member
I solved that problem by:

* merging from right to left (MergeService.merge(differences, false)). Seems to be a bug in EMFCompare. The eclipse plugin has the same problem: Only one direction allows saving.
* using content match instead of the normal match, because one model has parents, that are not supposed to be concerned during matching.
* implementing my own MatchEngine (extending GenericMatchEngine) and override setModelRoots() in a way, that only the objects are set as the left and right roots - not the whole content of the resource like in the default implementation
* setting MatchOptions.OPTION_DISTINCT_METAMODELS to true
* setting MatchOptions.OPTION_IGNORE_XMI_ID to true

Puh, but now it works fine. Smile

[Updated on: Thu, 26 May 2011 05:41]

Report message to a moderator

Re: [EMF Compare] Exception while merge(): "The feature XY does not exist in Project" [message #675162 is a reply to message #674246] Mon, 30 May 2011 09:10 Go to previous message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1609
Registered: July 2009
Senior Member
Hi Philipp,

Wow, three messages, and you've already found an answer, before I even saw the first Smile.

Some of the conclusions you end up with are troubling.

> merging from right to left (MergeService.merge(differences, false)). Seems to be a bug in EMFCompare. The eclipse plugin has the same problem: Only one direction allows saving.

This usually means that we couldn't load "one of the sides" from a full URL, and thus don't know "where" to save ... in which case we'll disable merging to that side. Do you know which of the two resources provokes this? And what happens if you try to compare two such resources? Is the merging disabled in both directions?

> using content match instead of the normal match, because one model has parents, that are not supposed to be concerned during matching.

That can also be solved through the "resource" match, the "normal" being "resource set" match.

> implementing my own MatchEngine [...]

Didn't really understand that. What was wrong with the default implementation in your case?

> setting MatchOptions.OPTION_DISTINCT_METAMODELS to true

This option prevents EMF Compare from doing a "object1.eClass().isInstance(object2.eClass())" and stopping if the classes don't correspond. That would indicate that the two models you're comparing are either referencing different meta models, or that these two meta models have been loaded from two disting URIs.

Laurent Goubet
Obeo
Previous Topic:[EEF] Using JMerge in the EEF Editor class
Next Topic:[EMF Compare] opening editor programmatically results in unexpected/wrong view
Goto Forum:
  


Current Time: Sat Apr 19 18:29:20 EDT 2014

Powered by FUDForum. Page generated in 0.04938 seconds