cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to get specific version of object?

WM_9965332
12-Amethyst

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 3

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
22-Sapphire II
(To:WM_9965332)

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

aPart.getVersionIdentifier().getValue();

avillanueva
22-Sapphire II
(To:WM_9965332)

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

 

Announcements

Top Tags