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 ?
Comments
Geoffrey Clemm
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jan 30 '17, 2:32 p.m.Arshad Adavani
Jan 31 '17, 2:57 a.m.Arshad Adavani
Feb 01 '17, 2:05 a.m.