setRole(r);
} else if (getUser().getDefaultRole() != null && getUser().getDefaultRole().isActive()) {
setRole(getUser().getDefaultRole());
} else {
final UserRoles ur = getOne(UserRoles.class, "select ur from " + UserRoles.class.getName()
+ " ur where " + " ur." + UserRoles.PROPERTY_USERCONTACT + "." + User.PROPERTY_ID
+ "='" + u.getId() + "' and ur." + UserRoles.PROPERTY_ACTIVE + "='Y' and ur."
+ UserRoles.PROPERTY_ROLE + "." + Role.PROPERTY_ACTIVE + "='Y' order by ur."
+ UserRoles.PROPERTY_ROLE + "." + Role.PROPERTY_ID + " asc", false);
if (ur == null) {
throw new OBSecurityException(
"Your user is not assigned to a Role and it is required to login into Openbravo. Ask the Security Administrator");
}
Hibernate.initialize(ur.getRole());
setRole(ur.getRole());
}
Check.isNotNull(getRole(), "Role may not be null");
if (orgId != null) {