Retrieve list of streams in a project area programatically
Hi All,
I am lloking to get the stream names from a project area and add the values into an enumeration. My Plugin is a server-side extension. Which methods can be used to achieve this? I got the below code - but this is client-specific. Pls suggest an alternate code for server 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); 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()); } } Thanks. |
8 answers
Hi,
you have to use IScmQueryService with a IWorkspaceSearchCriteria:
List<IWorkspaceHandle> streams = scmQueryService.findWorkspaces(wsSearchCriteria, Integer.MAX_VALUE , monitor).getItemHandles();
Best regards,
Michele.
|
Hi Michele,
I used this line below and am getting an error saying "cannot make a static reference to the non-static method findWorkspaces from the type ScmQueryService" at compilation itself List<IWorkspaceHandle> streams = ScmQueryService.findWorkspaces(criteria, Integer.MAX_VALUE , (IRepositoryProgressMonitor) monitor).getItemHandles() Am not sure how to fetch results as below to use fetchitems method IFetchResult ws1 = (IFetchResult) ?.fetchItem(workspaceHandle, IRepositoryItemService.COMPLETE); Complete part of the code looks like below: criteria.setKind( IWorkspaceSearchCriteria.STREAMS ); criteria.setPartialOwnerNameIgnoreCase("ccm_user"); criteria.setPartialOwnerNameIgnoreCase("Demo Formal"); List<IWorkspaceHandle> streams = ScmQueryService.findWorkspaces(criteria, Integer.MAX_VALUE , (IRepositoryProgressMonitor) monitor).getItemHandles(); List<String> streamNames = new ArrayList<String>(workspaceHandles.size()); if (workspaceHandles.size() > 1) { throw new TeamRepositoryException( workspaceHandles.size() + " \"" + streamNames + "\" streams found" ); } if (!workspaceHandles.isEmpty()) { IWorkspaceHandle workspaceHandle = workspaceHandles.get( 0 ); IItemHandle it = workspaceHandle.getFullState(); IFetchResult ws1 = (IFetchResult) ?.fetchItem(workspaceHandle, IRepositoryItemService.COMPLETE); if (ws1 instanceof IWorkspace) { IWorkspace stream = (IWorkspace) ws1; streamNames.add(stream.getName()); System.out.println("First Stream name is" + streamNames.get(0)); } } Thanks. |
|
Hi ,
See the post https://jazz.net/forum/questions/72283/use-of-iscmqueryservicefindworkspaces-on-rtc-server |
Hi Muthukumar,
I did refer this link previously. But, there are 2 main problems:
|
Seems to be a User Defined variable.
Use the getService method to get the access to that.
|
Hi Muthukumar,
I have changed it to: IScmQueryService commondata = this.getService(IScmQueryService.class);
How to retrieve
? Currently, I have cast the
".
Thanks. Comments
Muthukumar C
commented Aug 07 '12, 6:26 a.m.
I Hope "null" will be enough for monitor parameters. findWorkspaces(criteria, Integer.MAX_VALUE ,null).getItemHandles; |
Hi Muthukumar,
I have made some modifications and able to retrieve the streams now. Now, i am trying to add the values to the enumeration using : IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>)workItemCommon.resolveEnumeration(attribute1, monitor); List<ILiteral> enumerationLiterals = enumeration.getEnumerationLiterals(); My question here is : Even if i configure this enumeration as a dependent of another attribute in the process template, my code will run everytime the WI is saved. So, how to make sure that only 1 set is generated so that it will be used for later similar combinations? without adding on values over and over? Thanks. |
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.