It's all about the answers!

Ask a question

Teams role API


EclipseTalk . (32736061) | asked Mar 26 '10, 11:04 a.m.
retagged Jan 04 '13, 7:05 a.m. by Morten Madsen (3053149)
Hi,
There is an api to set contributor roles for team. However since it is possible to have a project without a team, how can I set programmatically roles for a contributor at the project level?
Thanks in advance for your help


IProcessAreaWorkingCopy projWc = (IProcessAreaWorkingCopy)getService().getWorkingCopyManager().createPrivateWorkingCopy(proj);
projWc.getTeam().addContributorsSettingRoleCast(new IContributor[] {contributor}, roles);

19 answers



permanent link
EclipseTalk . (32736061) | answered Apr 21 '10, 4:58 p.m.
Thanks for reply -
However you don't set a given role to a contributor at the project level - The code snippet adds a contributor (with a dev license) to a project and retrieve a given project role.
What I need is to be able to add a role at the project level for an existing contributor to the project.

You do get the role for the project via

roles[0] = getProjectsRoleName(project,roleName);

which is fine but you never assign roles to the contributor.

Am I missing something?
Thanks

permanent link
K M (38325051) | answered Apr 22 '10, 7:47 a.m.
in the code here is add the role to the user

workingCopy.addMembers(contributors);
workingCopy.setRoleCast(contributors, roles);
workingCopy.save(MONITOR);

readding an existing user does no affect the user

permanent link
EclipseTalk . (32736061) | answered Apr 22 '10, 8:07 a.m.
Thank you, however note that the setRoleCast is deprecated and therefore shoudln't be used....

workingCopy.setRoleCast(contributors[0], roles);

permanent link
K M (38325051) | answered Apr 22 '10, 8:45 a.m.
public void setRoleCast(IContributorHandle contributor, IRole[] roleCast) {
ITeamWorkingCopy team = getTeam();
if (team != null) {
team.setRoleCast(contributor, roleCast);
}
}

permanent link
K M (38325051) | answered Apr 22 '10, 8:54 a.m.
I retrieve

ProjectAreaWorkingCopy workingCopy = (ProjectAreaWorkingCopy)manager.getWorkingCopy(project);

this class extends to ProcessAreaWorkingCopy
public class ProjectAreaWorkingCopy extends
ProcessAreaWorkingCopy implements IProjectAreaWorkingCopy

In ProcessAreaWorkingCopy setRoleCast retreives the team and
sets the role.

It is not deprecated.

permanent link
EclipseTalk . (32736061) | answered Apr 23 '10, 8:08 a.m.
This is what I was asking at the beginning of this thread...
One can set the role at the team level via

team.setRoleCast(contributor, roleCast);

or

projWc.getTeam().addContributorsSettingRoleCast(new IContributor[] {contributor}, roles);


but it cannot be set at the project level - ie the API project.setRoleCast is deprecated. However one can set role at the project level in the UI.

Thanks

permanent link
Jose Miguel Ordax Cassa (2.4k3126100) | answered Jul 13 '10, 12:58 p.m.
Hi, I am trying to achieve similar scenario and after reading the full
thread I have following questions:

1.- IProcessAreaWorkingCopy is going to be private but
ProjectAreaWorkingCopy won't?

2.- Which method is deprecated? I have compiled the code against Plain
Java Classes from RTC 3.0M6 and nothing has been marked as deprecated.

3.- Why did you say it is not working with Project Areas?
I used the commented code with a Project Area and it worked fine.

URI uri= URI.create("Testing Project Area".replaceAll(" ", "%20"));
IProjectArea pa = (IProjectArea)service.findProcessArea(uri, null, monitor);
pa = (IProjectArea)service.getMutableCopy(pa);
....
....
....
IWorkingCopyManager manager = service.getWorkingCopyManager();
manager.connect(pa);
ProjectAreaWorkingCopy workingCopy =
(ProjectAreaWorkingCopy)manager.getWorkingCopy(pa);
....
....
workingCopy.addMembers(members);
workingCopy.setRoleCast(members, roles);
workingCopy.save(monitor);
manager.disconnect(pa);

Thanks,

Chemi.

permanent link
Jorge Diaz (8664434) | answered Jul 29 '10, 9:09 a.m.
JAZZ DEVELOPER
Hello guys,

do we have any news on this regard?

For Beta1 API still looks the same for these classes, although I guess that the not-supported consideration is still valid, right?

Thanks!

Regards,

Jorge.

permanent link
Rajkumar Rangaswamy (1113) | answered Oct 10 '13, 11:12 a.m.
Hello Guys,

Everything speaks about adding a role to users, how to do we add multiple roles to a single users.

Can anyone help ?

Regards,
Raj

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.