How to read Work Item history from RTC using java APIs?
2 answers
This can be done using the repository ItemManager something like the following:
// workItem is of type IWorkItem
// repository is of type ITeamRepository
IAuditableHandle auditableHandle = (IAuditableHandle) workItem.getItemHandle();
IItemManager itemManager = repository.itemManager();
List<IWorkItemHandle> handles;
try {
handles = itemManager.fetchAllStateHandles( auditableHandle, null);
List<IWorkItem> workItems = new ArrayList<IWorkItem>();
workItems = itemManager.fetchCompleteStates(handles, null);
workItems will contain the history records of the work item ( basically a copy of the prior history state of the work item)
The hard part is the rooting through the list to note the changes you have interest in. Look at the API doc for the named classes / methods.
// workItem is of type IWorkItem
// repository is of type ITeamRepository
IAuditableHandle auditableHandle = (IAuditableHandle) workItem.getItemHandle();
IItemManager itemManager = repository.itemManager();
List<IWorkItemHandle> handles;
try {
handles = itemManager.fetchAllStateHandles( auditableHandle, null);
List<IWorkItem> workItems = new ArrayList<IWorkItem>();
workItems = itemManager.fetchCompleteStates(handles, null);
workItems will contain the history records of the work item ( basically a copy of the prior history state of the work item)
The hard part is the rooting through the list to note the changes you have interest in. Look at the API doc for the named classes / methods.
Comments
I don't know if there's something better but you may get inspiration looking at class ChangePresentation (from com.ibm.team.workitem.service.internal.save.notify.ChangePresentation) where changes of attributes are found using a sorted attribute list (buildSortedAttributeList) and then comparing the values of the attributes in history,