|
|
Re: [CDO] Restore Resource from Audit [message #425791 is a reply to message #425786] |
Mon, 08 December 2008 18:41 |
|
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
>
>
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Powered by
FUDForum. Page generated in 0.02485 seconds