use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class UserController method validate.
public void validate(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
User user = request.getContext().asType(User.class);
Map<String, String> errors = ModelTool.getUniqueErrors(user, UNIQUE_MESSAGES);
if (!errors.isEmpty()) {
response.setErrors(errors);
return;
}
UserService userService = Beans.get(UserService.class);
user = userService.changeUserPassword(user, context);
response.setValue("transientPassword", user.getTransientPassword());
} catch (ValidationException e) {
response.setError(e.getMessage());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context 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.rpc.Context in project axelor-open-suite by axelor.
the class DuplicateObjectsController method addOriginal.
public void addOriginal(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
List<Map<String, Object>> duplicateObj = (List<Map<String, Object>>) context.get("duplicateObjects");
Object originalObj = null;
Object original = "";
boolean flag = false;
for (Map map : duplicateObj) {
if ((boolean) map.get("selected")) {
originalObj = context.get("originalObject");
response.setAttr("$originalObject", "value", map);
original = map;
flag = true;
}
}
if (!flag) {
response.setAlert(I18n.get(IExceptionMessage.GENERAL_11));
}
duplicateObj.remove(original);
if (originalObj != null) {
duplicateObj.add((Map<String, Object>) originalObj);
}
response.setAttr("$duplicateObjects", "value", duplicateObj);
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class DuplicateObjectsController method extractModel.
private Class<? extends Model> extractModel(ActionRequest request, Set<String> fields) {
Context context = request.getContext();
String model = (String) context.get("_contextModel");
if (model == null) {
model = request.getModel();
String duplicateFinderFields = (String) context.get("_duplicateFinderFields");
if (duplicateFinderFields != null) {
fields.addAll(Arrays.asList(duplicateFinderFields.split(";")));
}
} else {
if (context.get("fieldsSet") != null) {
List<HashMap<String, Object>> fieldsSet = (List<HashMap<String, Object>>) context.get("fieldsSet");
for (HashMap<String, Object> field : fieldsSet) {
fields.add((String) field.get("name"));
}
}
}
return (Class<? extends Model>) JPA.model(model);
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class FileTabController method updateFields.
public void updateFields(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
Map<String, Object> map = context.getParent();
if (map == null || (boolean) map.get("isConfigInFile") == true) {
return;
}
FileTab fileTab = context.asType(FileTab.class);
Beans.get(FileTabService.class).updateFields(fileTab);
response.setValue("fileFieldList", fileTab.getFileFieldList());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations