It's all about the answers!

Ask a question

RTC Java api list snapshots on a stream


sam matthews (434) | asked Oct 23 '13, 4:28 a.m.
retagged Dec 03 '13, 4:48 p.m. by David Lafreniere (4.8k7)
 I want to simply list the latest snapshot for a given stream using the java api.

Any code example would be great.

Thanks

Accepted answer


permanent link
Martin Muellenberg (7259) | answered Oct 24 '13, 8:27 a.m.
edited Oct 24 '13, 1:20 p.m.
Firstly, snapshots are called baseline sets in the RTC Plain Java API. Knowing this, you can get the snaptshots via IWorkspaceManager.findBaselineSets():

ITeamRepository repository = ...;
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);

Just hand in your given stream as the workspaceHandle to the following method:

@SuppressWarnings("unchecked")
private List<IBaselineSetHandle> getBaselineSetHandles(IWorkspaceHandle workspaceHandle)
                                                throws TeamRepositoryException {
      IBaselineSetSearchCriteria searchCriteria = IBaselineSetSearchCriteria.FACTORY.newInstance();           
      searchCriteria.setOwnerWorkspaceOptional(workspaceHandle);

      return workspaceManager.findBaselineSets(searchCriteria, Integer.MAX_VALUE, monitor);
}

Then you can loop through the returned List<IBaselineSetHandle> and get each BaseLineSet (== snapshot) with the following method:

private IBaselineSet getBaselineSet(IBaselineSetHandle baselineSetHandle)
                                                throws TeamRepositoryException {
        return (IBaselineSet) repository.itemManager().fetchCompleteItem(baselineSetHandle, IItemManager.DEFAULT, monitor);
}

Hopefully, that is of help.





Ralph Schoon selected this answer as the correct answer

Your answer


Register or to post your answer.