setCurrentOrganization(o);
} else if (getUser().getDefaultOrganization() != null
&& getUser().getDefaultOrganization().isActive()) {
setCurrentOrganization(getUser().getDefaultOrganization());
} else {
final RoleOrganization roa = getOne(RoleOrganization.class, "select roa from "
+ RoleOrganization.class.getName() + " roa where roa." + RoleOrganization.PROPERTY_ROLE
+ "." + Organization.PROPERTY_ID + "='" + getRole().getId() + "' and roa."
+ RoleOrganization.PROPERTY_ACTIVE + "='Y' and roa."
+ RoleOrganization.PROPERTY_ORGANIZATION + "." + Organization.PROPERTY_ACTIVE
+ "='Y' order by roa." + RoleOrganization.PROPERTY_ORGANIZATION + "."
+ Organization.PROPERTY_ID + " desc", false);
Hibernate.initialize(roa.getOrganization());
setCurrentOrganization(roa.getOrganization());
// if no client id then use the client of the role
if (localClientId == null) {
localClientId = roa.getClient().getId();
}
}
Check.isNotNull(getCurrentOrganization(), "Organization may not be null");