It's all about the answers!

Ask a question

Using java client api, how to get baseline from component if component is shared among streams

vikrant kamble (132558) | asked Apr 29 '16, 3:51 p.m.
edited Apr 29 '16, 3:52 p.m.
 Hi All,
I have below scenario
Development Stream

Integration Stream

Components of streams are originally created in Development stream and then same components are added to integration stream and then baselines named snap_4 are created on each component of integration stream.

I want to fetch latest baseline of Dev_Comp_1 from Development stream. When I do it using java API it fetches snap_4 instead of snap_3.
snap_4 is latest baseline for overall component, which resides in Integration stream.
How can i fetch snap_3 as latest baseline of Dev_Comp_1 from Development stream using java client api.

I tried using ibaselinesearchcriteria, but it fetches snap_4 as latest baseline from overall component.

Is there any API from which I can fetch state of component from Development stream, so that it can fetch snap_3 as latest baseline.

Accepted answer

permanent link
David Lafreniere (4.5k7) | answered May 17 '16, 1:43 p.m.
edited May 18 '16, 10:18 a.m.
Here is how you get the last baseline (known as the 'basis') of a component in a workspace or stream.

// Fetch a handle to the last baseline (basis)

ITeamRepository repo = <repo_of_the_workspace>

IWorkspaceManager manager = SCMPlatform.getWorkspaceManager(repo);

IWorkspaceHandle workspaceHandle = <this_is_the_handle_for_dev_stream>

IWorkspaceConnection wc = manager.getWorkspaceConnection(workspaceHandle , monitor);

IComponentHandle component = <this_is_the_component_you_care_about>

IBaselineHandle basisHandle = wc.getComponentInfo(component).basis();

// Fetch the full baseline

IFetchResult fetchResult =  repo.itemManager().fetchCompleteItemsPermissionAware(Collections.singletonList(basisHandle), ItemManager.DEFAULT, monitor);

IBaseline fetchedBaseline;

if (fetchResult.getRetrievedItems().size() == 1) {

   fetchedBaseline = fetchResult.getRetrievedItems().get(0);

Michael Valenta selected this answer as the correct answer

Your answer

Register or to post your answer.