}
@SuppressWarnings("unchecked")
public Role copyValues(Record from) {
Role to = new Role();
to.setId(from.getAttributeAsInt(Field.ID));
to.setName(from.getAttributeAsString(Field.NAME));
to.setDescription(from.getAttributeAsString(Field.DESCRIPTION));
Record[] permissionRecords = from.getAttributeAsRecordArray(Field.PERMISSIONS);
Set<Permission> permissions = toPermissionSet(permissionRecords);
to.setPermissions(permissions);
Record[] resourceGroupRecords = from.getAttributeAsRecordArray(Field.RESOURCE_GROUPS);
Set<ResourceGroup> resourceGroups = ResourceGroupsDataSource.getInstance().buildDataObjects(
resourceGroupRecords);
to.setResourceGroups(resourceGroups);
Record[] subjectRecords = from.getAttributeAsRecordArray(Field.SUBJECTS);
Set<Subject> subjects = UsersDataSource.getInstance().buildDataObjects(subjectRecords);
to.setSubjects(subjects);
Record[] ldapGroupRecords = from.getAttributeAsRecordArray(Field.LDAP_GROUPS);
Set<LdapGroup> ldapGroups = new RoleLdapGroupSelector.LdapGroupsDataSource().buildDataObjects(ldapGroupRecords);
to.setLdapGroups(ldapGroups);
Record[] bundleGroupRecords = from.getAttributeAsRecordArray(Field.BUNDLE_GROUPS);
Set<BundleGroup> bundleGroups = BundleGroupsDataSource.getInstance().buildDataObjects(bundleGroupRecords);
to.setBundleGroups(bundleGroups);
return to;
}