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

create a new stream out of a snapshot using the server side api

Hello
I want to create a stream based on a snapshot. IScmService has the method "createWorkspaceFromBaselineSet" to create a workspace. Is there a similar method for streams available? If not what needs to be done to create a stream?
Thanx, Steffen 

0 votes

Comments

The client API to set a baseline I have used looks looks this:

    private void setActiveBaseline(IWorkspaceConnection workspace,
            IComponentHandle component, IBaselineConnection lab2Baseline,
            IProgressMonitor monitor) throws TeamRepositoryException {
        workspace.applyComponentOperations(Collections.singletonList(workspace
                .componentOpFactory().replaceComponent(component, lab2Baseline,
                        false)), monitor);
    }

in the server side api the IScmService class provides a method called "replaceComponent" which seams to provide the same functionality as the client side "replaceComponent". Unfortunately the method is marked as deprecated and IScmService.updateComponents2 should be used instead. 

I changed the code to call updateComponents2:

IBaselineHandle currentBaseline = baselineIterator.next();
IComponentOpDescriptor desc = ComponentOpDescriptor.FACTORY.addComponent(currentComponent, currentBaseline ,false);
scmService.updateComponents2(w, null, new IComponentOpDescriptor[] { desc }, true, false, IScmService.DELTA_PER_INVOCATION, null, null);

this fails wit an exception

com.ibm.team.repository.common.TeamRepositoryException: Component 'the first one Default Component' is already in workspace
        at com.ibm.team.scm.service.internal.utils.IExceptionFactory$1.createException(IExceptionFactory.java:52)
        at com.ibm.team.scm.service.internal.utils.IExceptionFactory$1.createException(IExceptionFactory.java:57)
        at com.ibm.team.scm.service.internal.utils.WorkspaceUtils.addComponent(WorkspaceUtils.java:1341)
        at com.ibm.team.scm.service.internal.ScmServiceInternal.updateComponents2(ScmServiceInternal.java:4848)
        at com.ibm.team.scm.service.internal.ScmService$85.run(ScmService.java:3950)
        at com.ibm.team.scm.service.internal.AbstractScmService$2.run(AbstractScmService.java:431)
        at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:488)
     

What are you actually trying to do here? What is the use case? If it is server API, in which context do you run?

we want to create a number of "maintenance streams" based on snapshots in  development streams on a regular base. The maintenance streams differ in the number of components and also have functional dependencies to each other and to work items. So we need some checking before the streams are created and we to set a number of attributes for each stream. Of cause the creation of the "maintenance streams" could be done via the eclipse gui or from the java api. But both cases have there own drawbacks. We ended up with a rest service with some get functions to query information in RTC and a post function to create the new streams.     

showing 5 of 7 show 2 more comments


2 answers

Permanent link
You use the same call. There is no difference between a stream and a workspace except for the stream flag. It's used for checks when SCM only permits operations on streams or does not permit operations on streams. In this case, this call is allowable for a stream.

0 votes

Comments

the createWorkspaceFromBaselineSet method returns a workspace. How do I transform this workspace into a stream? The workspace owner is a IContributorHandle while the stream is owned by a IProcessAreaHandle. How do I change the owner? How can I set the stream flag?  

You're right, it only is used for creating workspaces. You'll have to create a stream and add the components from the snapshot yourself.


FYI, you can reply to answers instead of creating a new answer. This helps others read through the discussion of the answer.


Permanent link
Hello,

the code below creates a new stream  and adds the component from the snapshot. unfortunately the component is empty:

// create a new stream
IScmService scmService = super.getService(IScmService.class);
WorkspaceRefreshResult i = scmService.createStream((IProcessAreaHandle) currentProjectArea.getItemHandle(), streamName, "description", null, null);
IWorkspace w = i.getWorkspace();

//get component handle
IComponent currentComponent = (IComponent) itemSvc.fetchItem(currentComponentHandle, IRepositoryItemService.COMPLETE);

//add componet to stream
IComponentOpDescriptor desc = IComponentOpDescriptor.FACTORY.addComponent(currentComponent, false);
scmService.updateComponents2(w, null, new IComponentOpDescriptor[] { desc }, true, false, IScmService.DELTA_PER_INVOCATION, null, null);

looks like I need to replace the compete with a IBaselineHandle form the snapshot. Any Idea how this can be done?

0 votes

Comments

You can get the baselines from the snapshot. I assume that's how you know which components to add. FYI, I don't see any code there that shows how you get the component from the snapshot in case you're looking for validation on that part.

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

Question asked: Jul 23 '14, 8:40 a.m.

Question was seen: 4,924 times

Last updated: Aug 06 '14, 8:40 a.m.

Confirmation Cancel Confirm