It's all about the answers!

Ask a question

How to replace flow target in stream using server side API in RTC SCM


CLM _User (21117) | asked Nov 24 '19, 5:59 a.m.
edited Nov 24 '19, 6:01 a.m.
Hi Team,

I am duplicating stream using particular stream using server side api, I am able to duplicated stream, but I need to remove duplicated flow target and add new flow target in duplicated stream using server side API in RTC SCM,

Please provide the suggestions.

2 answers



permanent link
David Lafreniere (4.8k7) | answered Dec 02 '19, 12:05 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
See the following API:
IScmSevice.setWorkspaceFlows(...)

Comments
Yaswanth Garlapati commented Oct 29, 7:56 a.m. | edited Oct 29, 7:57 a.m.
<form accept-charset="utf-8" action="https://jazz.net/forum/comment/266838/" id="comment-266838-form" method="post" style="border: medium none; box-sizing: border-box; margin: 0px; padding: 0px;"> How to use this IScmSevice.setWorkspaceFlows(...) what are the values to be used in placeholders? It is somewhat confusing can i get an example? </form>
<form accept-charset="utf-8" action="https://jazz.net/forum/comment/266838/" id="comment-266838-form" method="post" style="border: medium none; box-sizing: border-box; margin: 0px; padding: 0px;"> </form>

permanent link
David Lafreniere (4.8k7) | answered Oct 29, 10:44 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 29, 10:49 a.m.

This is the response to your question Yaswanth.
I am adding it as a separate answer to this topic instead of a reply comment since the length is too long to add as a reply comment.

Try using this as an example to get you further:

import org.eclipse.emf.ecore.util.EcoreUtil;
    /*
* Changes the workspace's flow information
* @param scm the service
* @param ws the workspace to change flow information
* @param acceptFlowTarget the workspace to add to the accept flows
* @param deliverFlowTarget the workspace to add to the deliver flows
* @param currentFlowTarget the desired current flow target
* @param repoURI optional repo URI of the flow targets. May be null
* @param repoRoot optional reporoot of the flowtargets. May be null
* @return the updated IWorkspace
* @throws TeamRepositoryException
/
public static IWorkspace addFlow(IScmService scm, IWorkspaceHandle ws, IWorkspaceHandle acceptFlowTarget, IWorkspaceHandle deliverFlowTarget, IWorkspaceHandle currentFlowTarget, String repoURI, UUID repoRoot)
throws TeamRepositoryException {
WorkspaceRefreshResult result = refreshWorkspace(scm, ws);
Workspace w = (Workspace) result.getWorkspace();
List<FlowEntry> acceptFlows = new ArrayList<FlowEntry>(w.getFlows().size());
List<FlowEntry> deliverFlows = new ArrayList<FlowEntry>(w.getFlows().size());
for (FlowEntry fe : (Collection<FlowEntry>) w.getFlows()) {
if ((fe.getFlags() & FlowFlags.ACCEPT) != 0)
acceptFlows.add((FlowEntry) EcoreUtil.copy((EObject) fe));
else if ((fe.getFlags() & FlowFlags.DELIVER) != 0)
deliverFlows.add((FlowEntry) EcoreUtil.copy((EObject) fe));
}
CurrentFlows currentFlow = (CurrentFlows) EcoreUtil.copy((EObject) w.getCurrentFlows());

if (acceptFlowTarget != null) {
acceptFlows.add(createFlowEntry(acceptFlowTarget, FlowFlags.ACCEPT, repoURI, repoRoot));
}
if (deliverFlowTarget != null) {
deliverFlows.add(createFlowEntry(deliverFlowTarget, FlowFlags.DELIVER, repoURI, repoRoot));
}
if (currentFlowTarget != null) {
currentFlow.setCurrentAcceptFlow(currentFlowTarget.getItemId());
currentFlow.setCurrentDeliverFlow(currentFlowTarget.getItemId());
}
return scm.setWorkspaceFlows(ws,
acceptFlows.toArray(new FlowEntry[acceptFlows.size()]),
deliverFlows.toArray(new FlowEntry[deliverFlows.size()]),
currentFlow,
new IComponentHandle[0], new CurrentFlows[0], null, null);
}

private static FlowEntry createFlowEntry(IWorkspaceHandle target, int flags, String repoURI, UUID repoRoot) {
final FlowEntry result = ScmFactory.eINSTANCE.createFlowEntry();
result.setTargetWorkspace(target);
result.setFlags(flags);
if (repoURI != null) {
RemoteDescriptor descriptor = ScmFactory.eINSTANCE.createRemoteDescriptor();
descriptor.setRepoURI(repoURI);
descriptor.setRepoRoot(repoRoot);
result.setRemoteDescriptor(descriptor);
}
return result;
}
public static WorkspaceRefreshResult refreshWorkspace(IScmService scm,
IWorkspaceHandle ws) throws TeamRepositoryException {
WorkspaceRefreshParameter[] parameterArray = new WorkspaceRefreshParameter[1];
parameterArray[0] = ScmDtoFactory.eINSTANCE.createWorkspaceRefreshParameter();
parameterArray[0].setWorkspace(ws);
return scm.refreshWorkspaces(parameterArray, null)[0];
}

Your answer


Register or 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.