It's all about the answers!

Ask a question

How do you export WI history programmatically?


0
1
iijima takafumi (1111) | asked Sep 25 '15, 3:32 a.m.

Hello.

I would like to get WI history.

How do you export WI history programmatically?

2 answers



permanent link
Kohji Ohsawa (5951310) | answered Sep 25 '15, 3:52 a.m.
JAZZ DEVELOPER
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");
}
}

permanent link
Stefano Antoniazzi (1701711) | answered Jul 14 '16, 6:41 a.m.
edited Jul 14 '16, 7:56 a.m.
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


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