|
Re: [CDO] revisions or versions list. [message #1059373 is a reply to message #765150] |
Fri, 17 May 2013 17:43 |
Warwick Burrows Messages: 132 Registered: July 2009 Location: Austin, TX |
Senior Member |
|
|
I hope this is what you're asking, but this is how I have successfully gotten a specific version:
First get the object, then CDOUtil.getRevisionByVersion() to get the specific version, the get that versions timestamp, set it in the view and get by id. I've confirmed this gets the revision of the object that I request.
CDOObject latest = transaction.getObject(cdoID);
CDORevision specificRev = CDOUtil.getRevisionByVersion(latest, version);
CDOID revId = specificRev.getID();
transaction.setTimeStamp(mapRev.getTimeStamp());
CDOObject chosen = getObjectById(revId);
I would *assume* that setting the timestamp on the view will permanently set the view at this revision until the transaction is closed, which is ok if this is all you're going to do with the transaction. I don't know this for sure though as I haven't tested it. I'm about to ask this question to the forum in fact.
[Updated on: Fri, 17 May 2013 17:45] Report message to a moderator
|
|
|
Re: [CDO] revisions or versions list. [message #1059374 is a reply to message #1059373] |
Fri, 17 May 2013 17:52 |
|
Am 17.05.2013 19:43, schrieb Warwick Burrows:
> This is how I have successfully gotten a specific version:
>
> First get the object, then CDOUtil.getRevisionByVersion() to get the specific version, the get that versions
> timestamp, set it in the view and get by id. I've confirmed this gets the revision of the object that I request.
>
> CDOObject latest = transaction.getObject(cdoID);
> CDORevision specificRev = CDOUtil.getRevisionByVersion(latest, version);
> CDOID revId = specificRev.getID();
Here revID is identical to cdoID.
> transaction.setTimeStamp(mapRev.getTimeStamp());
Not sure what mapRev is, but setTimeStamp() delegates to setBranchPoint(), which is overridden in CDOTransactionImpl:
@Override
public synchronized boolean setBranchPoint(CDOBranchPoint branchPoint)
{
if (branchPoint.getTimeStamp() != UNSPECIFIED_DATE)
{
throw new IllegalArgumentException("Changing the target time is not supported by transactions");
}
if (isDirty() && !getBranch().equals(branchPoint.getBranch()))
{
throw new IllegalStateException("Changing the target branch is impossible while transaction is dirty");
}
return super.setBranchPoint(branchPoint);
}
I.e. you can't change the timestamp (of a transaction) to anything but UNSPECIFIED_DATE, or in wother words, you can't
modify the past.
> CDOObject chosen = getObjectById(revId);
What exactly does getObjectById() do and how?
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
>
> I would *assume* that setting the timestamp on the view will permanently set the view at this revision until the
> transaction is closed, which is ok if this is all you're going to do with the transaction. I don't know this for sure
> though as I haven't tested it. I'm about to ask this question to the forum in fact.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03071 seconds