How to set a stream as flow target using java RTC api?
Accepted answer
Comments
Nice code example, I can get everything to work except for the setting of current and default.
I have copied the workspace from some other system.
now I have to fix the flow table to point to streams on THIS system.
I loop thru the old flow table entries, and create a new entry that matches the stream from this system,
then I check to see if this old (only old entries processed in loop) matches the setting for default or current (as configured on the source system).
target.equals(flowtable.getDefaultDeliverFlow()
if it does than I set the newly created target node as the new default/current
flowtable.setDefault(newnode); or
flowtable.setCurrent(newnode);
I can't edit my comment, so
also, we had a few workspaces where there were multiple flow targets and some are neither current or default.. so the loop does
recreate all the flow table entries, pointing to the new workspaces/streams.
set the default/current for the new entry as appropriate
Thanks a lot for your answer :-).
I don't know.. I never had problem with the settings not sticking..
you DID set the flowtable back into the workspace (stream), right? else you didn't actually change it.
// after update, make sure to put the changes back into the workspace/stream
// no explicit write is required, the workspace manager will handle committing changes.
workspace.setFlowTable(flowtable, null);
Thanks again.
my code is called for both streams and workspaces, cause I just copied a stream/workspace from a different system and the target doesn't have the same object ID on this system as it did on the old system.
I was copying from 3.0.1.3 to 4.0.3.. hm.. actually not true.. only from/to like level systems.. 3.01.3 to 3.01.3 then upgrade, then 4.0.3 to 4.0.3
what RTC version are u on
I'm on version 5.0.1... maybe there's an incompatibility between my API and the server... I'll have to check that out.
3 other answers
http://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/
Otherwise you will have to use the flow table. I have no code for that right now but I was able to find several posts around this topic using go***e 'flowtable site:jazz.net'. Limiting the search to the Jazz.net site is a great feature that helps me a lot finding the information I need.
public void doAddFlowTargetToStream(AddFlowTargetToStream addFlowTargetToStream)
{
IProjectArea projectArea = jazzapi.findProjectArea(addFlowTargetToStream.getProjectarea());
IWorkspaceHandle sourceWorkspaceHandle = jazzapi.findWorkspace(projectArea, addFlowTargetToStream.getStream());
IWorkspaceHandle targetWorkspaceHandle = jazzapi.findStream(projectArea, addFlowTargetToStream.getFlowTarget());
IWorkspaceConnection sourceWorkspaceStreamConnection = jazzapi.getWorkspaceConnection(sourceWorkspaceHandle);
IFlowTable sourceFlowtable = sourceWorkspaceStreamConnection.getFlowTable().getWorkingCopy();
sourceFlowtable.addDeliverFlow(targetWorkspaceHandle, null, null, sourceWorkspaceStreamConnection.getComponents(), "Scoped");
// setting current + default
sourceFlowtable.setCurrent(sourceFlowtable.getDeliverFlow(targetWorkspaceHandle));
sourceFlowtable.setDefault(sourceFlowtable.getDeliverFlow(targetWorkspaceHandle));
// setting new flow table
sourceWorkspaceStreamConnection.setFlowTable(sourceFlowtable, jazzapi.monitor);
}
Comments
see what happens when you share the code? you start looking at it more...
congrats on finding it..
Thx, and actually, they say that you should use acceptSources() and getAcceptFlow(). It's a confusing naming fo the API methods, but the acceptsources are actually your flowtargets. Shouldn't you use these instead?
there is another whole loop for dealing with accept. My sample was intended to show the general process and api usage.. not every possible detail.
accept is incoming, deliver is outgoing.. they do not have to be symmetrical
I can accept from 1 (downstream) and deliver to a different one (upstream)
my purpose was to fixup the flow table because I had copied the workspace from system X to here, and the handles for the flow targets were no longer valid.