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

How do you export WI history programmatically?

Hello.

I would like to get WI history.

How do you export WI history programmatically?

1

0 votes



2 answers

Permanent link
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");
}
}

1 vote


Permanent link
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 ...

0 votes

Your answer

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
× 10,938

Question asked: Sep 25 '15, 3:32 a.m.

Question was seen: 3,139 times

Last updated: Jul 14 '16, 7:56 a.m.

Confirmation Cancel Confirm