It's all about the answers!

Ask a question

Create a stream using JAVA API


Sergio Lorente (981711) | asked Dec 26 '12, 7:53 a.m.
edited Oct 05 '17, 11:54 p.m. by David Lafreniere (4.8k7)

Hi,

I have to create a new stream without flows with a new component.
So i began to read the snippet files and i created a new stream but the problem cames when i've tried to creates a configuration for it. Instead to stream.addComponent method, which is deprecated and it still used in the snippet files, i've tried to use addBaselineSet method, more interesting if i want to seed my new stream from another stream configuration or snapshot:

IComp src = wm.createComponent(name,projectArea,null);
IBaselineHandle bh = src.getInitialBaseline();
IBaselineSetHandle intialBaselineSetHandle = (IBaselineSetHandle) IBaselineSet.ITEM_TYPE.createItemHandle(bh.getItemId,null);
stream.addBaselineSet(intialBaselineSetHandle,null);

</pre>

It returns a beautiful classCastException at the fourth line.

Reading in jazz.net, somebody suggested to use that if u are using flows, but we are not using flows.


I have tried in many other ways and i can not change my stream configuration using that addBaselineSet method. I found something similar in this place: jazzForum but it has no answer and i don't find nothing about IWorkSpaceUpdateOperation class in javadoc or jazzForum.

Any suggestion?


Best Regards,

Sergio
 

Accepted answer


permanent link
Tim Mok (6.6k38) | answered Jan 02 '13, 2:45 p.m.
JAZZ DEVELOPER
edited Jan 02 '13, 2:45 p.m.
IBaselineSetHandle refers to a snapshot, which is why you get a ClassCastException when casting the IComponent.

On your stream, you'll want to get the componentOpFactory to create your component operations that you'll apply on your stream:

IComponentOp op = stream.componentOpFactory().addComponent(componentHandle, boolean);
stream.applyComponentOperations(Collections.singletonList(op), monitor);
David Lafreniere selected this answer as the correct answer

Your answer


Register or to post your answer.