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

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

 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!

1

0 votes

Comments

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

1 vote

Comments

 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
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

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

Question asked: Sep 23 '15, 8:51 a.m.

Question was seen: 5,734 times

Last updated: Sep 25 '15, 5:23 p.m.

Confirmation Cancel Confirm