RTC: Find a Stream by ProjectArea and Contributor using Java API 3 (or 5)
Hello,
I'd like to find Streams using project areas and contributors as query parameters using the Java API.
I'm currently working with the Java API 3.0.1.6iFix3, but soon I could use the 5.0.1 version.
I've found a blog post from Ralph Schoon: "Managing Workspaces, Streams and Components Using the Plain Java Client Libraries" (http://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/) that has methods for finding Streams by using the class IWorkspaceManager, specifically, findWorkspaces with a IWorkspaceSearchCriteria.
Fatla 777 asked something similar, Get Stream from ProjectArea using RTC API 4 , and I've used the code that is included in the comment that was made in Feb 22 '13, 3:00 p.m:
But it doesn't work. It returns an empty List.
I've searched the Stream for printing its projectArea (actually, its process area) and the name that I've provided seems correct.
Can anyone tell me if I'm providing the project area name erroneously? and how can I filter Streams by Contributor?
Thank you very much,
Javier.
I'd like to find Streams using project areas and contributors as query parameters using the Java API.
I'm currently working with the Java API 3.0.1.6iFix3, but soon I could use the 5.0.1 version.
I've found a blog post from Ralph Schoon: "Managing Workspaces, Streams and Components Using the Plain Java Client Libraries" (http://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/) that has methods for finding Streams by using the class IWorkspaceManager, specifically, findWorkspaces with a IWorkspaceSearchCriteria.
Fatla 777 asked something similar, Get Stream from ProjectArea using RTC API 4 , and I've used the code that is included in the comment that was made in Feb 22 '13, 3:00 p.m:
IWorkspaceManager workspaceManager = SCMPlatform.getWorkspaceManager(repository);
IWorkspaceSearchCriteria wsSearchCriteria = WorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
wsSearchCriteria.setPartialOwnerNameIgnoreCase(projectAreaName); //I've donde this
// How can I provide the Contributor?
List <IWorkspaceHandle> workspaceHandles = workspaceManager.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, Application.getMonitor()); //It returns an empty list in my case
IWorkspaceConnection workspaceConnection = workspaceManager.getWorkspaceConnection(workspaceHandles.get(0),Application.getMonitor());
But it doesn't work. It returns an empty List.
I've searched the Stream for printing its projectArea (actually, its process area) and the name that I've provided seems correct.
Can anyone tell me if I'm providing the project area name erroneously? and how can I filter Streams by Contributor?
Thank you very much,
Javier.
2 answers
Thanks Ralph for the reply and for your very interesting blog.
I've been searching for a while, but I have found only the two solutions that I mentioned.
It should work, but it seems it doesn't. As an alternative I'm thinking in finding all the Streams and validate if each of them belongs to the desired Project Area and Contributor.
But it's too "brute force", because there are currently more than 100 Streams.
I'll try with the Java API 5 (but I have to install a RTC v5 before)
Regards,
Javier.
I've been searching for a while, but I have found only the two solutions that I mentioned.
It should work, but it seems it doesn't. As an alternative I'm thinking in finding all the Streams and validate if each of them belongs to the desired Project Area and Contributor.
But it's too "brute force", because there are currently more than 100 Streams.
I'll try with the Java API 5 (but I have to install a RTC v5 before)
Regards,
Javier.
Comments
Almost solved.
The code above works, but in my case (and I don't know if it's a general rule) the Stream belongs to an ItemArea, and I was using the name of the projectArea instead of the particular teamArea.
Anyway, I still miss a clear way to filter by Contributor.
What I've done is to obtain the ProcessArea that the IComponent belongs to, via IWorkspaceConnection.getOwner() (I tried with IWorkspaceConnection.getProcessArea(IProgressMonitor but it didn't return what I expected), and after fetching the complete item...
IProcessArea processArea = (IProcessArea) repository.itemManager().fetchCompleteItem(workspaceConnection.getOwner(), ItemManager.REFRESH, monitor);
... I use the processArea's member list to verify if some of them has an ItemID that is the same of the Contributor I'm interested in.
Brute force again, but I don't know any easier way.
I accept any suggestion.
Greetings,
Javier.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Sep 23 '14, 4:22 a.m.