use of com.axelor.auth.db.repo.UserRepository in project axelor-open-suite by axelor.
the class MailServiceBaseImpl method resolve.
@Override
public Model resolve(String email) {
final UserRepository users = Beans.get(UserRepository.class);
final User user = users.all().filter("self.partner.emailAddress.address = ?1", email).fetchOne();
if (user != null) {
return user;
}
final PartnerRepository partners = Beans.get(PartnerRepository.class);
final Partner partner = partners.all().filter("self.emailAddress.address = ?1", email).fetchOne();
if (partner != null) {
return partner;
}
return super.resolve(email);
}
use of com.axelor.auth.db.repo.UserRepository in project axelor-open-suite by axelor.
the class UserController method comparePfpValidatorCompanySet.
@SuppressWarnings("unchecked")
public void comparePfpValidatorCompanySet(ActionRequest request, ActionResponse response) {
Integer pfpValidatorUserId = (Integer) request.getContext().get("_userId");
LinkedHashMap<String, Object> newPfpValidatorUserMap = (LinkedHashMap<String, Object>) request.getContext().get("newPfpValidatorUser");
if (newPfpValidatorUserMap == null) {
return;
}
UserRepository userRepository = Beans.get(UserRepository.class);
User newPfpValidatorUser = userRepository.find(((Integer) newPfpValidatorUserMap.get("id")).longValue());
User pfpValidatorUser = userRepository.find(pfpValidatorUserId.longValue());
Set<Company> pfpValidatorUserCompanySet = pfpValidatorUser.getCompanySet();
Set<Company> newPfpValidatorUserCompanySet = newPfpValidatorUser.getCompanySet();
if (!pfpValidatorUserCompanySet.equals(newPfpValidatorUserCompanySet)) {
response.setAttr("$pfpValidatorCompanySetLabel", "title", String.format(I18n.get(IExceptionMessage.USER_PFP_VALIDATOR_COMPANY_SET_NOT_EQUAL), newPfpValidatorUser.getName(), pfpValidatorUser.getName()));
response.setAttr("$pfpValidatorCompanySetLabel", "hidden", false);
} else {
response.setAttr("$pfpValidatorCompanySetLabel", "hidden", true);
}
}
use of com.axelor.auth.db.repo.UserRepository in project axelor-open-suite by axelor.
the class UserController method setUserPartner.
public void setUserPartner(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
Partner partner = Beans.get(PartnerRepository.class).find(context.asType(Partner.class).getId());
if (context.get("created_from_user_id") != null && partner != null) {
UserRepository userRepo = Beans.get(UserRepository.class);
User user = userRepo.find(((Integer) context.get("created_from_user_id")).longValue());
Beans.get(UserService.class).setUserPartner(partner, user);
}
} catch (Exception e) {
TraceBackService.trace(response, e, ResponseMessageType.ERROR);
}
}
use of com.axelor.auth.db.repo.UserRepository in project axelor-open-suite by axelor.
the class UserController method changePfpValidator.
@SuppressWarnings("unchecked")
public void changePfpValidator(ActionRequest request, ActionResponse response) {
Integer pfpValidatorUserId = (Integer) request.getContext().get("_userId");
LinkedHashMap<String, Object> newPfpValidatorUserMap = (LinkedHashMap<String, Object>) request.getContext().get("newPfpValidatorUser");
if (newPfpValidatorUserMap == null) {
return;
}
UserRepository userRepository = Beans.get(UserRepository.class);
User newPfpValidatorUser = userRepository.find(((Integer) newPfpValidatorUserMap.get("id")).longValue());
User pfpValidatorUser = userRepository.find(pfpValidatorUserId.longValue());
int updateCount = Beans.get(UserServiceAccountImpl.class).changePfpValidator(pfpValidatorUser, newPfpValidatorUser);
if (updateCount >= 1) {
response.setFlash(I18n.get(IExceptionMessage.USER_PFP_VALIDATOR_UPDATED));
response.setCanClose(true);
} else if (updateCount == 0) {
response.setAlert(String.format(I18n.get(IExceptionMessage.USER_PFP_VALIDATOR_NO_RELATED_ACCOUNTING_SITUATION), pfpValidatorUser.getName()));
}
}
Aggregations