Creating Iterations using java api
Hi,
I want to create Iterations using java client library. I saw a post in jazz forum where is it explained.
https://jazz.net/forum/questions/65253/create-or-delete-iteration-and-timelines-programatically
But my question is do I need to set up a plugin development project for this? Can't I do the same as java project where I will import required jars and create iterations? If yes, Please show me an example.
Thanks!
Sud
I want to create Iterations using java client library. I saw a post in jazz forum where is it explained.
https://jazz.net/forum/questions/65253/create-or-delete-iteration-and-timelines-programatically
But my question is do I need to set up a plugin development project for this? Can't I do the same as java project where I will import required jars and create iterations? If yes, Please show me an example.
Thanks!
Sud
Accepted answer
Yes, you can only setup a "standalone" enviroment to create iterations on the RTC. You need to download the RTC SDK and use the jars, like you said.
This post explain how to setup you enviroment using Maven:
https://www.ibm.com/developerworks/community/blogs/cbe857dd-5392-4111-b0ea-6827c54f2e66/entry/setting_up_rtc_java_plain_api_dev_enviroment_with_maven_and_eclipse?lang=en
One other answer
If somebody is looking for an live example , here is :
public void createIteration(ITeamRepository repo,
IProgressMonitor monitor,
String iterationName, String id, String startDate, String endDate)
throws TeamRepositoryException {
IAuditableClient fAuditableClient;
fAuditableClient = (IAuditableClient) repo
.getClientLibrary(IAuditableClient.class);
CreateWI wi = new CreateWI();
Date start = almDateFormat(startDate);
Date end = almDateFormat(endDate);
IProcessItemService service = (IProcessItemService) repo
.getClientLibrary(IProcessItemService.class);
List<IProjectArea> activeProjectAreas = new ArrayList();
List<IProjectArea> allProjectAreas;
IProjectArea iProjectArea = null;
allProjectAreas = service.findAllProjectAreas(service.ALL_PROPERTIES,
monitor);
Iterator<IProjectArea> iterator = allProjectAreas.iterator();
while (iterator.hasNext()) {
iProjectArea = iterator.next();
if (CommonString.PROJECT_AREA_NAME.equals(iProjectArea.getName())) {
break;
}
}
System.out.println(iProjectArea.getName());
IDevelopmentLineHandle developmentLineHandler = iProjectArea
.getProjectDevelopmentLine();
IDevelopmentLine developmentLine = fAuditableClient.resolveAuditable(
developmentLineHandler, ItemProfile.DEVELOPMENT_LINE_DEFAULT,
monitor);
IIterationHandle[] iterationHandle = developmentLine.getIterations();
for (int i = 0; i < iterationHandle.length; i++) {
IIterationHandle iterationList = iterationHandle[i];
List handle = new ArrayList();
handle.add(iterationList);
IFetchResult result = repo.itemManager()
.fetchCompleteItemsPermissionAware(handle,
IItemManager.REFRESH, monitor);
IIteration iteration = (IIteration) result.getRetrievedItems().get(
0);
if (iteration.getName().equals(iterationName)) {
System.out.println("Iterations already exist. cannot create. Iteration name: "+iteration.getName());
}
}
IIteration newIteration = (IIteration) IIteration.ITEM_TYPE
.createItem();
newIteration.setName(iterationName);
newIteration.setId(id);
newIteration.setStartDate(start);
newIteration.setEndDate(end);
IDevelopmentLine workingDevLine = (IDevelopmentLine) developmentLine
.getWorkingCopy();
workingDevLine.addIteration((IIterationHandle) newIteration
.getItemHandle());
newIteration.setDevelopmentLine(workingDevLine);
service.save(new IProcessItem[] { workingDevLine, newIteration },
monitor);
}
}
public void createIteration(ITeamRepository repo,
IProgressMonitor monitor,
String iterationName, String id, String startDate, String endDate)
throws TeamRepositoryException {
IAuditableClient fAuditableClient;
fAuditableClient = (IAuditableClient) repo
.getClientLibrary(IAuditableClient.class);
CreateWI wi = new CreateWI();
Date start = almDateFormat(startDate);
Date end = almDateFormat(endDate);
IProcessItemService service = (IProcessItemService) repo
.getClientLibrary(IProcessItemService.class);
List<IProjectArea> activeProjectAreas = new ArrayList();
List<IProjectArea> allProjectAreas;
IProjectArea iProjectArea = null;
allProjectAreas = service.findAllProjectAreas(service.ALL_PROPERTIES,
monitor);
Iterator<IProjectArea> iterator = allProjectAreas.iterator();
while (iterator.hasNext()) {
iProjectArea = iterator.next();
if (CommonString.PROJECT_AREA_NAME.equals(iProjectArea.getName())) {
break;
}
}
System.out.println(iProjectArea.getName());
IDevelopmentLineHandle developmentLineHandler = iProjectArea
.getProjectDevelopmentLine();
IDevelopmentLine developmentLine = fAuditableClient.resolveAuditable(
developmentLineHandler, ItemProfile.DEVELOPMENT_LINE_DEFAULT,
monitor);
IIterationHandle[] iterationHandle = developmentLine.getIterations();
for (int i = 0; i < iterationHandle.length; i++) {
IIterationHandle iterationList = iterationHandle[i];
List handle = new ArrayList();
handle.add(iterationList);
IFetchResult result = repo.itemManager()
.fetchCompleteItemsPermissionAware(handle,
IItemManager.REFRESH, monitor);
IIteration iteration = (IIteration) result.getRetrievedItems().get(
0);
if (iteration.getName().equals(iterationName)) {
System.out.println("Iterations already exist. cannot create. Iteration name: "+iteration.getName());
}
}
IIteration newIteration = (IIteration) IIteration.ITEM_TYPE
.createItem();
newIteration.setName(iterationName);
newIteration.setId(id);
newIteration.setStartDate(start);
newIteration.setEndDate(end);
IDevelopmentLine workingDevLine = (IDevelopmentLine) developmentLine
.getWorkingCopy();
workingDevLine.addIteration((IIterationHandle) newIteration
.getItemHandle());
newIteration.setDevelopmentLine(workingDevLine);
service.save(new IProcessItem[] { workingDevLine, newIteration },
monitor);
}
}