It's all about the answers!

Ask a question

How to add members to Project Area in Rational Design Manager programmatically


Chandan M B (11314184) | asked May 18 '16, 11:51 p.m.
 Hello,

I have multiple project areas in a server. I need to add all the members to the multiple project areas programmatically and as well as assign roles for them.

How to do it ? Is there Java API available like RTC or should i go for OSLC ?

Regards,
Chandan

2 answers



permanent link
Ralph Schoon (63.5k33646) | answered May 19 '16, 4:11 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
For RTC, QM, RDNG it is possibl eto use the RTC Plain Java Client libraries and the code would be the same like below. I have no example for OSLC. Most likely there is no OSLC spec. There might be REST services you could use.


    /**
     * Adds users and roles to a project area.
     *
     * @param teamRepository
     * @param area
     * @param monitor
     * @return
     * @throws TeamRepositoryException
     */
    private IProjectArea addUsersAndRoles(ITeamRepository teamRepository,
            IProjectArea area, String userID, String roleID, IProgressMonitor monitor)
            throws TeamRepositoryException {

        IProcessItemService service = (IProcessItemService) teamRepository
                .getClientLibrary(IProcessItemService.class);
        area = (IProjectArea) service.getMutableCopy(area);
        System.out.println("Trying to add member with roles: "
                + roleID + " to Project Area" + area.getName());

        IContributor user = teamRepository.contributorManager().fetchContributorByUserId(userID, monitor);
        //area.addAdministrator(user);
        area.addMember(user);

       
        IRole role = getRole(area, roleID, monitor);
        area.addRoleAssignments(user, new IRole[] { role });
        @SuppressWarnings("unused")
        IProcessItem[] items = service.save(new IProcessItem[] { area },
                monitor);
        System.out.println("Users with Roles added to " + area.getName());
        return area;
    }

    /**
     * Gets a role by its ID.
     *
     * @param area
     * @param roleID
     * @param monitor
     * @return
     * @throws TeamRepositoryException
     */
    private IRole getRole(IProcessArea area, String roleID,
            IProgressMonitor monitor) throws TeamRepositoryException {
        ITeamRepository repo = (ITeamRepository) area.getOrigin();
        IProcessItemService service = (IProcessItemService) repo
                .getClientLibrary(IProcessItemService.class);
        IClientProcess clientProcess = service.getClientProcess(area, monitor);
        IRole[] availableRoles = clientProcess.getRoles(area, monitor);
        for (int i = 0; i < availableRoles.length; i++) {
            IRole role = availableRoles[i];
            // IRole2 role2 = (IRole2)role;
            // role2.getRoleName();
            if (role.getId().equalsIgnoreCase(roleID))
                return role;
        }
        throw new IllegalArgumentException("Couldn't find roles");
    }


Comments
Ralph Schoon commented May 19 '16, 4:12 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

PS: the code above would work for team areas or, if you use IProcessArea for both.


Chandan M B commented May 19 '16, 4:16 a.m.

Thanks Ralph for the answer.

But what about RDM ? Can i use the same RTC API's  for RDM as well ?


Ralph Schoon commented May 19 '16, 4:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I haven't tested RDM because I have not installed it. My assumption would be it uses the same Jazz core API, but I leave it to the reader to test that.


permanent link
Chandan M B (11314184) | answered May 20 '16, 12:13 a.m.
 This is the response from IBM David Hirsch
RDM SDK currently doesn't support creating project areas or adding members to it.
The creation of project areas is provided by jfs. 

RTC SDK (to my best knowledge) is using the jfs client libraries to provide the service of manipulating projectareas.

Currently dm sdk is not build on top of the jfs clients. As a result we cannot provide this service out of the box.

OSLC is a linking protocol, it doesn't play a role when creating project areas. 

Comments
Ralph Schoon commented May 20 '16, 2:33 a.m. | edited May 20 '16, 2:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

It might be smart to just try if the code above works with DM. Reading again, I think David  says it wouldn't.

Your answer


Register or 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.