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

How to fetch role name using role ids using plain Java API?

 Hi all,


I want to find out team area roles for the user and I used below code to for role ids:
teamArea.getRoleAssignmentIds(contributor);

but I want name of the role please give me API to fetch role name using its id.

Alternatively, I tried 

IRole2[] contributorRoles = (IRole2[]) process.getContributorRoles(contributor, projectArea, null);

But it returns the roles of project area also. So it is not useful to me. I need only team area roles.

Please provide the right API

0 votes


Accepted answer

Permanent link
Try this code snippet.
It used to work for me.

String URI = ....;
ITeamRepository  teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(URI);
IProcessClient  processClient = (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
// IProcessArea can be a Project Area, or a Team Area
ITeamArea teamArea = ...;
IRole[] processAreaRoles = getProcessAreaRoles(teamArea );
IContributor contributor = ...;
IRole[] contributorRoles = teamArea .getRoleAssignments(contributor, processAreaRoles);
for (int i=0; i<contributorRoles.length; i++) {
IRole contributorRole = contributorRoles[i];
IRole2 contributorRole2 = (IRole2) contributorRole;
System.out.println(contributorRole2.getRoleName());
}
Andrew Ciaz selected this answer as the correct answer

0 votes


One other answer

Permanent link

 @Luca Martinucci thanks for the help

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,936
× 1,700

Question asked: Apr 29 '20, 6:24 a.m.

Question was seen: 2,163 times

Last updated: May 11 '20, 4:22 a.m.

Confirmation Cancel Confirm