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

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

 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

0 votes



2 answers

Permanent link
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");
    }

0 votes

Comments

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

Thanks Ralph for the answer.

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

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

0 votes

Comments

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 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
× 1,220

Question asked: May 18 '16, 11:51 p.m.

Question was seen: 3,720 times

Last updated: May 20 '16, 2:50 a.m.

Confirmation Cancel Confirm