It's all about the answers!

Ask a question

How to get all Streams under a projectArea with java plain api


Qin Zhang (1122) | asked Nov 05 '14, 5:10 a.m.
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



permanent link
sam detweiler (12.5k6195201) | answered Nov 10 '14, 7:29 a.m.
edited Nov 10 '14, 7:32 a.m.
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..

permanent link
Ralph Schoon (63.6k33647) | answered Nov 05 '14, 5:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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
Qin Zhang commented Nov 05 '14, 5:27 a.m.

 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?




Ralph Schoon commented Nov 05 '14, 5:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Qin Zhang commented Nov 10 '14, 2:49 a.m.

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?


Ralph Schoon commented Nov 10 '14, 2:57 a.m. | edited Nov 10 '14, 2:58 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Start here:

  1. https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/
  2. 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.


permanent link
Stefano Antoniazzi (1701711) | answered Apr 13 '16, 9:59 a.m.
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() + "<=");
}  

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.