How to create project area programmatically?
2 answers
Hi, this might help you out.
if (!TeamPlatform.isStarted()) {
TeamPlatform.startup();
}
String rtcURL = "https:/****.com:9443/rm";
String user = "**";
String pass = "*";
ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(rtcURL);
IProgressMonitor MONITOR = new NullProgressMonitor();
repo.registerLoginHandler(new LoginHandler(user, pass));
repo.login(MONITOR);
IProcessItemService service = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
IProcessDefinition[] definitions = null;
IProcessDefinition processDefinition = service.findProcessDefinition(processId,
IProcessItemService.ALL_PROPERTIES, MONITOR);
IArtifactTypeManager artifactTypeManager;
if (processDefinition == null) {
// Create the definition if it does not exist.
definitions = service.deployPredefinedProcessDefinitions(new String[] { processId }, MONITOR);
if (definitions.length != 0) {
processDefinition = definitions[0];
} else {
throw new TeamRepositoryException("Process template " + processId + " does not exist.");
}
}
if (processDefinition == null) {
throw new TeamRepositoryException("Could not find Predefined Process " + processId);
}
// ---- creation of project area code
IProjectArea project = service.createProjectArea();
project.setName(name);
project.setProcessDefinition(processDefinition);
project.getDescription().setSummary("Test Process Summary");
// Save project area that uses the provided process
service.save(project, MONITOR);
// --------------- Set project access ------------------
service.initialize(project, MONITOR);
Thanks
Vab