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

How can i assign multiple process roles to a user in a team area in RTC using plain java api?

Hello,

I need help in adding a user and assigning/adding him/her with multiple process roles in a team area. I have an array where i will be getting the process roles that i need to assign to the user.

static String role[] = new String[] {"Product Owner","User"};

I'm using the code below that i found here in jazz. It's working but the only process role that is being assigned is the last process role in the array. I think it's because of the new keyword for the IContributor and IRole in addContributorsSettingRoleCast, it just overwrites the current process role of the added user everytime it loops.

                    if (teamArea.getName().equals(teamAreaName)) {
                        System.out.println("Adding user to " + teamArea.getName() + " team area");
                       
                        IProcessItemService service = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
                        IProcessAreaWorkingCopy areaWc = (IProcessAreaWorkingCopy) service.getWorkingCopyManager().createPrivateWorkingCopy(teamArea);
                        IContributor contributor = teamRepository.contributorManager().fetchContributorByUserId(memberId, null);
                       
                        areaWc.getTeam().addContributors(new IContributor[] {contributor});
                       
                        for (int i = 0; i < role.length; i++) {
                            IRole roles = getRole(teamArea, role[i]);
                            areaWc.getTeam().addContributorsSettingRoleCast(new IContributor[] {contributor}, new IRole[] {roles});
                        }
                        System.out.println("Added " + contributor.getName());
                        areaWc.save(myProgressMonitor);
                    }


    public static IRole getRole(IProcessArea processArea, String processRole) throws TeamRepositoryException {
        IProcessItemService service =(IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class);
        IClientProcess clientProcess = service.getClientProcess(processArea, null);
        IRole[] availableRoles = clientProcess.getRoles(processArea, null);
        for (int i = 0; i < availableRoles.length; i++) {
            if (availableRoles[i].getId().equals(processRole)) {
                return availableRoles[i];
            }
        }


Can addContributorsSettingRoleCast be used in adding multiple process roles? I tried using it with an ArrayList but there is an error with that. Can i use something else aside from addContributorsSettingRoleCast to add multiple process roles?

0 votes



One answer

Permanent link
Please see the code in https://rsjazz.wordpress.com/2013/09/18/deploying-templates-and-creating-projects-using-the-plain-java-clients-library/ It should work with multiple roles as well.

0 votes

Comments

Hi Ralph,

Thank you for this but i think this is adding multiple roles in a member of a project area. addRoleAssignments doesn't appear as an option for the team area. How will i make IRole to accept multiple roles? Is it possible?

ITeamArea has it too.

        ITeamArea tArea=null;
        tArea.addRoleAssignments(contributor, roles)

IRole is the interface for one role.

You want to study https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/ and https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ thoroughly to understand what to do to set up your environment to be able to use content assist and to browse the API and the JavaDoc.

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

Question asked: Aug 01 '14, 4:17 a.m.

Question was seen: 4,828 times

Last updated: Aug 05 '14, 4:16 a.m.

Confirmation Cancel Confirm