Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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:

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?

1 vote

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?

1 vote

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
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.

0 votes


Permanent link
 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 ...
}


0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 1,202
× 84
× 79

Question asked: Aug 21 '14, 12:19 a.m.

Question was seen: 5,702 times

Last updated: May 24 '16, 9:04 a.m.

Confirmation Cancel Confirm