Problem with "setCurrent" and "setDefault"
Hi team,
I have a problem in a FlowTable.
I'm trying to put a
default and current
target of a target flow table but I can't it.
My code:
------------------------------------------------------
//Create workspace
IWorkspaceConnection wsc = workspaceManager.createWorkspace(teamRepository.loggedInContributor(), Workspace_name, Workspace_name, null);
//Add component
List<IComponentOp> ops = new ArrayList<IComponentOp>();
//ops.add(wsc.componentOpFactory().addComponent(auxcomp, false));
ops.add(wsc.componentOpFactory().addComponent(auxcomp, true));
wsc.applyComponentOperations(ops, null);
IWorkspaceSearchCriteria search2 = IWorkspaceSearchCriteria.FACTORY.newInstance();
search2.setExactName(Workspace_name);
List<IWorkspaceHandle> handles2 ;
handles2 = workspaceManager.findWorkspaces(search2, Integer.MAX_VALUE, null);
IWorkspace iwspaux2 = null;
for( IWorkspaceHandle aux2:handles2 ){
iwspaux2 = (IWorkspace) teamRepository.itemManager().fetchCompleteItem(aux2,0,null);
}
IWorkspaceHandle myws = (IWorkspaceHandle) iwspaux2;
IWorkspaceConnection workspaceConnection2 = workspaceManager.getWorkspaceConnection(myws, null);
IFlowTable flowTable2 = workspaceConnection2.getFlowTable().getWorkingCopy();
flowTable2.removeDeliverFlow(workspaceConnection2.getResolvedWorkspace());
flowTable2.addDeliverFlow(workspaceConnection.getResolvedWorkspace(), null, null, Collections.singletonList(cmp), cmp.getName().toString());
flowTable2.setComponentScopes(workspaceConnection.getResolvedWorkspace(), Collections.singletonList(cmp));
List<IFlowEntry> entries = flowTable2.deliverTargets();
flowTable2.setCurrent(entries.get(0));
flowTable2.setDefault(entries.get(0));
wsc.setFlowTable(flowTable2, null);
-----------------------------------------------------
There is no error message but it doesn't work.
Could anyone help me?
Any help would be appreciated.
Thanks in advance!!
BR Javier Lisbona
I have a problem in a FlowTable.
I'm trying to put a
My code:
------------------------------------------------------
//Create workspace
IWorkspaceConnection wsc = workspaceManager.createWorkspace(teamRepository.loggedInContributor(), Workspace_name, Workspace_name, null);
//Add component
List<IComponentOp> ops = new ArrayList<IComponentOp>();
//ops.add(wsc.componentOpFactory().addComponent(auxcomp, false));
ops.add(wsc.componentOpFactory().addComponent(auxcomp, true));
wsc.applyComponentOperations(ops, null);
IWorkspaceSearchCriteria search2 = IWorkspaceSearchCriteria.FACTORY.newInstance();
search2.setExactName(Workspace_name);
List<IWorkspaceHandle> handles2 ;
handles2 = workspaceManager.findWorkspaces(search2, Integer.MAX_VALUE, null);
IWorkspace iwspaux2 = null;
for( IWorkspaceHandle aux2:handles2 ){
iwspaux2 = (IWorkspace) teamRepository.itemManager().fetchCompleteItem(aux2,0,null);
}
IWorkspaceHandle myws = (IWorkspaceHandle) iwspaux2;
IWorkspaceConnection workspaceConnection2 = workspaceManager.getWorkspaceConnection(myws, null);
IFlowTable flowTable2 = workspaceConnection2.getFlowTable().getWorkingCopy();
flowTable2.removeDeliverFlow(workspaceConnection2.getResolvedWorkspace());
flowTable2.addDeliverFlow(workspaceConnection.getResolvedWorkspace(), null, null, Collections.singletonList(cmp), cmp.getName().toString());
flowTable2.setComponentScopes(workspaceConnection.getResolvedWorkspace(), Collections.singletonList(cmp));
List<IFlowEntry> entries = flowTable2.deliverTargets();
flowTable2.setCurrent(entries.get(0));
flowTable2.setDefault(entries.get(0));
wsc.setFlowTable(flowTable2, null);
-----------------------------------------------------
There is no error message but it doesn't work.
Could anyone help me?
Any help would be appreciated.
Thanks in advance!!
BR Javier Lisbona
Accepted answer
Solution:
......................
......................
List<IFlowEntry> entries = flowTable2.deliverTargets() ;
List<IFlowEntry> entries = flowTable2.acceptFlows();
......................
......................
:-)
......................
......................
List<IFlowEntry> entries = flowTable2.
List<IFlowEntry> entries = flowTable2.acceptFlows();
......................
......................
:-)
Comments
Hi Javier, I dont understant solution...
Here is my code, what am I missing?
IFlowTable flowTable = wc.getFlowTable().getWorkingCopy();
flowTable.addDeliverFlow(targetStreamConnection.getResolvedWorkspace(), repo.getId(), repo.getRepositoryURI(), null, targetStreamConnection.getDescription());
IFlowEntry newnode = flowTable.getDeliverFlow(targetStreamConnection.getResolvedWorkspace());
flowTable.setCurrent(newnode);
flowTable.setDefault(newnode);
wc.setFlowTable(flowTable, monitor);
I found :D
wrong -> correct
flowTable.addDeliverFlow -> flowTable.addAcceptFlow
2 other answers
Ok, I know the problem:
-->
"Yes, there is a problem, you are changing the 'deliverFlows ', when you
should change the 'acceptFlows '.
The flow table API method names are misleading, and it is possible that
we'll be changing this in the future (partially to sort out this confusion
you're experiencing now). The 'acceptFlows' are for the collaborations.
The 'deliverFlows' are for helping identify component additions/removals
(I believe. Somebody correct me if I'm wrong.) "
Yes, I think so (The flow table API method names are misleading)
-->
"Yes, there is a problem, you are changing the '
should change the '
The flow table API method names are misleading, and it is possible that
we'll be changing this in the future (partially to sort out this confusion
you're experiencing now). The 'acceptFlows' are for the collaborations.
The 'deliverFlows' are for helping identify component additions/removals
(I believe. Somebody correct me if I'm wrong.) "
Somehow it makes sense: even if you see it as a "Flow target" you must establish a connection for both accepting and delivering change sets.
This is used also in com.ibm.team.scm.client.tests.tools.samples.SampleChangeSets.SampleChangeSets(ITeamRepository, String, boolean)
...
workspaceConnection = createUniqueWorkspace(repo);
workspaceConnection.addComponent(component, false, (IProgressMonitor) null);
IFlowTable wc = workspaceConnection.getFlowTable().getWorkingCopy();
wc.addAcceptFlow(masterWorkspace, null, null, Collections.singleton(component), null);
wc.addDeliverFlow(masterWorkspace, null, null, Collections.singleton(component), null);
workspaceConnection.setFlowTable(wc, null);