Skip to main content
13-Aquamarine
July 5, 2022
Question

How to get specific version of object?

  • July 5, 2022
  • 3 replies
  • 1776 views

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

HelesicPetr
22-Sapphire II
22-Sapphire II
July 7, 2022

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

 

avillanueva
23-Emerald I
23-Emerald I
July 7, 2022

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

aPart.getVersionIdentifier().getValue();

avillanueva
23-Emerald I
23-Emerald I
July 7, 2022

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;
 }
 }