how to retrieve the name of all Streams of a project area?
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!
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
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);
...