How to get OperationHistory of the stream programmatically using RTC api?
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!!
|
Accepted answer
David Lafreniere (4.8k●7)
| answered Jan 07 '20, 3:05 p.m.
FORUM MODERATOR / JAZZ DEVELOPER edited Oct 08 '20, 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 '20, 8:37 a.m.
ScmWorkspaceHistory workspaceHistory = scmService.postGetWorkspaceHistory(parms);
this line gives error ,saying Parms is compatible.
1
By "compatible" do you mean "incompatible"?
Can you provide the actual error message + stack trace?
vijayakumar ramesh
commented Oct 08 '20, 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 '20, 9:35 a.m.
Hello David,
I am using below snippet
ParmsGetWorkspaceHistory parms = new ParmsGetWorkspaceHistory();
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 '20, 7:50 p.m.
| edited Oct 08 '20, 7:52 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
For identifying the components:
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 '20, 8:31 a.m.
Hello David,
Support here, would be very much helpful and appreciate it.
1
To clarify, workspaceHistory.getHistoryEntries() is non-empty for the first page, but it is empty for the 2nd page?
vijayakumar ramesh
commented Oct 19 '20, 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 '20, 9:21 a.m.
workspaceHistory.getNextPage(); value remains constant 1586880172836, does it indicate something.? 1
Are you sure in the code you are using that you are getting the getNextPage() from the correct workspaceHistory instance?
1
In particular, the code you pasted above has an issue with variable shadowing...
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
Glad you resolved it.
vijayakumar ramesh
commented Oct 21 '20, 10:14 a.m.
For identifying the components:
How to get ScmComponentOperationDescription from ScmWorkspaceOperationDescription object seems to not direct
-->ScmComponentOperationDescription.getComponent() to identify the component 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 :)
vijayakumar ramesh
commented Oct 22 '20, 8:57 a.m.
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 ?
It seems likely that you have not set the ParmsGetWorkspaceHistory.includeDetails to true.
In the above thread you only indicate that you comment out the includeDetails parameter, which is equivalent to setting it to false.
Hallo Andrew Niefer,
Thanks for support it worked.
Further more , I am trying to get change set details such as modified files etc. As of now i could changeset basic info such author, comment and UUID. How can get file level info from ScmWorkspaceHistoryChangeSetImpl object ?
List changeSets=compDesc.getAddedChangeSets();
for(Iterator<ScmWorkspaceHistoryChangeSetImpl> its=changeSets.iterator(); its.hasNext();) {
ScmWorkspaceHistoryChangeSetImpl cs=its.next();
System.out.println(cs.getComment());
System.out.println(cs.getItemId());
System.out.println(cs.getAuthorName());
}
showing 5 of 19
show 14 more comments
|
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.
Comments
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.
@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 ?