How do you export WI history programmatically?
Hello. I would like to get WI history. How do you export WI history programmatically?
|
2 answers
Hi Iijima-san,
I think it would be possible by using SDK API like below.
private static void findWorkitemHistoryById(ITeamRepository repository, int id) throws TeamRepositoryException {
IWorkItemClient workItemClient = (IWorkItemClient)repository.getClientLibrary(IWorkItemClient.class);
IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, null);
System.out.println("Workitem ID: " + workItem.getId() + " Name: " + workItem.getHTMLSummary());
List<?> history = repository.itemManager().fetchAllStateHandles((IAuditableHandle)workItem.getStateHandle(), null);
if(history.size() == 0){
return;
}
for(int i = history.size() -1; i >= 0; i--){
IAuditableHandle zz = (IAuditableHandle)history.get(i);
IWorkItem workItemPrevious = (IWorkItem)repository.itemManager().fetchCompleteState(zz, null);
System.out.println("history start");
System.out.println("ID: " + workItemPrevious.getId() + " Name: " + workItemPrevious.getHTMLSummary());
System.out.println("history end");
}
}
|
About sorting, I'm watching the code in com.ibm.team.build.internal.ui.history.AuditableHistoryPage.computeAuditableHistory(ITeamRepository, IAuditableHandle, StateCollector, IProgressMonitor) where the fetchAllStateHandles returns a List where the first entry (position 0) is the most recent (the actual state) then from entry 1 to the last entry it seems you may get the states from the oldest to the most recent.
But I've made some experiments and this is not accurate (considering the workitem.modified() ) so I think I should order by modified() Timestamp ...
|
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.