Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get the links from a specific state of the work item ?

Hello All,

I am trying to fetch changeset links present in a work item for all its states. For E.g. say I have added a changeset link to a work item 123 when it is in IN PROGRESS state and say I add one more changeset to the same work item when it is in Closed state.

I am retrieving all the work item states through its history. Something like below:

 IItemManager itm = teamRepository.itemManager();
            List history = itm.fetchAllStateHandles((IAuditableHandle) workItem.getStateHandle(), monitor);
           
            for (int i = history.size() - 1; i >= 0; i--)
            {
                IAuditableHandle audit = (IAuditableHandle) history.get(i);
               // Below line fetches me different states of the work item one by one through its history.
                IWorkItem workItemPrevious = (IWorkItem) teamRepository.itemManager().fetchCompleteState(audit, null);
            }

What I am trying to achieve :
For each state of the work item I am trying to fetch its changeset links. In the above E.g. for work item 123,
It should give output as:
IN PROGRESS : 1 changeset (I store its UUID)
Closed : 2 changesets

But for whichever state I try to access a work items changeset links, it always give me the same results. It gives the latest changeset links for all the states.

I use below code to fetch a work item's changeset links:

 
final IWorkItemCommon workItemCommon = (IWorkItemCommon) iTeamRepository
                .getClientLibrary(IWorkItemCommon.class);
        final IWorkItemReferences references = workItemCommon.resolveWorkItemReferences(workItem, iProgressMonitor);
        final List<IEndPointDescriptor> refTypes = references.getTypes();

        final List<IChangeSet> changeSets = new ArrayList<IChangeSet>();

        for (final IEndPointDescriptor endPointDescriptor : refTypes)
        {

            if (endPointDescriptor.getLinkType()
                    .equals(ILinkTypeRegistry.INSTANCE.getLinkType(WorkItemLinkTypes.CHANGE_SET)))
            {

                final List<IReference> refList = references.getReferences(endPointDescriptor);
                for (final IReference reference : refList)
                {
                    final IChangeSetHandle csh = (IChangeSetHandle) reference.resolve();

                    final IChangeSet changeSet = (IChangeSet) iTeamRepository.itemManager()
                            .fetchCompleteItem(csh, IItemManager.DEFAULT, iProgressMonitor);
                    if (changeSet != null)
                    {
                       
                        changeSets.add(changeSet);

                    }

                }
            }
        }

Can someone help me here ?

0 votes

Comments

The only way I can imagine that you'd be able to determine this information is if you could obtain the exact time each change set link was added-to/removed-from the work item, and then correlate that sequence with the times that the work item changed state.  If you cannot find a way to get those times, then the information you want is probably not computable.  

Hi Geoffrey Clemm,

Thanks for your response. This can be definitely achieved by computing time.
But I was a little disappointed after seeing that there is an option to go to the previous state of the work item but not everything can be fetched from its previous state!
Do you think this part of the API has to be improved?

Also is there a way to know if some link was ADDED or REMOVED from the work item?


Be the first one to answer this question!

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 1,221

Question asked: Jan 30 '17, 11:36 a.m.

Question was seen: 1,502 times

Last updated: Feb 01 '17, 2:05 a.m.

Confirmation Cancel Confirm