Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Transaction find deleted elements
EMF Transaction find deleted elements [message #885281] Tue, 12 June 2012 18:28 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
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 #885289 is a reply to message #885281] Tue, 12 June 2012 18:42 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
El 12/06/2012 20:28, Felix Dorner escribió:

> switch (Notificationtype){
> case Add: orphaned.remove(...)
> case Remove: orphaned.add(...)
> [...]

Uhm very pseudocodish.. I just do that for each notification and look at
the orphaned set in the end. Deleted elements should be in the set
after all notifications have been processed.

> 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 #885331 is a reply to message #885281] Tue, 12 June 2012 20:32 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1195
Registered: July 2009
Location: Canada
Senior Member

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 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
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 Go to previous message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1195
Registered: July 2009
Location: Canada
Senior Member

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
Previous Topic:XPand - JMerge Protected Region
Next Topic:[Teneo] Hibernate Auditing Support
Goto Forum:
  


Current Time: Mon Aug 26 00:35:25 GMT 2019

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

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

Back to the top