getMergedBaselineHistory does not return all baselines reliably
Sometimes baselines in a stream are not visible.
I get all baselines of a component using below code:
I get the Baselines delivered into Stream using below code:
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?
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
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 ...
while (historicBaselineIterator.hasPrevious()) { historicBaselineIterator = historicBaselineIterator.getPrevious(MAX_BASELINE_FETCH_FROM_NEWER_TO_OLDER, progressMonitor); baselineHandles = (List<IBaselineHandle>) historicBaselineIterator.getBaselines();
//...do something to store baselineHandles ...
}
Comments
Evan Hughes
JAZZ DEVELOPER Nov 18 '14, 10:41 a.m.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?
1 vote
Ramesh V Raghupathi
Mar 05 '15, 10:21 p.m.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.