Get the role/roles of a contributor
Hello,
I'm working with a follow up ... that extends AbstractService and implements IOperationParticipant
To find the user who is logged:
final IAuditableServer auditableServer = workItemServer.getAuditableServer();
I'm working with a follow up ... that extends AbstractService and implements IOperationParticipant
To find the user who is logged:
final IAuditableServer auditableServer = workItemServer.getAuditableServer();
IContributorHandle userHandle=this.
getAuthenticatedContributor();
IContributor contributor= auditableServer.
resolveAuditable(
userHandle,
ItemProfile.<IContributor>
createFullProfile(
IContributor.ITEM_TYPE),
monitor);
System.out.println("USER logeado: " + contributor.getName());
I need to know contributor roles and the projectArea or processArea in which this work...
this post https://jazz.net/forum/
questions/14492/get-the-role-
of-a-contributor recommend use:
getContributorRoles(IContributorHandle contributor, IProcessArea processArea, IProgressMonitor monitor) ...
but I need the processArea...
Has anyone worked on something like that???
Thanks
IContributor contributor= auditableServer.
userHandle,
ItemProfile.<IContributor>
monitor);
System.out.println("USER logeado: " + contributor.getName());
I need to know contributor roles and the projectArea or processArea in which this work...
this post https://jazz.net/forum/
getContributorRoles(IContributorHandle contributor, IProcessArea processArea, IProgressMonitor monitor) ...
but I need the processArea...
Has anyone worked on something like that???
Thanks
Accepted answer
I looked into my examples. Here some code. Please be aware it is client side code and you might need to use slightly different services. But I would assume you can do similar things in the server api. If you need the team repository, you can get to it from elements using .getOrigin(). I haven't tried to gt deeper into the process e.g. to find permissions etc.
private static void dumpContributor(ITeamRepository teamRepository,
IProcessArea processArea, IContributorHandle handle)
throws TeamRepositoryException {
IContributor contributor = (IContributor) teamRepository.itemManager()
.fetchCompleteItem(handle, IItemManager.DEFAULT, null);
System.out.print(": " + contributor.getUserId() + "\t"
+ contributor.getName() + "\t" + contributor.getEmailAddress()+ "\t");
IProcessItemService processService = (IProcessItemService) teamRepository
.getClientLibrary(IProcessItemService.class);
IClientProcess process = processService.getClientProcess(processArea,
null);
IRole[] contributorRoles = process.getContributorRoles(contributor,
processArea, null);
for (int j = 0; j < contributorRoles.length; j++) {
IRole role = (IRole) contributorRoles[j];
System.out.print(role.getId() + " ");
}
System.out.println();
}
private static void dumpContributor(ITeamRepository teamRepository,
IProcessArea processArea, IContributorHandle handle)
throws TeamRepositoryException {
IContributor contributor = (IContributor) teamRepository.itemManager()
.fetchCompleteItem(handle, IItemManager.DEFAULT, null);
System.out.print(": " + contributor.getUserId() + "\t"
+ contributor.getName() + "\t" + contributor.getEmailAddress()+ "\t");
IProcessItemService processService = (IProcessItemService) teamRepository
.getClientLibrary(IProcessItemService.class);
IClientProcess process = processService.getClientProcess(processArea,
null);
IRole[] contributorRoles = process.getContributorRoles(contributor,
processArea, null);
for (int j = 0; j < contributorRoles.length; j++) {
IRole role = (IRole) contributorRoles[j];
System.out.print(role.getId() + " ");
}
System.out.println();
}
4 other answers
Ah, so I overlooked the most important part in your question.
You implement AbstractService so you can use this.getAuthenticatedContributor() to get it.
If you are looking at other user data you can typically get to the project area e.g. using workItem.getProjectArea() and then you can iterate that for the team areas.
Some code i was using to iterate that structure.
ITeamAreaHierarchy teamhierarchy = projectArea
.getTeamAreaHierarchySnapshot();
List teamAreas = projectArea.getTeamAreas();
for (Iterator iterator = teamAreas.iterator(); iterator.hasNext();) {
ITeamAreaHandle handle = (ITeamAreaHandle) iterator.next();
ITeamArea teamArea = (ITeamArea) teamRepository.itemManager()
.fetchCompleteItem(handle, IItemManager.DEFAULT, null);
dumpContributors(teamRepository, teamArea);
}
I was thinking about your problem, but Ihaven't done an implementation myself.
You implement AbstractService so you can use this.getAuthenticatedContributor() to get it.
If you are looking at other user data you can typically get to the project area e.g. using workItem.getProjectArea() and then you can iterate that for the team areas.
Some code i was using to iterate that structure.
ITeamAreaHierarchy teamhierarchy = projectArea
.getTeamAreaHierarchySnapshot();
List teamAreas = projectArea.getTeamAreas();
for (Iterator iterator = teamAreas.iterator(); iterator.hasNext();) {
ITeamAreaHandle handle = (ITeamAreaHandle) iterator.next();
ITeamArea teamArea = (ITeamArea) teamRepository.itemManager()
.fetchCompleteItem(handle, IItemManager.DEFAULT, null);
dumpContributors(teamRepository, teamArea);
}
I was thinking about your problem, but Ihaven't done an implementation myself.