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
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
2 answers
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.
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.
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?
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?
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Aug 04 '14, 9:30 a.m.The client API to set a baseline I have used looks looks this:
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Aug 04 '14, 9:34 a.m.This is from the example in https://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/
Steffen Kriese
Aug 05 '14, 5:02 a.m.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.
Steffen Kriese
Aug 05 '14, 5:03 a.m.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
Steffen Kriese
Aug 05 '14, 5:13 a.m.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)
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Aug 05 '14, 5:32 a.m.What are you actually trying to do here? What is the use case? If it is server API, in which context do you run?
Steffen Kriese
Aug 05 '14, 6:07 a.m.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.