It's all about the answers!

Ask a question

How can you create a stream and its component from Api Java or Rest


Emiliano Iannetti (386) | asked Mar 30 '22, 9:40 a.m.

 I found this post that helps me in part:

But now I would have another need and that is to create one or more Components within the Stream.
I have always found the following method here:
stream.applyComponentOperations (list, monitor);
Where stream is the stream created and list is a list of Components to be created
(IComponentOp op = stream.componentOpFactory (). AddComponent (a, true), but there is also the method:
stream.addComponent (IComponent, boolean, monitor); but this is obsolete.
Finally I ask you the Boolean that is passed to both of you what does it mean? And above all, I haven't had a chance to try it yet, let's say I'm studying
still the best way, is the approach used for Java Api right? But Api Rest don't exist yet? I read that it was said no but it was 2016 I would like a confirmation thank you.

3 answers



permanent link
Ralph Schoon (61.5k33643) | answered Mar 30 '22, 10:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 My best hints are:


Look into https://github.com/jazz-community/ewm-scm-utils it contains a lot of examples and code you can look at.
E.g. com.ibm.js.team.supporttools.scmutils.commands.ImportWorkspace

You should set up your development environment following the complete LAB 1 in https://jazz.net/library/article/1000 .
The workspaces you have at the end of Lab 1 allow you to see the JavaDoc and SDK properly. 

Unfortunately, at the moment, I do not see the addComponent detailled documentation either. But I downloaded the JavaDoc and found it in there. The boolean is for detailledUpdates. I usually use false.

As far as I can tell there is no public REST API to do this. You can use the SDK/Plain Java Client Libraries or the SCM Command Line tool.


Comments
Emiliano Iannetti commented Mar 30 '22, 10:34 a.m.

Thank you so much for the quick reply, I will take a look at the links you gave me and I will also use false, as suggested.

I'm doing a batch to test everything on a ProjectArea under test, I'll go on on this line. As soon as I get a response, I will also update the answer for the sake of information. In the meantime, thank you very much as always.
P.s. I figured they weren't there yet, but since the question was out of date, I tried. 


permanent link
Emiliano Iannetti (386) | answered Mar 30 '22, 12:35 p.m.

Good evening and here I am as promised, I solved the "question" if someone was useful I leave my source, do not pay attention to some customizations such as the owners of the streams and related components, you can put them who you want just match the types.


[Code]
/ Creazione Stream /
String streamName = "StreamByApiJava";
String streamDescription = "Descrizione della stream creata con API Java.";
IWorkspaceConnection stream = wm.createStream(handleTa, streamName, streamDescription, monitor);

/ Creazione Componenti /
IComponent ic = wm.createComponent(streamName+"_Documentazione", stream.getOwner(), monitor); //NomeModuloApplicativo + "_Documentazione"
IComponent a = wm.createComponent("Comp1", stream.getOwner(), monitor); //NomeComponente + "_Properties"
IComponent b = wm.createComponent("Comp2", stream.getOwner(), monitor); 
IComponent c = wm.createComponent("Comp3", stream.getOwner(), monitor);

//Il false qui sta per detailledUpdates (non ho ancora ben capito cosa indica pero')
IComponentOp op = stream.componentOpFactory().addComponent(a, false);
IComponentOp op2 = stream.componentOpFactory().addComponent(b, false);
IComponentOp op3 = stream.componentOpFactory().addComponent(c, false);
IComponentOp op4 = stream.componentOpFactory().addComponent(ic, false);
ArrayList<IComponentOp> list = new ArrayList();
list.add(op);
list.add(op2);
list.add(op3);
list.add(op4);
stream.applyComponentOperations(list, monitor);
[/Code]

I hope I didn't write nonsense, in the tests I did, for what we need is just fine, thanks a lot again to everyone.


permanent link
Emiliano Iannetti (386) | answered Mar 30 '22, 12:36 p.m.

Good evening and here I am as promised, I solved the "question" if someone was useful I leave my source, do not pay attention to some customizations such as the owners of the streams and related components, you can put them who you want just match the types.


[Code]
/ Creazione Stream /
String streamName = "StreamByApiJava";
String streamDescription = "Descrizione della stream creata con API Java.";
IWorkspaceConnection stream = wm.createStream(handleTa, streamName, streamDescription, monitor);

/ Creazione Componenti /
IComponent ic = wm.createComponent(streamName+"_Documentazione", stream.getOwner(), monitor); //NomeModuloApplicativo + "_Documentazione"
IComponent a = wm.createComponent("Comp1", stream.getOwner(), monitor); //NomeComponente + "_Properties"
IComponent b = wm.createComponent("Comp2", stream.getOwner(), monitor); 
IComponent c = wm.createComponent("Comp3", stream.getOwner(), monitor);

//Il false qui sta per detailledUpdates (non ho ancora ben capito cosa indica pero')
IComponentOp op = stream.componentOpFactory().addComponent(a, false);
IComponentOp op2 = stream.componentOpFactory().addComponent(b, false);
IComponentOp op3 = stream.componentOpFactory().addComponent(c, false);
IComponentOp op4 = stream.componentOpFactory().addComponent(ic, false);
ArrayList<IComponentOp> list = new ArrayList();
list.add(op);
list.add(op2);
list.add(op3);
list.add(op4);
stream.applyComponentOperations(list, monitor);
[/Code]
I hope I didn't write nonsense, in the tests I did, for what we need is just fine, thanks a lot again to everyone.

Your answer


Register or to post your answer.