getMergedBaselineHistory does not return all baselines reliably
![]()
Ramesh V Raghupathi (16●2●3)
| asked Aug 21 '14, 12:19 a.m.
edited Aug 27 '14, 11:37 a.m. by Ralph Earle (257●3●9)
Sometimes baselines in a stream are not visible.
I get all baselines of a component using below code: IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(getRepo()); IItemManager itemManager = getRepo().itemManager(); IBaseline baseline = null; IBaselineSearchCriteria baselineCriteria = IBaselineSearchCriteria.FACTORY.newInstance(); baselineCriteria.setComponentRequired(component); if (isPartialName) { baselineCriteria.setPartialName(baselineName); } else { baselineCriteria.setExactName(baselineName); } List<? extends IBaselineHandle> allBaselines = workspaceManager.findBaselines(baselineCriteria, Integer.MAX_VALUE, null); I get the Baselines delivered into Stream using below code: IHistoricBaselineIterator historicBaselineIter; historicBaselineIter = componentContainer.getMergedBaselineHistory(component, Integer.MAX_VALUE, null); List<? extends IBaselineHandle> baselinesInHistory = historicBaselineIter.getBaselines(); And using a search algorithm, I try to find if the baseline of specific partial name available in stream. The problem, if the baseline is on top of stream, it is always found. When there are baselines above the required baseline, code some times finds it and some times says baseline not found. Is there some thing wrong in this code / approach? How to handle this situation? |
2 answers
![]()
Unlike Java Iterator, which updates itself about new instance, IHistoricBaselineIterator
is paged and the instance returned by getPrevious is to be used for looking in new page. Unless this is done, we are always stuck in first page.
|
![]()
Yes, something like this
historicBaselineIterator = workspaceConnection.getMergedBaselineHistory( componentHandle, MAX_BASELINE_FETCH_FROM_NEWER_TO_OLDER, progressMonitor); List<IBaselineHandle> baselineHandles = (List<IBaselineHandle>) historicBaselineIterator.getBaselines(); //...do something to store baselineHandles ... } |
Comments
Which list doesn't contain the baseline you expect? Is it allBaselines or baselinesInHistory ?
The list returned by IHistoricBaselineIterator is paged. Do you walk those pages?
baselinesInHistory doesn't contain the baseline I expect.
IHistoricBaselineIterator is paged and I am walking through all the pages using getPrevious. However the mistake I did was that I did not use the instance returned by getPrevious that has to be used for looking in new page.
This I overlooked in API documentation as the normal Java Iterator behaviour is that instance gets updated and does not return an updated instance.