Skip to main content
Jul 5, 2022 9:56 PM UTC
Question

How to get specific version of object?

Hello. I am trying to find the specific revision of an object(WTPart/WTDoc). For instance, if I pass in 0.3 or A.1 can I have an api that returns that specific part revision? I am not looking for the previous version just the specific one in the history

3 replies

Jul 7, 2022 8:08 AM UTC

Hi @WM_9965332 

You have to search for it manually.

So you need to go through all iterations and control what iteration and revision are.

PetrH

 

Jul 7, 2022 11:37 AM UTC

So you are looking for the code that strips out the iteration part of the version?

aPart.getVersionIdentifier().getValue();

Jul 7, 2022 11:44 AM UTC

I re-read this. If you are supplying the version identifier, you want the object returned. Ok, did something like that for a static URL content retriever JSP page:

I took in a version letter and looped through the versions to find the one that matched. The VersionControlHelper has other methods to show all iterations.

QuerySpec qs = new QuerySpec(WTDocumentMaster.class);
 qs.appendWhere(new SearchCondition(WTDocumentMaster.class,WTDocumentMaster.NUMBER,SearchCondition.EQUAL, number));

 QueryResult qr = PersistenceHelper.manager.find(qs);
 if(qr.hasMoreElements())
 {
 WTDocumentMaster docm = (WTDocumentMaster) qr.nextElement();
 QueryResult qrLatest = VersionControlHelper.service.allVersionsOf(docm);
 while(qrLatest.hasMoreElements()) 
 {
 WTDocument doc = (WTDocument) qrLatest.nextElement();
 if (version!= null)
 {
 if (!(doc.getVersionIdentifier().getValue().equals(version)))
 continue;
 }
 }