It's all about the answers!

Ask a question

How to get OperationHistory of the stream programmatically using RTC api?


1
1
Rajat Krishnan (212) | asked Dec 16 '19, 5:37 a.m.
edited Dec 18 '19, 12:41 a.m.
Hello Team,
Usecase:
We are actually planning to clean up some of the Streams in the Project area ( 40+).
to do this activity, we would like to have a report showing which streams are actively working(Some operation happening in the Stream) or which are not( Operations done few months back like Changeset deliver,,,)

In Eclipse Client, we can see this using Operation History option, which gives me operations currently happening in the Stream. But doing this for all the 40+ streams is difficult.

So could you please support how to achieve this use case using RTC API?


Thanks in advance!!


Comments
Ralph Schoon commented Dec 18 '19, 2:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

You have asked your question Dec 13th. You could edit that if you wanted to. Please do not spam the forum with duplicate questions. I closed the older one for this time.


Rajat Krishnan commented Dec 18 '19, 4:34 a.m.

@Ralph Schoon, Apologies for the same but there seems some problem with jazz forum, like i was trying to delete my earlier question but it was not getting deleted, may be next time i will keep this thing in my mind, but anyway can you please help me with the above query ?


Ralph Schoon commented Dec 18 '19, 4:47 a.m. | edited Dec 18 '19, 4:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Don't worry Rajat. I have seen such delete issues myself. Also, sometimes you ask a question once and somehow it has a twin.

I have not looked into that particular API.

Accepted answer


permanent link
David Lafreniere (4.5k7) | answered Jan 07, 3:05 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Oct 08, 7:51 p.m.
Note: This is not official API, however here is the way to retrieve the same information that would be shown in the Operation History view in Eclipse:


ParmsGetWorkspaceHistory parms = new ParmsGetWorkspaceHistory();
parms.workspaceId = uuidOfStream;
parms.includeDetails = false; // We don't care about all the details, only the time really....
parms.maxResultSize = 1; // We just need the most recent operation entry

IScmRichClientRestService scmService = (IScmRichClientRestService) ((IClientLibraryContext) repository).getServiceInterface(IScmRichClientRestService.class);
ScmWorkspaceHistory workspaceHistory = scmService.postGetWorkspaceHistory(parms);
if (workspaceHistory.getHistoryEntries().size() > 0) {
   ScmWorkspaceHistoryEntry entry = (ScmWorkspaceHistoryEntry) workspaceHistory.getHistoryEntries().get(0);
   date = entry.getDate(); // This is the date of the last operation against this stream....
}
Ralph Schoon selected this answer as the correct answer

Comments
vijayakumar ramesh commented Sep 30, 8:37 a.m.
ScmWorkspaceHistory workspaceHistory = scmService.postGetWorkspaceHistory(parms);
this line gives error ,saying Parms is compatible.

1
David Lafreniere commented Oct 01, 5:22 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
By "compatible" do you mean "incompatible"?
Can you provide the actual error message + stack trace?

vijayakumar ramesh commented Oct 08, 6:00 a.m.

 Hello David ,


Thanks for the snippet .It is working fine.

I need support in finding details of components which gets affected with delivery operation.

Example: When user delivers 3 change sets to 3 different component. From above snippet ,I get info on how many comments get affected but not the details of which components.  


vijayakumar ramesh commented Oct 08, 9:35 a.m.
Hello David,
I am using below snippet

ParmsGetWorkspaceHistory parms = new ParmsGetWorkspaceHistory();
parms.workspaceId = uuidOfStream;

commmented these two params // parms.includeDetails = false; // We don't care about all the details, only the time really....// parms.maxResultSize = 1; Result of history entries is coming for around last 6 months but not fully since the stream is created.What am I missing to set ? or How can I  get all operation entries  (since beginning of streams)


1
David Lafreniere commented Oct 08, 7:50 p.m. | edited Oct 08, 7:52 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

For identifying the components:
-->ScmWorkspaceHistory .getHistoryEntries() to give ScmWorkspaceHistoryEntry
-->ScmWorkspaceHistoryEntry.getDescription() to give ScmWorkspaceOperationDescription 
-->ScmComponentOperationDescription.getComponent() to identify the component

For getting the entire history:
IScmRichClientRestService.postGetWorkspaceHistory() will not return the entire history as that may be too large. To get all the data you will need to make multiple calls, paging through the results. If the return value has ScmWorkspaceHistory.getNextPage() non-null and non-empty, then you pass that along as an argument using ParmsGetWorkspaceHistory.pageToken to get subsequent pages.


