Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 365530 - Deletion of Objects using EcoreUtil.delete() works wrong
Summary: Deletion of Objects using EcoreUtil.delete() works wrong
Status: CLOSED FIXED
Alias: None
Product: EMFStore
Classification: Modeling
Component: Common (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 0.8.9.M921   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-04 14:55 EST by Eugen Neufeld CLA
Modified: 2012-01-24 10:52 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eugen Neufeld CLA 2011-12-04 14:55:03 EST
Build Identifier: 20110218-0911

I'm currently working with the ModelGenerator and the ModelChanger. 
I created a test case  where  I generate a model, put it into the emfstore, check it out again and compare it with the local version. This works fine. 
But when deleting elements from the model, using the EcoreUtil.delete()- method (as implemented in the generator/changer) then this changes are applied wrong. 
What happens is, that elements on the root level aren't deleted at all. 
Elements on other levels, are moved to the root level instead of being deleted. 

I created a test case in a copy of the org.eclipse.emfstore.client.test project I host at github. 

Reproducible: Always

Steps to Reproduce:
1.Check out the org.eclipse.emf.emfstore.client.test, org.eclipse.emf.emfstore.modelgenerator,org.eclipse.emf.emfstore.modelgenerator.common,org.eclipse.emf.emfstore.modelgenerator.ui and the org.eclipse.example.bowlingmodel,org.eclipse.example.bowlingmodel.edit from
git://github.com/eneufeld/EmfStore-Test.git
2.in org.eclipse.emf.emfstore.client.test.server run the AllServerTest Test-Suite
3.a good way to see what happens, is to set a breakpoint in line 143 of the ModelGeneratorTest class in the same package as the AllServerTest. in the .emfstore folder you can see the current model under client and the two versions  of the store in the server folder.
Comment 1 Max Hohenegger CLA 2011-12-19 12:00:25 EST
Hi Eugen,
I just sent you a pull-request on github.

It looks like the EObject itself remains on the root-level because only an EObjects references, such as the containment reference to the objects parent, is removed when deleting it.
The problem is that an EObject is only considered deleted, if it is no longer connected to the containment tree at the end of a command. (We consider a command to represent a consistent set of changes to a model.)
You could use a DeleteCommand or an AbstractCommand to persistently delete an EObject.

However the bug you reported is of course valid and the framework should
make it more clear if elements are removed without a command, therefore
I open this bug to implement a warning: https://bugs.eclipse.org/bugs/show_bug.cgi?id=367101

I hope this helps.