Is there a API to get the name of only latest snapshot from the stream?
The use case is I have IWorkspaceConnection object and I need to fetch the name of the latest snapshot. There is a api ".getBaselineSets(IProgressMonitor)" , however it lists all the snapshot and the javadocs says "The items in the list not specified to be in any particular order" . Is the first object in the list is the latest one or Is there any other api's to fetch the latest snapshot details?
One answer
As far as I know, to fetch the latest snapshot you have to retrieve the creation dates and compare them.
Pehaps this code snippet I used some time ago for this purpose can help you:
List<?> snapshots = reportStreamConn.getBaselineSets(monitor);
for (Object snapshotObj : snapshots) {
IBaselineSetHandle snapshotHandle = (IBaselineSetHandle) snapshotObj;
IBaselineSet snapshot = (IBaselineSet) repo.itemManager().fetchCompleteItem(snapshotHandle, IItemManager.DEFAULT, monitor);
Date snapshotCreationDate = snapshot.getCreationDate();
// compare the dates and retrieve the most recent
// .....
}