It's all about the answers!

Ask a question

getMergedBaselineHistory does not return all baselines reliably


Ramesh V Raghupathi (1623) | asked Aug 21 '14, 12:19 a.m.
edited Aug 27 '14, 11:37 a.m. by Ralph Earle (25739)
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?


Comments
1
Evan Hughes commented Nov 18 '14, 10:40 a.m. | edited Nov 18 '14, 10:41 a.m.
JAZZ DEVELOPER

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?


Ramesh V Raghupathi commented 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.

2 answers



permanent link
Ramesh V Raghupathi (1623) | answered Mar 05 '15, 10:23 p.m.
edited Mar 05 '15, 10:26 p.m.
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.

permanent link
stefano antoniazzi (170711) | answered May 24 '16, 9:04 a.m.
 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 ...
}


Your answer


Register or to post your answer.