How to get all Streams under a projectArea with java plain api
Hi,
I want to get all streams under a project area. Now I get IProjectArea object and IProjectAreaHandle through the code as follows:
ITeamRepository repository = openRepositoryConnection();
IProcessClientService processClientService = (IProcessClientService)repository.getClientLibrary(IProcessClientService.class);
URI uri = URI.create(URIUtil.encodePath(projectAreaName));
IProcessArea processArea = processClientService.findProcessArea(uri, null, null);
if (processArea instanceof IProjectArea){
IProjectArea projectArea = (IProjectArea) processArea;
IProjectAreaHandle projectAreaHandle = projectArea.getProjectArea();
}
}
3 answers
I use this in one of my plain java applications
after the search for Streams, I then test to see if the stream process area matches the project area
final IWorkspaceManager srcmgr = SCMPlatform.getWorkspaceManager(srcrepo);
IWorkspaceSearchCriteria srcstreamsearchcriteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
srcstreamsearchcriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
// loop thru all the streams on the src system
for (IWorkspaceHandle iwsh : (List<IWorkspaceHandle>) srcmgr.findWorkspaces(srcstreamsearchcriteria, IWorkspaceManager.MAX_QUERY_SIZE, null))
{
IWorkspaceConnection stream = srcmgr.getWorkspaceConnection(iwsh, null);
if(stream.getProcessArea(null).getItemId().getUuidValue().equals(owning_project.getProjectArea().getItemId().getUuidValue()) )
{
// is in this project area
}
you don't need the SDK for this..
after the search for Streams, I then test to see if the stream process area matches the project area
final IWorkspaceManager srcmgr = SCMPlatform.getWorkspaceManager(srcrepo);
IWorkspaceSearchCriteria srcstreamsearchcriteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
srcstreamsearchcriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
// loop thru all the streams on the src system
for (IWorkspaceHandle iwsh : (List<IWorkspaceHandle>) srcmgr.findWorkspaces(srcstreamsearchcriteria, IWorkspaceManager.MAX_QUERY_SIZE, null))
{
IWorkspaceConnection stream = srcmgr.getWorkspaceConnection(iwsh, null);
if(stream.getProcessArea(null).getItemId().getUuidValue().equals(owning_project.getProjectArea().getItemId().getUuidValue()) )
{
// is in this project area
}
you don't need the SDK for this..
This post might contain what you are looking for: https://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/
Comments
Thanks for replying.
In the given url of "Manage Streams" part, it use IWorkspaceSearchCriteria to search some special Streams according its name. But I want to get all streams under a special ProjectArea through IProjectArea object or IProjectAreaHandle object. Any thought?
I would consider search criteria such as Owner (a team or project area for a stream). sorry, that is what I know about the API and what I found for this purpose. There might be other ways, the RTC Eclipse client uses something to show all streams in the Team Artifacts view. You can search the SDK for that.
Okay, but how to use the SDK? I downloaded RTC-SDK-4.0.6.zip from jazz server and unzip it, then got three sub folders and two jar files. How do I use them?
Start here:
- https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/
- https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/
Various posts on that site explain how to search the API in Eclipse once you have done 1 and 2. You can search the site for articles using keywords.
Based on Sam code, if you already know the Project Area I think you may simply add the search criteria:
srcstreamsearchcriteria.setExactOwnerName(projecAreaName);
and then cycle through the resulting Handles:
List<IWorkspaceHandle> wksHandles = wksManager.findWorkspaces(wksSearchCriteria, IWorkspaceManager.MAX_QUERY_SIZE, null);
for (IWorkspaceHandle wksHandle : wksHandles) {
IWorkspaceConnection stream = wksManager.getWorkspaceConnection(wksHandle, null);
log.trace("Stream =>" + stream.getName() + "<=");
}