我使用下面的代码创建工作区:
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;
}
}
}
我认为我需要使用我想要流的流来填充IFlowTable?如果是这样,怎么能实现呢?我可以使用下面的代码来查找流:
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;
}
但是一旦我找到了流,我该如何将其添加为流目标?
答案 0 :(得分:3)
不知道你是否还需要答案,但我使用下面的代码添加一个流(lv1Stream)作为另一个流的流目标(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);