use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class GlobalTrackingLogController method showGlobalTrackingLogsInWizard.
public void showGlobalTrackingLogsInWizard(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
boolean showLines = context.get("metaModel") != null && context.get("metaField") != null;
response.setAttr("globalTrackingLogDashlet", "hidden", showLines);
response.setAttr("globalTrackingLogLineDashlet", "hidden", !showLines);
response.setAttr(showLines ? "globalTrackingLogLineDashlet" : "globalTrackingLogDashlet", "refresh", true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class DuplicateObjectsController method showDuplicate.
/**
* Find duplicated records by using DuplicateObjectsService and open it.
*
* @param request
* @param response
* @throws AxelorException
*/
public void showDuplicate(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
Set<String> fields = new HashSet<String>();
Class<? extends Model> modelClass = extractModel(request, fields);
LOG.debug("Duplicate record model: {}", modelClass.getName());
if (fields.size() > 0) {
String filter = findDuplicated(request, fields, modelClass);
if (filter == null) {
response.setFlash(I18n.get(IExceptionMessage.GENERAL_1));
} else {
response.setView(ActionView.define(I18n.get(IExceptionMessage.GENERAL_2)).model(modelClass.getName()).add("grid").add("form").domain(filter).context("_domain", filter).map());
if (context.get("_contextModel") != null) {
response.setCanClose(true);
}
}
} else if (context.get("_contextModel") == null) {
response.setFlash(I18n.get(IExceptionMessage.GENERAL_10));
} else {
response.setFlash(I18n.get(IExceptionMessage.GENERAL_3));
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class AccountClearanceController method showAccountClearanceMoveLines.
public void showAccountClearanceMoveLines(ActionRequest request, ActionResponse response) {
Map<String, Object> viewMap = new HashMap<String, Object>();
Context context = request.getContext();
viewMap.put("title", I18n.get(IExceptionMessage.ACCOUNT_CLEARANCE_7));
viewMap.put("resource", MoveLine.class.getName());
viewMap.put("domain", "self.accountClearance.id = " + context.get("id"));
response.setView(viewMap);
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class PrintTemplateController method generatePrint.
public void generatePrint(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
Map templateContext = (Map) context.get("template");
PrintTemplate printTemplate = null;
if (templateContext != null) {
printTemplate = Beans.get(PrintTemplateRepository.class).find(Long.parseLong(templateContext.get("id").toString()));
}
Long objectId = Long.parseLong(context.get("_objectId").toString());
try {
response.setCanClose(true);
Print print = Beans.get(PrintTemplateService.class).generatePrint(objectId, printTemplate);
response.setView(getPrintView(print));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.rpc.Context in project axelor-open-suite by axelor.
the class PrintTemplateLineController method checkTemplateLineExpression.
public void checkTemplateLineExpression(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
PrintTemplateLineTest printTemplateLineTest = context.asType(PrintTemplateLineTest.class);
printTemplateLineTest = Beans.get(PrintTemplateLineTestRepository.class).find(printTemplateLineTest.getId());
MetaModel metaModel = Beans.get(MetaModelRepository.class).all().filter("self.fullName = ?", printTemplateLineTest.getReference()).fetchOne();
try {
Beans.get(PrintTemplateLineService.class).checkExpression(Long.valueOf(printTemplateLineTest.getReferenceId().toString()), metaModel, printTemplateLineTest.getPrintTemplateLine());
} catch (NumberFormatException | ClassNotFoundException | AxelorException | IOException e) {
TraceBackService.trace(response, e);
}
response.setReload(true);
}
Aggregations