It's all about the answers!

Ask a question

RTC: API call to retrieve full repo change history with work item tasks


0
1
Alexander Sobran (112) | asked Sep 23 '15, 8:51 a.m.
edited Sep 23 '15, 9:31 a.m.
 Is there an API call to retrieve the full repo change history for a project as well as the work item task associated with each change? Or is there a programmatic way to achieve this?

This is for data mining purposes. 

Thank you!

Comments
Geoffrey Clemm commented Sep 25 '15, 2:32 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

In RTC, each component in a stream/workspace has a change history (RTC would call it a "change set history").  Then for each change set in that change set history, you can ask for the associated work item(s).  
Note that "project" is not a term used in RTC (except sometimes as an informal abbreviation for a longer term), so to avoid ambiguity, you'd want to use one of the RTC terms ("project area", "work item", "stream", etc.).

I personally am not familiar with that API, so I'll post this as a "comment" rather than an "answer".

2 answers



permanent link
Kohji Ohsawa (5951310) | answered Sep 24 '15, 7:45 p.m.
JAZZ DEVELOPER
Hi Alex,

I am not sure what exactly you mean by "full repo change", but you can retrieve WI history like below. Is this what you are looking for?

private static void findAllWorkitemHistory(ITeamRepository repository) throws TeamRepositoryException {
IProcessItemService processItemService = (IProcessItemService)repository.getClientLibrary(IProcessItemService.class);
List<IProjectArea> projectArea = processItemService.findAllProjectAreas(null, null);
Iterator<IProjectArea> iter = projectArea.iterator();
while(iter.hasNext()){
IProjectArea area = (IProjectArea)iter.next();
IWorkItemClient workItemClient = (IWorkItemClient)repository.getClientLibrary(IWorkItemClient.class);
IQueryClient queryClient = workItemClient.getQueryClient();
IAuditableClient auditableClient = (IAuditableClient)repository.getClientLibrary(IAuditableClient.class);
IQueryableAttribute attribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(area, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, null);
Expression expression = new AttributeExpression(attribute, AttributeOperation.EQUALS, area);
IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(area, expression, IWorkItem.FULL_PROFILE);
List<IResolvedResult<IWorkItem>> page =  results.nextPage(null);
Iterator<IResolvedResult<IWorkItem>> iterResult = page.iterator();
while(iterResult.hasNext()){
IResolvedResult<IWorkItem> resolvedResult = iterResult.next();
IWorkItem workItem = resolvedResult.getItem();
System.out.println("Project Area: " + area.getName() + " ID: " + workItem.getId() + " Name: " + workItem.getHTMLSummary());
List<?> history = repository.itemManager().fetchAllStateHandles((IAuditableHandle)workItem.getStateHandle(), null);
if(history.size() == 0){
continue;
}
for(int i = history.size() -1; i >= 0; i--){
IAuditableHandle zz = (IAuditableHandle)history.get(i);
//IAuditable zz1 = repository.itemManager().fetchCompleteState(zz, null);
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");
}
}
}
}


Comments
Alexander Sobran commented Sep 25 '15, 9:00 a.m. | edited Sep 25 '15, 9:00 a.m.

 Thank you.


For full repo change history:

I want to to calculate the number of changes for each individual file by getting the diff of the file before the change and after the change. This is usually called a change history in Git, I'm not sure if it's the same term for RTC. 


permanent link
Geoffrey Clemm (30.1k33035) | answered Sep 25 '15, 5:23 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
See: https://jazz.net/forum/questions/207607
This has API snippets for retrieving the change set history.
For retrieving the work items, see: https://jazz.net/forum/questions/110582

Your answer


Register or to post your answer.