It's all about the answers!

Ask a question

How do I find the Current Iteration of a Project Area with the Java Server API?

Shawn Carroll (36313) | asked Nov 28 '18, 1:37 p.m.

I'm looking to be able to make changes to a workitem and linked workitems whenever the workitem is moved into our current iteration. Is there anything in the APIs that can find what the project's current iteration is?

Accepted answer

permanent link
Shawn Carroll (36313) | answered Dec 07 '18, 1:48 p.m.
I solved the issue by just casting an IProcessArea as an IProjectArea.

IProjectArea projectArea = (IProjectArea) operation.getProcessArea();

I added this line to the beginning of the run method of my extension and then was able to use IProjectArea's getDevelopmentLines() and IDevelopmentLine's getCurrentIteration() calls to get the current iteration.
Ralph Schoon selected this answer as the correct answer

One other answer

permanent link
David Lafreniere (4.8k7) | answered Nov 28 '18, 9:21 p.m.
Relevant code to answer your question:
  • IProjectArea has .getDevelopmentLines() and .getProjectDevelopmentLine()
  • IDevelopmentLine has .getCurrentIteration() which returns the current iteration.
  • IIteration has .getDevelopmentLine()

Shawn Carroll commented Nov 29 '18, 12:13 p.m.

I'm able to get the IProjectAreaHandle from workitem.getProjectArea() but when I try to use the IRepositoryItemService.fetchItem() to get the full item from the handle, I get a null value. How do I actually get an IProjectArea object to begin that chain?

David Lafreniere commented Dec 03 '18, 3:45 p.m.

IProjectArea projectArea = (IProjectArea) repositoryItemService.fetchItem(workItem.getProjectArea(), IRepositoryItemService.COMPLETE);

Per the Javadoc, the return value 'cannot' be null... so perhaps you are calling a different method. Note: It can however throw one of several Exceptions (is it possible you are just catching that and continuing?),

David Lafreniere commented Dec 03 '18, 3:46 p.m.

     * @return the item for the given item handle; the item has all its
              properties set of <em>properties</em> is <code>COMPLETE</code>;
         otherwise, the item is partial with the specified properties set;
              the item is immutable; never <code>null</code>
     * @throws PermissionDeniedException
             if authenticated contributor is not authorized to read this
                  item from the repository
     * @throws ItemNotFoundException
             if the item was not found

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.