It's all about the answers!

Ask a question

API - Get change set list of a Stream ?


vijayakumar ramesh (1173760) | asked Sep 28 '20, 10:40 a.m.
edited Sep 28 '20, 10:42 a.m.
Use case:
To make report on change set delivery over a time on Stream. Need to get list of all change sets delivered for a Stream.

User knows Stream Name and provides this as an input, to get all changesets delivered for this stream.

Is there an API or change set exporter for a stream.?

Accepted answer


permanent link
Shashikant Padur (4.2k27) | answered Sep 29 '20, 12:24 a.m.
JAZZ DEVELOPER
You can get the history of the component in your stream by using the following api:
ChangeHistoryWithBaselinesResult IWorkspaceConnection#ChangeHistoryWithBaselinesResult fetchChangeHistoryWithBaselines(IComponentHandle component, ChangeHistoryHandle nextPageToken, int pageSizeHint, IProgressMonitor monitor)

List<ChangeHistoryEntry> ChangeHistoryWithBaselinesResult#getChangeHistoryEntries()

Ralph Schoon selected this answer as the correct answer

Comments
vijayakumar ramesh commented Sep 30 '20, 7:07 a.m.

can you provide the operation history API details (Stream). I need to know count how many change sets delivery happening on the stream daily.


1
Shashikant Padur commented Oct 01 '20, 4:55 a.m.
JAZZ DEVELOPER
Take a look at this forum link:

https://jazz.net/forum/questions/267038/how-to-get-operationhistory-of-the-stream-programmatically-using-rtc-api


Before posting followup questions, please update if the previous suggested solution worked for you or not. This will help other forum members looking for solutions. Also, search the forum before posting the query.


vijayakumar ramesh commented Nov 09 '20, 11:17 a.m.

Hello Shashikant,

I am unable to get ChangeHistoryWithBaselinesResult from IWorkspaceConnection object.
I find only IWorkspaceConnection.changeHistory(IComponentHandel). Could you tell me How to I get object of ChangeHistoryWithBaselinesResult ?


Shashikant Padur commented Nov 09 '20, 10:28 p.m.
JAZZ DEVELOPER

The IWorkspaceConnection#fetchChangeHistoryWithBaselines(...) was added in 701. Which version are you using?


vijayakumar ramesh commented Nov 10 '20, 2:55 a.m.

We are still using 6.0.6.1 :( 


vijayakumar ramesh commented Nov 11 '20, 5:16 a.m.

Hallo Shashikant ,


Could you provide API's which can used for 6.0.6.1 also. it would be great helpful. 


Shashikant Padur commented Nov 24 '20, 6:14 a.m. | edited Nov 24 '20, 6:17 a.m.
JAZZ DEVELOPER

Sorry, I couldn't respond earlier as I was on leave.

You can do the following:
IWorkspaceConnection wsConn = SCMPlatform.getWorkspaceManager(teamRepository).getWorkspaceConnection(workspaceHandle, progress);
IChangeHistory changeHistory = IWorkspaceConnection#changeHistory(componentHandle);
while (changeHistory != null) {
  List<IChangeHistoryEntryChange> recentHistory = changeHistory.recent(null);
  // loop through the recent history list and get the change set handles: IChangeHistoryEntryChange#changeSet() and pass it to the below method
  List<IChangeSet> changeSets = repository.itemManager().fetchCompleteItems(changeSetHandles, IItemManager.DEFAULT, progress);
  // process more in the history
  changeHistory = changeHistory.previousHistory(progress);
}


vijayakumar ramesh commented Jan 05 '21, 5:44 a.m.

Hello Shashikant,

Wish you happy new year. Thanks for your earlier comment and support.  From change, trying to find which file was changed. I got stuck in finding file name.
List<IChangeSet> changeSets = repository.itemManager().fetchCompleteItems(changeSetHandles, IItemManager.DEFAULT, progress);
looping each IChangeSet cs from List List<IChangeSet> changeSets and inner loop of  IChange change 
 IVersionable  versionalbe=compConfig.fetchCompleteItem(change.item(), monitor); this line gives me exception. Could you help which object , should use to get IFileItem from Change  object.


Shashikant Padur commented Jan 07 '21, 11:46 p.m. | edited Jan 07 '21, 11:47 p.m.
JAZZ DEVELOPER
IVersionableHandle versionableHandles = new ArrayList<IVersionableHandle>(changeSet.changes().size);
for (IChange change : (List<IChange>) changeSet.changes()) {
    versionableHandles.add(change.afterState());
}

List<IVersionable> versionables = SCMPlatform.getWorkspaceManager(repo).versionableManager().fetchCompleteStates(versionableHandles, monitor);

versionables[i].getName(); // gives you the filename


vijayakumar ramesh commented Jan 13 '21, 8:42 a.m. | edited Jan 13 '21, 8:43 a.m.
Thanks a lot for the support, highly appreciate it. Below code worked for me.
for (IChange change : (List<IChange>) changeSet.changes()) {
 IVersionable   versionable= SCMPlatform.getWorkspaceManager(teamRepository).versionableManager().fetchCompleteState(change.afterState(), monitor); 

} 

need to take care for cases when file is deleted/removed from SCM , versionable will be null.

showing 5 of 10 show 5 more comments

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.