vijayakumar ramesh commented Oct 09, 9:50 a.m. | edited Oct 09, 9:51 a.m.

Hello David,

thank you so much for earlier comment.
ParmsGetWorkspaceHistory parms = new ParmsGetWorkspaceHistory();
parms.workspaceId = uuidOfStream;
while(workspaceHistory.getNextPage() !=null) {
parms.pageToken=workspaceHistory.getNextPage();
      ScmWorkspaceHistory workspaceHistory = scmService.postGetWorkspaceHistory(parms); 
}
I am still not getting full history entries. What am I using it wrongly from your description?


vijayakumar ramesh commented Oct 13, 8:31 a.m.

Hello David,


Support here, would be very much helpful and appreciate it.


1
David Lafreniere commented Oct 13, 10:07 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

To clarify, workspaceHistory.getHistoryEntries() is non-empty for the first page, but it is empty for the 2nd page?

Also, it's hard for me to confirm that your stream has more than 512 'changes' to it (perhaps they all do fit within the 1st page). What type of changes are you missing? (perhaps you are expecting a change type that is not actually included in the operation history)


vijayakumar ramesh commented Oct 19, 6:52 a.m.

 workspaceHistory.getHistoryEntries() is non-empty for the first page but for second page also it is non empty. 


In the Streams which are one or two year old ,I have all entries in first page itself.In this case it is totally fine. But for two streams which are older than 3 years. They have more entries. In these streams after fetching entries of second page if I run the code , it gets same 2nd page entries. So in total I am getting 1024 entries after that, second page entries gets repeated.


vijayakumar ramesh commented Oct 19, 9:21 a.m.

workspaceHistory.getNextPage(); value remains constant 1586880172836, does it indicate something.? 


1
David Lafreniere commented yesterday
FORUM MODERATOR / JAZZ DEVELOPER

Are you sure in the code you are using that you are getting the getNextPage() from the correct workspaceHistory instance?


1
David Lafreniere commented yesterday
FORUM MODERATOR / JAZZ DEVELOPER
In particular, the code you pasted above has an issue with variable shadowing...

vijayakumar ramesh commented yesterday | edited yesterday
while(workspaceHistory.getNextPage() !=null) {
parms.pageToken=workspaceHistory.getNextPage();
  workspaceHistory = scmService.postGetWorkspaceHistory(parms); // read the entries using workspaceHistory object
} thanks for hint, there was  variable shadowing. Now my code works perfectly fine and retrieves complete History entries. I highly appreciate  your support and being patient with my queries :) 

1
David Lafreniere commented yesterday
FORUM MODERATOR / JAZZ DEVELOPER

Glad you resolved it.
Please click 'Mark this answer as the accepted answer'.


vijayakumar ramesh commented yesterday

 For identifying the components:
-->ScmWorkspaceHistory .getHistoryEntries() to give ScmWorkspaceHistoryEntry 
-->ScmWorkspaceHistoryEntry.getDescription() to give ScmWorkspaceOperationDescription 

How to get  ScmComponentOperationDescription from ScmWorkspaceOperationDescription  object seems to not direct
-->ScmComponentOperationDescription.getComponent() to identify the component


David Lafreniere commented yesterday
FORUM MODERATOR / JAZZ DEVELOPER

It's literally the first method in the ScmWorkspaceOperationDescription.java file. Please spend a bit of effort looking through the classes to see what's available :)

ScmWorkspaceOperationDescription desc = workspaceHistoryEntry.getDescription();
List<ScmComponentOperationDescription> componentOperations = desc.getComponentDescriptions();



vijayakumar ramesh commented 4 hours ago
ScmWorkspaceOperationDescription wsOpDesc =entry.getDescription(); List<ScmComponentOperationDescription> compOpDesc =wsOpDesc.getComponentDescriptions();
          for (Iterator<ScmComponentOperationDescription> it = compOpDesc.iterator(); it.hasNext();) {
            ScmComponentOperationDescription compDesc= it.next();
            System.out.println(compDesc.getComponent().getName());
          }
    Earlier I had tried wsOpDesc.getComponentDescriptions(); this, as it was returning just List  ,I thought it may not be the type, ScmComponentOperationDescription. so asked you.  I checked for around 4 streams , all of them give null value for entry.getDescription();  it is bit surprising , how can it be null in 4 streams :(. this blocks me further getting any component details. Does it indicate something wrong with stream ?
showing 5 of 17 show 12 more comments

Your answer


Register or to post your answer.