It's all about the answers!

Ask a question

How do you get an IIteration object from an IIterationHandle with the Server API?

Shawn Carroll (3611) | asked Sep 27 '18, 2:14 p.m.

I've included a part of my code below. I'm trying to create a server extension that can subscribe users based on where a work item is in our plans/sprints so I access to the planned for value. Everything I've found talking about converting the IIterationHandle to an IIteration deals with the client API. How do you do this with the server API?

public void run(AdvisableOperation operation, IProcessConfigurationElement participantConfig,
            IParticipantInfoCollector collector, IProgressMonitor monitor)
            throws TeamRepositoryException
        Object data = operation.getOperationData();
        ISaveParameter saveParameter = null;

        if(!(data instanceof ISaveParameter))
        saveParameter = (ISaveParameter) data;
        IAuditable auditable = saveParameter.getNewState();
        IWorkItem workitem = null;
        if (auditable instanceof IWorkItem)
            workitem = (IWorkItem) auditable;
        if(workitem == null)
        workitem = (IWorkItem) workitem.getWorkingCopy();
        IIterationHandle plannedForHandle = workitem.getTarget();
        IIteration plannedFor = null;
        if(plannedForHandle != null)
            plannedFor = (IIteration)plannedForHandle.getFullState();

One answer

permanent link
Shawn Carroll (3611) | answered Sep 27 '18, 3:41 p.m.
edited Sep 27 '18, 3:42 p.m.

I found the solution for this issue.
I needed to use IRepositoryItemService.fetchItem to retrieve the IIteration object from the IIterationHandle.

Here's the snippets of code I added to my extension:


    private IRepositoryItemService itemService;

        itemService = getService(IRepositoryItemService.class);

        IIterationHandle plannedForHandle = workitem.getTarget();
        IIteration plannedFor = (IIteration) itemService.fetchItem(plannedForHandle, null);

Your answer

Register or to post your answer.