How to set iteration type using RTC JAVA API for iteration
Hi,
I am trying to set iteration type using RTC JAVA API using below code where I am not able to set iteration type for iteration being getting created or updated.
NullProgressMonitor monitor = new NullProgressMonitor();List<IIteration> newOnes = new ArrayList<IIteration>();IProcessItemService service = (IProcessItemService) TeamRepository().getClientLibrary(IProcessItemService.class);IProjectArea projectArea = (IProjectArea) service.getMutableCopy(projectArea);IDeliverable deliverable = null;IIteration newIteration = null;IItemManager itemManager = TeamRepository().itemManager();itemManager.fetchCompleteItem(projectArea.getProjectDevelopmentLine(), IItemManager.REFRESH, monitor);Object obj1 = itemManager.fetchCompleteItem(projectArea.getProjectDevelopmentLine(), ItemManager.REFRESH,monitor);
if (obj1 instanceof IDevelopmentLine) {developmentLine = (IDevelopmentLine) obj1;}
IDevelopmentLine workingDevLine = (IDevelopmentLine) developmentLine.getWorkingCopy();
IWorkItemClient workItemClient = (IWorkItemClient) clientUtil.getTeamRepository().getClientLibrary(IWorkItemClient.class);
newIteration = (IIteration) IIteration.ITEM_TYPE.createItem();newIteration.setName("iterationName");
newIteration.setIterationType(); //not able to set by sending user parameter as method argument
newIteration.setStartDate(iterationStartDate);newIteration.setEndDate(iterationEndDate);newIteration.setDevelopmentLine(workingDevLine);workingDevLine.addIteration((IIterationHandle) newIteration.getItemHandle());newIteration.setDevelopmentLine(workingDevLine);
newOnes.add(newIteration);
newIteration.setId(newIteration.getItemId().getUuidValue());
List<IProcessItem> processItems = new ArrayList<IProcessItem>();processItems.add(workingDevLine);processItems.addAll(newOnes);
try {service.save(processItems.toArray(new IProcessItem[] {}), null);} catch (TeamRepositoryException e) {}
Can anybody help me to resolve this?
Thanks
One answer
The, not so surprising answer is, that com.ibm.team.process.common.IIteration.setIterationType(IIterationTypeHandle) requires an com.ibm.team.process.common.IIterationTypeHandle (or com.ibm.team.process.common.IIterationType) as parameter and not a user.
com.ibm.team.process.common.IIteration.getIterationType() provides a list of iteration types that are available.
This should be clear even if looking at how to edit iterations in the UI. You have to define an iteration type and set that. Users are not involved in that.
Comments
IIterationTypeHandle ith = newIteration.getIterationType();
I tried this but it is giving me as null.
But when I am cheking it form UI, in combo box it is giving me 2 values for type which I am not able to get it using JAVA API
Why would the new iteration have any type set by default (other than null)?
Consider rereading my answer.