How to retrieve groups which have roles in a project

Daniel Burke January 18, 2018

How can I retrieve the groups which are allocated roles in a project.

i.e. Administrators = jira-administrators 

1 answer

0 votes
miikhy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2018

Hi Daniel,

If I understand correctly you want an overview of groups usage in Roles overall?

That's not possible OOTB I'd say but with a few database query you might get that if you're familiar with SQL.

There might also be plugins able to help you, I've created one for group management which has a feature of showing group usage in projects but only for groups you belong to, it's called Group Ambassadors, there might be others (just checked but don't have enough time to deeply analyze).

If you need a free, quick solution you might go with SQL. I know Insight Asset Management plugin have an extension to graphically represent your instance configuration, that might be available there as well.

A lot of ideas, please let us know if any worked for you!

Cheers

Daniel Burke January 18, 2018

Thanks Micky, yes you're correct, I should have mentioned I was scripting in Groovy to try and retrieve this. 

It appears that my script currently does get "groups" but doesn't label that to be the case, it will show the content of users in each group, which do have a role, but not the group name. 

Thanks for the tip!

miikhy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2018

In my plugin the java classes I,m using are mostly ProjectRoleManager and ProjectManager:

ProjectRoleManager prm = ComponentAccessor.getComponent(ProjectRoleManager.class);
ProjectManager pm = ComponentAccessor.getProjectManager();
for(Long pid : prm.getProjectIdsContainingRoleActorByNameAndType(group,ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE)) {
...
}

The pid long var will give all project ids where the "group" parameter (A String containing a group name) have a role. 

You can then use ProjectRole class to identify the project role (in my case and it's not ideal I use:

List<ProjectRole> rids = new ArrayList(prm.getProjectRoles());
for(ProjectRole pr : rids) {
if(!prm.roleActorOfTypeExistsForProjects(pid,pr,ProjectRoleActor.GROUP_ROLE_ACTOR_TYPE,group).isEmpty()) {

}
}

 Hope this will help :)

Suggest an answer

Log in or Sign up to answer