return copyValues(sourceRole, true);
}
@Override
public ListGridRecord copyValues(Role sourceRole, boolean cascade) {
ListGridRecord targetRecord = new ListGridRecord();
targetRecord.setAttribute(Field.ID, sourceRole.getId());
targetRecord.setAttribute(Field.NAME, sourceRole.getName());
targetRecord.setAttribute(Field.DESCRIPTION, sourceRole.getDescription());
Set<Permission> permissions = sourceRole.getPermissions();
ListGridRecord[] permissionRecords = toRecordArray(permissions);
targetRecord.setAttribute(Field.PERMISSIONS, permissionRecords);
if (cascade) {
Set<ResourceGroup> resourceGroups = sourceRole.getResourceGroups();
ListGridRecord[] resourceGroupRecords = ResourceGroupsDataSource.getInstance().buildRecords(resourceGroups,
false);
targetRecord.setAttribute(Field.RESOURCE_GROUPS, resourceGroupRecords);
Set<Subject> subjects = sourceRole.getSubjects();
ListGridRecord[] subjectRecords = UsersDataSource.getInstance().buildRecords(subjects, false);
targetRecord.setAttribute(Field.SUBJECTS, subjectRecords);
Set<LdapGroup> ldapGroups = sourceRole.getLdapGroups();
ListGridRecord[] ldapGroupRecords = new RoleLdapGroupSelector.LdapGroupsDataSource()
.buildRecords(ldapGroups);
targetRecord.setAttribute(Field.LDAP_GROUPS, ldapGroupRecords);
Set<BundleGroup> bundleGroups = sourceRole.getBundleGroups();
ListGridRecord[] bundleGroupRecords = BundleGroupsDataSource.getInstance()
.buildRecords(bundleGroups, false);
targetRecord.setAttribute(Field.BUNDLE_GROUPS, bundleGroupRecords);
}
return targetRecord;
}