It's all about the answers!

Ask a question

how to retrieve the name of all Streams of a project area?


Leandro Leal (14613445) | asked Apr 14 '12, 8:16 p.m.
Hi,

i need retrieve the name of all streams of a project area x, using API JAVA LIB. how to do this?

my code is this:

IProgressMonitor monitor = new NullProgressMonitor();
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
IWorkspaceSearchCriteria wsSearchCriteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
wsSearchCriteria.setPartialOwnerNameIgnoreCase(ProjectArea);
List <IWorkspaceHandle> workspaceHandles = wm.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, monitor);



thanks!

5 answers



permanent link
sam detweiler (12.4k6175200) | answered Apr 15 '12, 7:49 a.m.
did u look at the build system toolkit for apis? this provides additional classes for accessing streams and their content

permanent link
Leandro Leal (14613445) | answered Apr 15 '12, 2:32 p.m.
did u look at the build system toolkit for apis? this provides additional classes for accessing streams and their content


may indicate a link to documentation or an example

permanent link
David Lafreniere (4.4k7) | answered May 10 '12, 6:52 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
Hi,

i need retrieve the name of all streams of a project area x, using API JAVA LIB. how to do this?

my code is this:

IProgressMonitor monitor = new NullProgressMonitor();
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository);
IWorkspaceSearchCriteria wsSearchCriteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
wsSearchCriteria.setKind(IWorkspaceSearchCriteria.STREAMS);
wsSearchCriteria.setPartialOwnerNameIgnoreCase(ProjectArea);
List <IWorkspaceHandle> workspaceHandles = wm.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE, monitor);

thanks!


Hi,

You are on the right track.
That code you have will give you the handles of the streams, however you now have to fetch them from the repository so that you can get the most recent name.

do this from where you left off (Not tested, but should be mostly right):


List<String> streamNames = new ArrayList<String>(workspaceHandles.size());

IFetchResult fetchResults = teamRepository.itemManager().fetchCompleteItemsPermissionAware(workspaceHandles, IItemManager.REFRESH, monitor);
List<Object> retrievedStreams = fetchResults.getRetrievedItems();

for (Object fetchedObject : retrievedStreams) {
if (fetchedObject instanceof IWorkspace) {
IWorkspace stream = (IWorkspace) fetchedObject;
streamNames.add(stream.getName());
}
}


Note: using IItemManager.REFRESH will take longer but will give you the up-to-date names of the streams in the repository. Or you could use IItemManager.DEFAULT to have it possibly run quicker, giving you the names that are from the local cache (but there's a small chance that they could be stale if someone were to rename the streams)

Also, at a quick glance, if the first part that you have doesn't work (due to wsSearchCriteria.setPartialOwnerNameIgnoreCase()) , do this;

List<IProcessArea> processAreas = new ArrayList<IProcessArea>();
...
add the process areas you care about.
...
...
wsSearchCriteria.getFilterByOwnerOptional().addAll(processAreas);
...

permanent link
VK L (8177129159) | answered May 11 '12, 11:23 a.m.
Is it possible to do this in attribute customization (Javascript) to create dependent enumerations based on selected project area?

Thanks.

permanent link
David Lafreniere (4.4k7) | answered May 11 '12, 11:26 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Is it possible to do this in attribute customization (Javascript) to create dependent enumerations based on selected project area?

Thanks.


That I have no idea. Hopefully someone else who reads this can provide some insight.

Your answer


Register or to post your answer.