It's all about the answers!

Ask a question

How to set iteration type using RTC JAVA API for iteration


Yatin Chaudhari (112) | asked Sep 26 '18, 4:50 a.m.

  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



permanent link
Ralph Schoon (63.3k33646) | answered Sep 26 '18, 5:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Sep 26 '18, 7:13 a.m.

 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
Yatin Chaudhari commented Sep 26 '18, 8:36 a.m.
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


Ralph Schoon commented Sep 26 '18, 10:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Why would the new iteration have any type set by default (other than null)?

Consider rereading my answer. 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.