I use below code to create a workspace :
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import com.ibm.team.repository.client.ITeamRepository;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler;
import com.ibm.team.repository.client.ITeamRepository.ILoginHandler.ILoginInfo;
import com.ibm.team.repository.client.TeamPlatform;
import com.ibm.team.repository.common.TeamRepositoryException;
import com.ibm.team.scm.client.IWorkspaceConnection;
import com.ibm.team.scm.client.IWorkspaceManager;
import com.ibm.team.scm.client.SCMPlatform;
import com.ibm.team.scm.common.IFlowTable;
public class RTCFirst {
public static void main(String args[]) {
String repositoryURI = "https://rtc.domain.com/jazz";
String userId = "myid";
String password = "****";
IProgressMonitor monitor = new NullProgressMonitor();
try {
ITeamRepository repo = logIntoTeamRepository(repositoryURI,
userId, password, monitor);
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repo);
IWorkspaceConnection workspace = wm.createWorkspace(repo.loggedInContributor(), "Example Workspace", "Description", monitor);
IFlowTable ift = workspace.getFlowTable().getWorkingCopy();
} catch (TeamRepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private static ITeamRepository logIntoTeamRepository(String repositoryURI,
String userId, String password, IProgressMonitor monitor)
throws TeamRepositoryException {
System.out.println("Trying to log into repository: " + repositoryURI);
TeamPlatform.startup();
ITeamRepository teamRepository = TeamPlatform
.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(monitor);
System.out.println("Login succeeded.");
return teamRepository;
}
private static class LoginHandler implements ILoginHandler, ILoginInfo {
private String fUserId;
private String fPassword;
private LoginHandler(String userId, String password) {
fUserId = userId;
fPassword = password;
}
public String getUserId() {
return fUserId;
}
public String getPassword() {
return fPassword;
}
public ILoginInfo challenge(ITeamRepository repository) {
return this;
}
}
}
I think I need to populate the IFlowTable with the stream I want to flow to ? If so how can this be achieved ? I can use below code to find the stream :
IWorkspaceHandle iwh = (IWorkspaceHandle) findConnectionByName(repo , "mystream" , 1 , monitor).get(0);
private static List findConnectionByName(
ITeamRepository teamRepository, String name, int kind,
IProgressMonitor monitor) throws TeamRepositoryException {
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY
.newInstance().setKind(kind);
if (name != null) {
criteria.setExactName(name);
}
List<IWorkspaceHandle>workspaces= wm.findWorkspaces(criteria,
Integer.MAX_VALUE, monitor);
return workspaces;
}
But once I've found the stream how do I add it as flow target ?
don't know if you still need the answer, but I use below code to add a stream (lv1Stream) as flow target of another stream (lv2Stream):
IFlowTable flowTable = lv2Stream.getFlowTable().getWorkingCopy();
flowTable.addDeliverFlow(lv1Stream.getResolvedWorkspace(), repo.getId(),
repo.getRepositoryURI(), null, lv1Stream.getDescription());
IFlowEntry flowNode =
flowTable.getDeliverFlow(lv1Stream.getResolvedWorkspace());
flowTable.setDefault(flowNode);
flowTable.setCurrent(flowNode);
lv2Stream.setFlowTable(flowTable, null);