Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Restore Resource from Audit
[CDO] Restore Resource from Audit [message #425786] Mon, 08 December 2008 17:24 Go to next message
Bjoern Sundin is currently offline Bjoern SundinFriend
Messages: 47
Registered: July 2009
Member
In my application I have implemented an optional action "SaveAsVersion" in
order to enter version name and comment before saving the CDOResource. With
the name and comment I also store the timestamp from right after the save
(session.getRepositoryTime()).

The idea is that I would retrieve the Audit from a named save point by using
session.openAudit(new ResourceSetImpl(), timeStamp), and then switch the
root object from the audit view to the running transaction. In this way I
hoped to be able to "load" an older state of the root object's containment
tree and restore as the latest.

I found a promising thread by Andr
Re: [CDO] Restore Resource from Audit [message #425787 is a reply to message #425786] Mon, 08 December 2008 17:48 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Hi Bjoern,

Bjoern Sundin wrote:
> In my application I have implemented an optional action "SaveAsVersion" in
> order to enter version name and comment before saving the CDOResource. With
> the name and comment I also store the timestamp from right after the save
> (session.getRepositoryTime()).
>

You should look at that bugzilla:

256649: Make the concept of "successful commit" explicit and persistent
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256649

it talks about description at commit time and more.

> The idea is that I would retrieve the Audit from a named save point by using
> session.openAudit(new ResourceSetImpl(), timeStamp), and then switch the
> root object from the audit view to the running transaction. In this way I
> hoped to be able to "load" an older state of the root object's containment
> tree and restore as the latest.
>
> I found a promising thread by András Ökrös "[CDO] Version handling
> ( http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 5324.html)"
> partly dealing with this matter. The key sentence for me was: "Just detach
> objects from the audit view and attach them to the transaction before
> committing it".
>
> I have tried this in different ways either by removing and adding between
> the resources (audit and current transaction) as well as casting to
> InternalCDOObject and using the CDUStateMachine.INSTANCE.detach resp.
> CDUStateMachine.INSTANCE.attach, unfortunately without success.
>
This will not work since you are not in a transaction! :-) But you
probably know it now.

> I would really appreciate to know if there is any recommended way to do
> this.
I don't know how to do that at the moment...(easily I mean). I will wait
for Eike's comment...but I will continue to think about it.

>
> Thanks,
> Bjoern
>
>
Re: [CDO] Restore Resource from Audit [message #425791 is a reply to message #425786] Mon, 08 December 2008 18:41 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Bjoern,

Some comments in addition to Simon's below...



Bjoern Sundin schrieb:
> In my application I have implemented an optional action "SaveAsVersion" in
> order to enter version name and comment before saving the CDOResource. With
> the name and comment I also store the timestamp from right after the save
> (session.getRepositoryTime()).
>
session.getRepositoryTime() is only an approximate repository time. In
CDO 2.0 I would recommend to use transaction.getLastCommitTime() which
gives exactly the time that is also stored in the revisions themselves.

> The idea is that I would retrieve the Audit from a named save point by using
> session.openAudit(new ResourceSetImpl(), timeStamp), and then switch the
> root object from the audit view to the running transaction. In this way I
> hoped to be able to "load" an older state of the root object's containment
> tree and restore as the latest.
>
As Simon noticed, it is not possible to change objects in an audit view.
So you can not *move* it to another transaction. Maybe you can copy
selected values from the "old" object in the audit view to a "new"
object inthe transaction?

> I found a promising thread by András Ökrös "[CDO] Version handling
> ( http://dev.eclipse.org/newslists/news.eclipse.tools.emf/msg3 5324.html)"
> partly dealing with this matter. The key sentence for me was: "Just detach
> objects from the audit view and attach them to the transaction before
> committing it".
>
Apologies. The intended semantics of the term "detach" changed several
times in the past. While formerly it meant *local* detachment of an
object from a view, nowadays it means physical removal of the object
from the persistent object graph. And this can only be done in a
transaction.

> I have tried this in different ways either by removing and adding between
> the resources (audit and current transaction) as well as casting to
> InternalCDOObject and using the CDUStateMachine.INSTANCE.detach resp.
> CDUStateMachine.INSTANCE.attach, unfortunately without success.
>
As I said above, audit views do not permit any object modifications,
including addition or removal from the graph. And using internal code
does not seem like a good idea either. I think the only valid approach
is to *copy* data instead of *move* it.

Does this help?

Cheers
/Eike

----
http://thegordian.blogspot.com


> I would really appreciate to know if there is any recommended way to do
> this.
>
> Thanks,
> Bjoern
>
>
>


Previous Topic:[Teneo] hibernate collection lazy loading behavior ?
Next Topic:Dependency on org.eclipse.core.runtime in generated model plug-in
Goto Forum:
  


Current Time: Thu Mar 28 20:28:30 GMT 2024

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

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

Back to the top