Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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();
        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

1

0 votes


Accepted answer

Permanent link
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

0 votes


4 other answers

Permanent link
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.

0 votes


Permanent link
Ralph, thank you for your quick response!!

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

thanks!

0 votes


Permanent link
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.

0 votes


Permanent link
Thanks again

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

i get it!!

thanks

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939
× 89

Question asked: Jul 19 '12, 9:25 a.m.

Question was seen: 6,532 times

Last updated: Jul 19 '12, 11:26 a.m.

Confirmation Cancel Confirm