3

how can I read history from RTC workItem. I want to check some attribute change and its value before and after change form history. By jazz API. how its is possible? Please help .

Tom
  • 132
  • 2
  • 11

2 Answers2

1

Ragarding attributes, you can see more at "Working with Work Item Attributes"

If you have the Attribute ID available as a string, you can use this code to get the attribute.

IWorkItemClient workItemClient = (IWorkItemClient) fTeamRepository.getClientLibrary(IWorkItemClient.class);
IAttribute someAttribute= workItemClient.findAttribute(fProjectArea, "some_attribute_ID", monitor);

For the history, this thread can help

you can use IItemManager.fetchCompleteState() to get the full item in its historical state.
If you want to get the full history you can also get all state handles at once using IItemManager.fetchAllStateHandles() instead of walking the history using IAuditable.getPredecessorState().

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi VonC,how can I get attribute itself from history of workitem ? – Tom Aug 17 '14 at 06:04
  • @VarunGupta you can check out https://jazz.net/forum/questions/87341/how-to-fetch-the-workitem-built-in-custom-attribute-id-and-value?page=1&focusedAnswerId=87383#87383 – VonC Aug 17 '14 at 06:06
  • the mentioned link is not have the answer of my query. can you please help me on this? – Tom Aug 17 '14 at 06:56
  • @VarunGupta it is a start. I don't have more specific elements. – VonC Aug 17 '14 at 06:58
  • Is it possible to get history for all the files in a particular component of a Project area? For Ex if file PropertyReader.java has been modified by Developer A most recently.. Need to get the list like PropertyReader.java Developer A I was able to get the history in CLI using scm show history -r $URL -u $userId -P $pwd -w $ws --component icdp_core_as /source/common/Adapters/com/bac/icdp/consumer/common/PropertyReader.java But i need run this for each file to get the history of all the files.. – Nayeem Mar 07 '15 at 14:18
0

Use the below snippet:

IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, monitor);

IItemManager itm = teamRepository.itemManager(); 
List history = itm.fetchAllStateHandles((IAuditableHandle) workItem.getStateHandle(), monitor);
System.out.println("Record history details:-");
for(int i = history.size() -1; i >= 0; i--){
    IAuditableHandle audit = (IAuditableHandle) history.get(i);
    IWorkItem workItemPrevious = (IWorkItem) teamRepository.itemManager().fetchCompleteState(audit,null);
    //Operations to be carried on workItemPrevious
}
Neha S
  • 283
  • 1
  • 3
  • 17