Line 1: |
|
|
+ |
You need to be admin to see everything, you have an option to select a particular role. It only shows active roles. This report has to be used in conjunction with a report template such as the [[HTML Template]].
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
''Meta-Data Script:''
|
|
|
|
|
|
|
+ |
<pre>import com.urbancode.anthill3.domain.reporting.ReportMetaData;
|
|
|
+ |
import com.urbancode.anthill3.domain.reporting.SelectParamMetaData;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.Role;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.RoleFactory;
|
|
|
|
|
|
|
|
|
|
|
+ |
ReportMetaData rmd = new ReportMetaData();
|
|
|
|
|
|
|
+ |
// Add some parameters to the report
|
|
|
+ |
SelectParamMetaData params = new SelectParamMetaData();
|
|
|
|
|
|
|
+ |
Role[] roleArray = RoleFactory.getInstance().restoreAllActive();
|
|
|
+ |
String[] labels = new String[roleArray.length + 1];
|
|
|
+ |
String[] values = new String[roleArray.length + 1];
|
|
|
+ |
for (int i = 0; i < roleArray.length; i++) {
|
|
|
+ |
labels[i] = roleArray[i].getName();
|
|
|
+ |
values[i] = roleArray[i].getId().toString();
|
|
|
+ |
}
|
|
|
+ |
labels[roleArray.length] = "All";
|
|
|
+ |
values[roleArray.length] = "all";
|
|
|
|
|
|
|
+ |
params.setLabels(labels);
|
|
|
+ |
params.setValues(values);
|
|
|
+ |
params.setName("role");
|
|
|
+ |
params.setLabel("Role");
|
|
|
+ |
params.setDescription(
|
|
|
+ |
"Select the role to display. Or select ''All'' to display all roles together.");
|
|
|
|
|
|
|
|
|
|
|
+ |
rmd.addParameter(params);
|
|
|
|
|
|
|
|
|
|
|
+ |
// Configure columns
|
|
|
+ |
rmd.addColumn("Role");
|
|
|
+ |
rmd.addColumn("Users");
|
|
|
|
|
|
|
+ |
return rmd;</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
''Report Script:''
|
|
|
|
|
|
|
+ |
<pre>import com.urbancode.anthill3.domain.reporting.ReportOutput;
|
|
|
+ |
import com.urbancode.anthill3.domain.reporting.ReportRow;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.Role;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.RoleFactory;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.User;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.UserFactory;
|
|
|
|
|
|
|
+ |
Role[] roleArray = null;
|
|
|
+ |
if ("all".equals(role)) {
|
|
|
+ |
roleArray = RoleFactory.getInstance().restoreAll();
|
|
|
+ |
}
|
|
|
+ |
else {
|
|
|
+ |
roleArray = new Role[1];
|
|
|
+ |
roleArray[0] = RoleFactory.getInstance().restore(Long.valueOf(role));
|
|
|
+ |
}
|
|
|
|
|
|
|
|
|
|
|
+ |
ReportOutput output = new ReportOutput(metaData);
|
|
|
+ |
for(Role role : roleArray) {
|
|
|
+ |
if (role != null) {
|
|
|
+ |
ReportRow row = new ReportRow(output, role.getName());
|
|
|
+ |
StringBuffer sb = new StringBuffer();
|
|
|
+ |
User[] userArray = UserFactory.getInstance().restoreAllForRole(role);
|
|
|
+ |
for (User user : userArray) {
|
|
|
+ |
if (user != null) {
|
|
|
+ |
sb.append(user.getName()).append("<br>");
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
+ |
row.setColumnValue("Role", role.getName());
|
|
|
+ |
row.setColumnValue("Users", sb.toString());
|
|
|
+ |
output.addRow(row);
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ |
return output;</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
'''Related Content'''
|
|
|
|
|
|
|
+ |
[[AnthillPro Template Reports]]<br/>
|
|
|
+ |
[[Report Templates]]
|