Line 1: |
|
|
+ |
Report of Total Users In the System. This will report on all of the users who are in a role, with the role provided as a dropdown. This dropdown will only contain roles that you can see. 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.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.*;
|
|
|
|
|
|
|
+ |
rmd = new ReportMetaData();
|
|
|
|
|
|
|
+ |
rmd.addColumn("Role");
|
|
|
+ |
rmd.addColumn("Auth Realm");
|
|
|
+ |
rmd.addColumn("User");
|
|
|
+ |
rmd.addColumn("Name");
|
|
|
+ |
rmd.addColumn("Email");
|
|
|
|
|
|
|
+ |
pmd = new SelectParamMetaData();
|
|
|
+ |
pmd.setLabel("Role");
|
|
|
+ |
pmd.setName("roleName");
|
|
|
+ |
pmd.setDescription("Select the role to report the permissions of.");
|
|
|
+ |
pmd.setRequired(true);
|
|
|
|
|
|
|
+ |
roles = RoleFactory.getInstance().restoreAll();
|
|
|
+ |
roleNames = new String[roles.length];
|
|
|
+ |
for (int r=0; r<roles.length; r++) {
|
|
|
+ |
roleNames[r] = roles[r].getName();
|
|
|
+ |
}
|
|
|
+ |
pmd.setValues(roleNames);
|
|
|
|
|
|
|
+ |
rmd.addParameter(pmd);
|
|
|
|
|
|
|
+ |
return rmd;</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
''Report Script:''
|
|
|
|
|
|
|
+ |
<pre>import com.urbancode.anthill3.domain.reporting.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.security.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.userprofile.*;
|
|
|
+ |
import java.util.*;
|
|
|
|
|
|
|
+ |
output = new ReportOutput(metaData);
|
|
|
|
|
|
|
+ |
role = RoleFactory.getInstance().restoreForName(roleName);
|
|
|
+ |
users = UserFactory.getInstance().restoreAllForRole(role);
|
|
|
|
|
|
|
+ |
comparator = new Comparator() {
|
|
|
+ |
public int compare(Object o1, Object o2) {
|
|
|
+ |
u1 = (User) o1;
|
|
|
+ |
u2 = (User) o2;
|
|
|
+ |
int result = u1.getAuthenticationRealm().getName().compareTo(u2.getAuthenticationRealm().getName());
|
|
|
+ |
if (result == 0) {
|
|
|
+ |
result = u1.getName().compareTo(u2.getName());
|
|
|
+ |
}
|
|
|
+ |
return result;
|
|
|
+ |
}
|
|
|
+ |
};
|
|
|
|
|
|
|
+ |
String trimNull(String s) {
|
|
|
+ |
return s == null ? "" : s;
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
Arrays.sort(users, comparator);
|
|
|
|
|
|
|
+ |
for (int u=0; u<users.length; u++) {
|
|
|
+ |
user = users[u];
|
|
|
+ |
row = new ReportRow(output, String.valueOf(user.getId()));
|
|
|
+ |
row.setColumnValue("Role", role.getName());
|
|
|
+ |
row.setColumnValue("Auth Realm", user.getAuthenticationRealm().getName());
|
|
|
+ |
row.setColumnValue("User", user.getName());
|
|
|
+ |
profile = UserProfileFactory.getInstance().restoreForUser(user);
|
|
|
+ |
if (profile != null) {
|
|
|
+ |
row.setColumnValue("Name", trimNull(profile.getFirstName()) + " " + trimNull(profile.getLastName()));
|
|
|
+ |
row.setColumnValue("Email", trimNull(profile.getEmailAddress()));
|
|
|
+ |
}
|
|
|
+ |
else {
|
|
|
+ |
row.setColumnValue("Name", "");
|
|
|
+ |
row.setColumnValue("Email", "");
|
|
|
+ |
}
|
|
|
+ |
output.addRow(row);
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
return output;</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
'''Related Content'''
|
|
|
|
|
|
|
+ |
[[AnthillPro Template Reports]]<br/>
|
|
|
+ |
[[Report Templates]]
|