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

Obtain a list of baselines for a component in a workspace

Hi,

I want to recover via the Java API a list of baselines of a component, but filtered for a specific workspace. I can obtain a list of baselines for a component but across all workspaces. I want this list filtered for just one specific workspace. I'm using the following code to get a complete list for a component but I don't know how to filter this for a given workspace(Handle)

IBaselineSearchCriteria crit = IBaselineSearchCriteria.FACTORY.newInstance();
crit.setComponentRequired(comp);
List baselines = workspaceManager.findBaselines(crit, Integer.MAX_VALUE, monitor);
for (Iterator b = baselines.iterator(); b.hasNext();) {
IBaselineHandle bl = (IBaselineHandle) b.next();
IBaseline baseline = (IBaseline) teamRepository.itemManager().fetchCompleteItem(bl, IItemManager.DEFAULT, monitor);
IBaselineConnection baseConnection = workspaceManager.getBaselineConnection(baseline,monitor);
System.out.println(baseline.getId() + " - " + baseline.getName());
}


Anyone knows how to filter this list further per workspace? Or do I need another approach to get this working?

Thanks in advance.

0 votes



7 answers

Permanent link
 I think that the right answer is here link . If you want a list of the specific stream or workspace component baselines (like what you get from ui when you right click on the component of a workspace and then you select show > baselines) you've just to change the parameters from
wsConn.getComponentAuditTrail(compHandle, numBasisInHistory - 1, 1, new NullProgressMonitor());
	
	
to  
wsConn.getComponentAuditTrail(compHandle, 0, myMax, new NullProgressMonitor());

where myMax is the maximum number of baselines you want, paying attention that the list is from oldest to newest

0 votes


Permanent link
Hi Michele,
                    To automatically compare the baseline against the previous one, which operation is your plugin based on? I mean is it an Operation particpant and if yes, where is it configured in the operation behaviour?

Thanks.

0 votes


Permanent link
David,
thanks for you answer but this code does not work for me because I'm searching for baseline in a specific workspace.

I've just tried another method which works quite the way I need: getMergedBaselineHistory. This method has only a problem: it returns some duplicate line. This is ok if the duplicates are not subsequent (because of replace history) but it returns also, in some case, the same baseline two times one after the other.

I resolved removing subsequent duplicates and so I obtain the same list I have with client command.

Best regards,
Michele.

0 votes


Permanent link
Michele , the answer you seek is in the first post of this thread ;-)


IBaselineSearchCriteria crit = IBaselineSearchCriteria.FACTORY.newInstance();
crit.setComponentRequired(comp);
List baselines = workspaceManager.findBaselines(crit, Integer.MAX_VALUE, monitor);

0 votes


Permanent link
Hi,
I've a similar problem. I'd like to compare the baseline automatically created by a build request with the previous one.

In this cas I've found that getBaselinesInHistory method does not return the same content I would have if I select "Show Baselines" in client but only the baseline in the history.

For example if I select show baselines on my repository workspace I obtain this list:
12: RI000_add_TestVari_20120223-0930, sa_RTC, 9.30.26 (1 ora fa)

9: pluto, es02046 Michele Pegoraro, 16-Feb-2012 17.33
11: RI000_add_TestVari_20120217-1115, sa_RTC, 17-Feb-2012 11.15
9: pluto, es02046 Michele Pegoraro, 16-Feb-2012 17.33
10: RI000_add_TestVari_20120216-1735, sa_RTC, 16-Feb-2012 17.35
9: pluto, es02046 Michele Pegoraro, 16-Feb-2012 17.33
8: RI000_add_TestVari_20120216-1730, sa_RTC, 16-Feb-2012 17.30
1: Initial Baseline, es02046 Michele Pegoraro, 13-Feb-2012 12.50


but if I run getBaselinesInHistory I only get
12: RI000_add_TestVari_20120223-0930, sa_RTC, 9.30.26 (1 ora fa)

9: pluto, es02046 Michele Pegoraro, 16-Feb-2012 17.33
1: Initial Baseline, es02046 Michele Pegoraro, 13-Feb-2012 12.50


What is the method I can call to obtain the same of show baselines command?

Thanks,
Michele.

0 votes


Permanent link
Hi..

Do you know how to resolve this problem now???

I have the same trouble....

thanks


As a matter of a fact, we found a solution yes. Via the WorkspaceConnection object you can use the getBaseLinesInHistory(comp, qty, monitor) method. This method returns a IHistoricBaselineIterator which contains a list of baselines. My method to recover the last baseline for a component in my workspace:

private IBaseline recoverLastBaseline(IWorkspaceConnection workspace, IComponent component) throws MojoFailureException {
try {
IHistoricBaselineIterator baseHist = workspace.getBaselinesInHistory(component, 1, getMonitor());
if (baseHist.getBaselines() == null || baseHist.getBaselines().size() < 1) {
throw new MojoFailureException("Couldn't find a useable baseline");
}
IBaseline baseline = (IBaseline) getItemManager().fetchCompleteItem(baseHist.getBaselines().get(0), IItemManager.DEFAULT, getMonitor());
getLog().debug("Baseline: " + baseline.getId() + " - " + baseline.getName());
return baseline;
} catch (TeamRepositoryException e) {
throw new MojoFailureException("Error while fetching last baseline for component " + component.getName() + " in workspace " + workspace.getName());
}
}


I hope it helps.
Regards,
Patrick

0 votes


Permanent link
Hi..

Do you know how to resolve this problem now???

I have the same trouble....

thanks

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,927
× 1,201

Question asked: Dec 02 '10, 4:08 a.m.

Question was seen: 10,020 times

Last updated: Jun 01 '16, 11:26 p.m.

Confirmation Cancel Confirm