|
|
Re: EMF Transaction find deleted elements [message #885331 is a reply to message #885281] |
Tue, 12 June 2012 20:32 |
|
Hi, Felix,
Objects that were deleted will no longer be attached to a resource. I
think you need only process the "old value" objects of REMOVE and
REMOVE_MANY notifications for which eResource() is now null.
HTH,
Christian
On 2012-06-12 18:28:54 +0000, Felix Dorner said:
> Hi,
>
> I need to respond with some action if one or more elements are deleted
> from a TransactionalResourceSet. Previously we just adapted the
> DeleteCommand with a homegrown notification mechanism, but someone
> raised an objection. I now try to "detect" elements that are deleted on
> a per-transaction base via an EMFT ResourceSetListener somehow like
> this:
>
> resourceSetChanged(RSCEvent event){
> Set orphaned = new HashSet();
> switch (Notificationtype){
> case Add: orphaned.remove(...)
> case Remove: orphaned.add(...)
> [...]
> }
> }
>
> It seems to work but it does feel somewhat hackish..
> Maybe there's a better solution? I tried
> event.getTransaction().getChangeModel().getDetachedObjects() but that
> doesn't return anything.
>
> Thanks for comments,
> Felix
|
|
|
Re: EMF Transaction find deleted elements [message #885346 is a reply to message #885331] |
Tue, 12 June 2012 21:05 |
Felix Dorner Messages: 676 Registered: July 2009 |
Senior Member |
|
|
El 12/06/2012 22:32, Christian W. Damus escribió:
> Hi, Felix,
>
> Objects that were deleted will no longer be attached to a resource. I
> think you need only process the "old value" objects of REMOVE and
> REMOVE_MANY notifications for which eResource() is now null.
Oh yes, that's better. I thought doing so would accidentially count the
'moved' ones, but forgot the fact that I am in fact notified after the
whole thing already happened, not in between remove/add as with normal
EMF notifications.
Thanks Christian. Btw it's a pleasure to read your code.
> HTH,
>
> Christian
>
>
> On 2012-06-12 18:28:54 +0000, Felix Dorner said:
>
>> Hi,
>>
>> I need to respond with some action if one or more elements are deleted
>> from a TransactionalResourceSet. Previously we just adapted the
>> DeleteCommand with a homegrown notification mechanism, but someone
>> raised an objection. I now try to "detect" elements that are deleted
>> on a per-transaction base via an EMFT ResourceSetListener somehow like
>> this:
>>
>> resourceSetChanged(RSCEvent event){
>> Set orphaned = new HashSet();
>> switch (Notificationtype){
>> case Add: orphaned.remove(...)
>> case Remove: orphaned.add(...)
>> [...]
>> }
>> }
>>
>> It seems to work but it does feel somewhat hackish..
>> Maybe there's a better solution? I tried
>> event.getTransaction().getChangeModel().getDetachedObjects() but that
>> doesn't return anything.
>>
>> Thanks for comments,
>> Felix
>
>
|
|
|
Re: EMF Transaction find deleted elements [message #885438 is a reply to message #885346] |
Wed, 13 June 2012 01:56 |
|
Felix,
I'm glad it's working for you.
And thanks! I'm glad to be able to give you something good to read.
There's so much junk on the Interwebs. ;-)
Yes, that displacement in time can be a blessing but it can also bite,
because for any feature that changed more than once, only the last
notification makes sense when interpreted as a delta from the object's
current state to the previous. All prior notifications are relative to
earlier states that the object isn't in, now.
cW
On 2012-06-12 21:05:50 +0000, Felix Dorner said:
> El 12/06/2012 22:32, Christian W. Damus escribió:
>> Hi, Felix,
>>
>> Objects that were deleted will no longer be attached to a resource. I
>> think you need only process the "old value" objects of REMOVE and
>> REMOVE_MANY notifications for which eResource() is now null.
>
> Oh yes, that's better. I thought doing so would accidentially count the
> 'moved' ones, but forgot the fact that I am in fact notified after the
> whole thing already happened, not in between remove/add as with normal
> EMF notifications.
>
> Thanks Christian. Btw it's a pleasure to read your code.
>
>
>> HTH,
>>
>> Christian
>>
>>
>> On 2012-06-12 18:28:54 +0000, Felix Dorner said:
>>
>>> Hi,
>>>
>>> I need to respond with some action if one or more elements are deleted
>>> from a TransactionalResourceSet. Previously we just adapted the
>>> DeleteCommand with a homegrown notification mechanism, but someone
>>> raised an objection. I now try to "detect" elements that are deleted
>>> on a per-transaction base via an EMFT ResourceSetListener somehow like
>>> this:
>>>
>>> resourceSetChanged(RSCEvent event){
>>> Set orphaned = new HashSet();
>>> switch (Notificationtype){
>>> case Add: orphaned.remove(...)
>>> case Remove: orphaned.add(...)
>>> [...]
>>> }
>>> }
>>>
>>> It seems to work but it does feel somewhat hackish..
>>> Maybe there's a better solution? I tried
>>> event.getTransaction().getChangeModel().getDetachedObjects() but that
>>> doesn't return anything.
>>>
>>> Thanks for comments,
>>> Felix
|
|
|
Powered by
FUDForum. Page generated in 0.02883 seconds