Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Delete/RemoveCommand does not remove reference from EList
[CDO] Delete/RemoveCommand does not remove reference from EList [message #893026] Mon, 02 July 2012 10:58 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 853
Registered: July 2009
Senior Member
I have the following EClass:

MyType:
+ visibleFeatures: EStructuralFeature (0 .. *)


I.e. my model class has an attribute of type EStructuralFeature with multiplicity set to 'many'.

If I use a Delete/RemoveCommand and execute it using the appropriate editing domain, the EList will still contain the reference:

Command removeCommand = new RemoveCommand(context.getEditingDomain(), eRefList, eObjectToRemove); //this is an EObject of type EStructuralFeature
context.getEditingDomain().getCommandStack().execute(removeCommand);


Is that supposed to work or do I miss something?

[Updated on: Mon, 02 July 2012 11:07]

Report message to a moderator

Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893028 is a reply to message #893026] Mon, 02 July 2012 11:10 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 853
Registered: July 2009
Senior Member
Note:

org.eclipse.emf.ecore.impl.EStoreEObjectImpl.BasicEStoreEList.delegateContains(Object)

returns false when Command.canExecute() is called...
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893065 is a reply to message #893028] Mon, 02 July 2012 13:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
That delegates to the store. So either the object isn't in the list
(you're sure it's in the list?), or the store implementation is faulty
(which store implementation are you using?).

On 02/07/2012 1:10 PM, Erdal Karaca wrote:
> Note:
>
> org.eclipse.emf.ecore.impl.EStoreEObjectImpl.BasicEStoreEList.delegateContains(Object)
>
>
> returns false when Command.canExecute() is called...
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893072 is a reply to message #893065] Mon, 02 July 2012 13:26 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 853
Registered: July 2009
Senior Member
The EList definitely contains (a reference to) the EObject (EStructuralFeature).
Restarting the application shows that the list is not empty.

I am using the hibernate store.

If I override doCanExecute() and just return true, the operation succeeds, i.e. the element will be removed.
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893074 is a reply to message #893072] Mon, 02 July 2012 13:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
Erdal,

This involves CDO? It sounds like a bug. Perhaps you can create a test
case showing that list.contains(x) returns false when it should return true.


On 02/07/2012 3:26 PM, Erdal Karaca wrote:
> The EList definitely contains (a reference to) the EObject
> (EStructuralFeature).
> Restarting the application shows that the list is not empty.
>
> I am using the hibernate store.
>
> If I override doCanExecute() and just return true, the operation
> succeeds, i.e. the element will be removed.
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893087 is a reply to message #893074] Mon, 02 July 2012 14:42 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 853
Registered: July 2009
Senior Member
Ed Merks wrote on Mon, 02 July 2012 09:41
Erdal,

This involves CDO? It sounds like a bug. Perhaps you can create a test
case showing that list.contains(x) returns false when it should return true.


It does not seem to be list.contains(x), but list.containsAll(xAll).

In org.eclipse.emf.edit.command.RemoveCommand.prepare(),
if I execute the following expressions in the debugger

ownerList.containsAll(collection) -> false
ownerList.contains(collection.iterator().next()) -> true

Note: 'collection' is a simple ArrayList with EObjects...
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893091 is a reply to message #893087] Mon, 02 July 2012 14:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
Erdal,

This doesn't look quite right does it!

protected boolean delegateContainsAll(Collection<?> collection)
{
for (Object o : collection)
{
if (!delegateContains(o))
{
return false;
}
}
return true;
}

Please open a bugzilla against EMF core. I'll fix it in the 2.8.1
maintenance stream.


On 02/07/2012 4:42 PM, Erdal Karaca wrote:
> Ed Merks wrote on Mon, 02 July 2012 09:41
>> Erdal,
>>
>> This involves CDO? It sounds like a bug. Perhaps you can create a
>> test case showing that list.contains(x) returns false when it should
>> return true.
>
>
> It does not seem to be list.contains(x), but list.containsAll(xAll).
>
> In org.eclipse.emf.edit.command.RemoveCommand.prepare(),
> if I execute the following expressions in the debugger
>
> ownerList.containsAll(collection) -> false
> ownerList.contains(collection.iterator().next()) -> true
>
> Note: 'collection' is a simple ArrayList with EObjects...
>
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893093 is a reply to message #893091] Mon, 02 July 2012 15:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
Hmm.

Maybe it is right. Can you try to determine why containsAll isn't
working but contains is?

On 02/07/2012 4:59 PM, Ed Merks wrote:
> Erdal,
>
> This doesn't look quite right does it!
>
> protected boolean delegateContainsAll(Collection<?> collection)
> {
> for (Object o : collection)
> {
> if (!delegateContains(o))
> {
> return false;
> }
> }
> return true;
> }
>
> Please open a bugzilla against EMF core. I'll fix it in the 2.8.1
> maintenance stream.
>
>
> On 02/07/2012 4:42 PM, Erdal Karaca wrote:
>> Ed Merks wrote on Mon, 02 July 2012 09:41
>>> Erdal,
>>>
>>> This involves CDO? It sounds like a bug. Perhaps you can create a
>>> test case showing that list.contains(x) returns false when it should
>>> return true.
>>
>>
>> It does not seem to be list.contains(x), but list.containsAll(xAll).
>>
>> In org.eclipse.emf.edit.command.RemoveCommand.prepare(),
>> if I execute the following expressions in the debugger
>>
>> ownerList.containsAll(collection) -> false
>> ownerList.contains(collection.iterator().next()) -> true
>>
>> Note: 'collection' is a simple ArrayList with EObjects...
>>
>
>
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893099 is a reply to message #893093] Mon, 02 July 2012 15:45 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 853
Registered: July 2009
Senior Member
If I just call list.contains(x), then org.eclipse.emf.ecore.util.DelegatingEcoreEList.contains(Object) will be called somewhere to resolve proxies....
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893110 is a reply to message #893099] Mon, 02 July 2012 16:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30439
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Erdal,<br>
<br>
You mentioned containAll having a problem.  DelegatingEList is like
this:<br>
<br>
<small>  /**<br>
   * Returns whether the list contains each object in the
collection.<br>
   * @return whether the list contains each object in the
collection.<br>
   * @see #contains<br>
   * @see #useEquals<br>
   */<br>
  @Override<br>
  public boolean containsAll(Collection&lt;?&gt; collection) <br>
  {<br>
    return delegateContainsAll(collection);<br>
  }<br>
<br>
  /**<br>
   * Returns whether the backing store list contains each object
in the collection.<br>
   * @return whether the backing store list contains each object
in the collection.<br>
   * @see #contains<br>
   * @see #useEquals<br>
   */<br>
  protected boolean delegateContainsAll(Collection&lt;?&gt;
collection) <br>
  {<br>
    return delegateList().containsAll(collection);<br>
  }</small><br>
<br>
And EStoreEList overrides the latter like this:<br>
<br>
<small>   protected boolean delegateContainsAll(Collection&lt;?&gt;
collection)<br>
    {<br>
      for (Object o : collection)<br>
      {<br>
        if (!delegateContains(o))<br>
        {<br>
          return false;<br>
        }<br>
      }<br>
      return true;<br>
    }</small><br>
<br>
So where specifically is something going wrong that contains works
but containsAll doesn't?<br>
<br>
<div class="moz-cite-prefix">On 02/07/2012 5:45 PM, Erdal Karaca
wrote:<br>
</div>
<blockquote cite="mid:jssfm4$3q3$1@xxxxxxxxe.org" type="cite">If
I just call list.contains(x), then
org.eclipse.emf.ecore.util.DelegatingEcoreEList.contains(Object)
will be called somewhere to resolve proxies....
<br>
</blockquote>
<br>
<br>
</body>
</html>
Re: [CDO] Delete/RemoveCommand does not remove reference from EList [message #893336 is a reply to message #893110] Tue, 03 July 2012 15:19 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 853
Registered: July 2009
Senior Member
Thanks, Ed, for the feedback, I will try to provide a test case to reproduce this...
Previous Topic:[EMF .Edit] FeatureMapEntryWrapperItemProvider prepending feature name
Next Topic:[CDO] Cohabitation of both standard EMF and CDO-Native implementations
Goto Forum:
  


Current Time: Sun Sep 15 10:01:30 GMT 2019

Powered by FUDForum. Page generated in 0.02865 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top