How to get a component by component and a projectArea in plain java api
I am writing using plain java to find a component. I only have a project area name and a component name as argument. How shoud I write api to get the component or component list. |
4 answers
IWorkspaceManager# findComponents(java.lang.String namePattern, IAuditableHandle owner, boolean exact, org.eclipse.core.runtime.IProgressMonitor progressMonitor) throws TeamRepositoryExceptionYou can use the #findComponents(*) call to get a list of components matching your conditions. IProcessClientService and IProcessItemService both have ways to get an item handle for your project area but it's easier to get a handle if you are working with item IDs. Comments
silencehill wu
commented Aug 26 '13, 11:30 a.m.
I think the answer can not resolve my problem.
You don't have to give it a project area and if you don't know the owner then that's the best you can do with the query conditions.
silencehill wu
commented Aug 26 '13, 8:45 p.m.
The project area is not the owner of this component, but it is under this project area. From view of RTC client, I can see the component in a stream of this project area. So I really need get the component under this project area. If I don't pass project area, how can I avoid this api get the component with same name in another project area.
Geoffrey Clemm
commented Aug 26 '13, 10:26 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
A component has a global name ... it does not have different names depending on where it is used. Any component can be added to any stream (if the user has read access to the component, and write access to the stream). There is no concept in RTC of a component being "under" a project area. A component can be owned by a (single) project area, and it can be used by an arbitrary number of streams or workspaces.
silencehill wu
commented Aug 26 '13, 11:24 p.m.
I got the component concept. But why the component can be display in a stream of a project area? Dose project Area really unuseful in API to find a component unless project area is owner of component? 1
The component shows in the stream because it is in that configuration. The project area owns the stream (or one of the project area's teams owns it) so it shows there. If you are looking at the "Components" node under a project area then that means the project area or one of its teams owns the component.
silencehill wu
commented Sep 01 '13, 12:29 p.m.
So I have to get the stream, and then loop components in a streams, Do you have any idea to get the component in a stream by one api? IWorkspaceConnection#getComponents() returns a list of IComponentHandle. You may want to mention your overall goal. The component handle at this point isn't particularly significant because you could have retrieved it with the component search mentioned above. The component handle itself isn't going to provide any specific information about existing in the stream. You likely would want the component's configuration to get anything significant.
showing 5 of 8
show 3 more comments
|
Ralph Schoon (63.5k●3●36●46)
| answered Sep 02 '13, 2:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You again use the Workspacemanager to find all streams:
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(teamRepository); IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY .newInstance().setKind(IWorkspaceSearchCriteria.STREAMS); List<IWorkspaceHandle> streams = wm.findWorkspaces(criteria, Integer.MAX_VALUE, monitor); |
I have a utility to copy a project to another server. it does streams and workspaces, and can select workspaces for specific users (src= source system, dest = destination system)
here is the code to find workspaces for the non-archived users in a spacified list (by email address) IContributor srcwkspace_owner = (IContributor) srcauditableClient.fetchCurrentAuditable(srcowner, ItemProfile.createProfile(IContributor.ITEM_TYPE, new String[] { IContributor.ARCHIVED_PROPERTY, IContributor.NAME_PROPERTY, IContributor.EMAIL_ADDRESS_PROPERTY }), null); // only for non-archived users if (!srcwkspace_owner.isArchived()) { // if no selection list (everyone), or the user is in the selection list (the select few) // copy their workspaces if (userworkspaces.isEmpty() || userworkspaces.get(srcwkspace_owner.getEmailAddress().toLowerCase()) != null) { IWorkspaceSearchCriteria workspacesearchcriteria = IWorkspaceSearchCriteria.FACTORY.newInstance(); // say we want workspaces workspacesearchcriteria.setKind(IWorkspaceSearchCriteria.WORKSPACES); // for THIS user workspacesearchcriteria.setExactOwnerName(srcwkspace_owner.getName()); // get the list List<IWorkspaceHandle> user_workspacehandles = (List<IWorkspaceHandle>) srcmgr.findWorkspaces(workspacesearchcriteria, IWorkspaceManager.MAX_QUERY_SIZE, null); |
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.