[SOLVED] Get users with a role on a Teamarea
I'm developing a plugin that needs to get a list of all the members from a teamArea that have a determinated role ( p.e. ScrumMaster ).
I've been able to get the IContributor list from the TeamArea, but I can't figure how to get the roles from that team area and match the data or if there is any 'magic' method to get the relation between user/role in a teamArea.
Any idea?
Thanks!
4 answers
As per IServerProcess documentation:
"A server process is a proxy for the server-side team process for a given project area. Server processes can not be persisted or be returned by a service method"
So try following code to get the Server Process from the governing Process Area service:
IProcessServerService processService = getService(IProcessServerService.class);
IServerProcess serverProcess = processService.getServerProcess(processArea);
And the required service you depend on is then "IProcessServerService".
Regards,
Jorge.
It worked !
To sum up a bit this thread I post the 'key' code to work with the roles of a team area in a plugin.
IProcessServerService processService = getService(IProcessServerService.class);
IProcessArea processArea = operation.getProcessArea();
IServerProcess serverProcess = processService.getServerProcess(processArea);
IRole [] memberRoles = serverProcess.getContributorRoles(memberHandle, processArea);
And add on the plugin.xml the prerequisite
com.ibm.team.repository.service.IRepositoryItemService
Thank u all for the help!
Comments
I'm trying to do something similar to this and am having difficulties following the example outlined in this thread. Can you elaborate on what you needed to do to get this working?
Why did you include a mention of IRepositoryItemService in the plugin.xml? Did you also include the IServerProcess as a prerequisite as well as you seemed to indicate in your previous post? Did you need to import the class as you had indicated in your previous post or was the prerequisite all that was needed?
when you create your plugin, open the plugin.xml and on the Extensions tab,
expand your extension definition, by right clicking to keep adding elements thru the Prerequisites.
1 vote
Thanks for the clarification. I think I finally realized what was going on here. I should have read your earlier post more carefully. I had assumed you could instantiate an instance of IServerProcess by saying something like:
IServerProcess sp = getService(IServierProcess.class);
I see now though that you have to go through the IProcessServerService. I think that was my issue. I'll give that a try.
Hi,
I'm developing a plugin that needs to get a list of all the members from a teamArea that have a determinated role ( p.e. ScrumMaster ).
I've been able to get the IContributor list from the TeamArea, but I can't figure how to get the roles from that team area and match the data or if there is any 'magic' method to get the relation between user/role in a teamArea.
Any idea?
Thanks!
Try below sample code:
IServerProcess serverProcess = getProcessService().getServerProcess(fProjectArea);
1. get all roles:
IRole[] roles = serverProcess.getRoles(fProjectArea);
2. getting contributor role:
IRole[] contributorRoles = serverProcess.getContributorRoles(contributor, fProjectArea);
I've been trying the second option:
getting contributor role:
IRole[] contributorRoles = serverProcess.getContributorRoles(contributor, fProjectArea);
I did:
import com.ibm.team.process.service.IServerProcess;
IServerProcess serverProcess = getService(IServerProcess.class);
IRole [] memberRoles = serverProcess.getContributorRoles(memberHandle, processArea);
I also registered the service 'com.ibm.team.process.service.IServerProcess' in the plugin.xml as a prerequisite.
<extension>
<operationAdvisor>
<description> XXX
</description>
<extensionService>
<prerequisites>
<requiredService> <requiredService>
</prerequisites>
</extensionService>
</operationAdvisor>
</extension>
And iside the prerequiste tag interface="com.ibm.team.process.service.IServerProcess"
The problem I get is that when I execute the advisor I get the following error:
CRJAZ1115I The service "com.ibm.team.process.service.IServerProcess" is not registered, any idea why this is happening?
Thanks!