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

Replacing Baseline using API

I am trying to replace a baseline of a component via API. Unfortunately it is not working.
I am using
public void replace(IWorkspaceConnection workspace, IBaselineConnection sourceBaseline); 
of
IWorkspaceUpdateOperation class.

Here is my scenario:
I have a stream "ComponentContainer_Stream" with following components
- Comp1 - (1:InitialBaseline 2:bl1 3:bl2)
- Comp2 - (1:InitialBaseline 2:bl1 3:bl2)
- Comp3 - (1:InitialBaseline 2:bl1 3:bl2)
with different baselines as mentioned above.

My Use Cases are as follows:

Use Case #1
- A Stream "Stream_Target" (Empty, have no component within it)
-  I want to add Comp2(bl1) in to Stream_Target

Use Case #2
- A Stream "Stream_Target" has Comp2(bl1)
-  I want to replace Comp2(bl1) with Comp2(bl2) in Stream_Target

Use Case #3
- A Stream "Stream_Target" has Comp2(bl2)
-  I want to replace Comp2(bl2) with Comp2(bl1) in Stream_Target


Here is my Code (To make it readable, I have removed try catch blocks)
private static String _repository ="{repository}";
private static String _projectName = "{Project name}";
private static String _user = "{userId}";  
private static String _pwd ="{pwd}";
private static String _stream = "{Stream name}";
private static ITeamRepository teamRepository;
private static IWorkspaceHandle wsHandle;
private static IWorkspaceConnection wsConn;
private static IWorkspaceManager wm;
//team repository and login
teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);
// Workspace manager
wm = SCMPlatform.getWorkspaceManager(teamRepository);
// load stream
IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
wsSearchCriteria.setExactOwnerName({projectName});
wsSearchCriteria.setExactName("Stream_Target");
wsSearchCriteria.setExactOwnerName("{OwnerName}");
wsHandle = wsHandleList.get(0);
// workspace connection to the stream
wsConn = wm.getWorkspaceConnection(wsHandle, null);

// find & load a componenthandle for component "Comp2"
IComponentHandle currentCompHandle = wm.findComponents(IComponentSearchCriteria.FACTORY.newInstance().setExactName("Comp2"), Integer.MAX_VALUE, null).get(0);
// find all baselineHandles for the component handle of Comp2 
List<IBaselineHandle> blHandles = wm.findBaselines(IBaselineSearchCriteria.FACTORY.newInstance().setComponentRequired(compHandle), Integer.MAX_VALUE, null);
 for (IBaselineHandle blHandle: blHandles ) {
     // fetch IBaseline from BaselineHandle
     IBaseline desiredBaseline = (IBaseline) teamRepository.itemManager().fetchCompleteItem(blHandle, IItemManager.DEFAULT, null);
     // compare baselineName with baselineName as specified in UseCase, if it is our required baseline which is to be added.
     if ("bl1".equalsIgnoreCase(desiredBaseline.getName()) {

        // replace baseline operation
        IBaselineConnection desiredBaselineConnection = wm.getBaselineConnection(blHandle, null);
        IWorkspaceUpdateOperation wsUpdateOp = IOperationFactory.instance.getWorkspaceUpdateOperation(WorkspaceUpdateDilemmaHandler.getDefault());
        wsUpdateOp.replace(wsConn, desiredBaselineConnection);
      }
      // I expected that Comp1(bl2) will be added to "Stream_Target"
      // But no component is added to "Stream_Target"

0 votes


Accepted answer

Permanent link
See https://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/
Aley Zaidi selected this answer as the correct answer

0 votes


One other answer

Permanent link
Thanks Ralph. It worked

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,948

Question asked: Oct 20 '15, 4:07 a.m.

Question was seen: 2,523 times

Last updated: Oct 28 '15, 11:21 a.m.

Confirmation Cancel Confirm