It's all about the answers!

Ask a question

Get the role/roles of a contributor


0
1
Paulino Alonso (381214) | asked Jul 19 '12, 9:25 a.m.
edited Jul 19 '12, 10:37 a.m. by David Olsen (5237)
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();
        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

Accepted answer


permanent link
Ralph Schoon (56.2k23642) | answered Jul 19 '12, 11:25 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 19 '12, 11:26 a.m.
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();
    }

Ralph Schoon selected this answer as the correct answer

4 other answers



permanent link
Ralph Schoon (56.2k23642) | answered Jul 19 '12, 10:36 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
A process area can be a project area or a team area, I believe, if you look at the type hierarchy. I have passed project areas as well as team areas. Both work. You can have users and roles in both levels.

permanent link
Paulino Alonso (381214) | answered Jul 19 '12, 10:45 a.m.
Ralph, thank you for your quick response!!

My problem is how to know the process or the project area...

thanks!

permanent link
Ralph Schoon (56.2k23642) | answered Jul 19 '12, 11:07 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Jul 19 '12, 11:10 a.m.
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.

permanent link
Paulino Alonso (381214) | answered Jul 19 '12, 11:24 a.m.
Thanks again

with your help and this post
https://jazz.net/forum/questions/65852/advisor-plugin-using-iteamrepository

i get it!!

thanks

Your answer


Register or to post your answer.