Search in sources :

Example 46 with Context

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);
    }
}
Also used : Context(com.axelor.rpc.Context)

Example 47 with Context

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));
    }
}
Also used : Context(com.axelor.rpc.Context) HashSet(java.util.HashSet)

Example 48 with Context

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);
}
Also used : Context(com.axelor.rpc.Context) HashMap(java.util.HashMap) MoveLine(com.axelor.apps.account.db.MoveLine)

Example 49 with Context

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);
    }
}
Also used : Context(com.axelor.rpc.Context) Print(com.axelor.apps.base.db.Print) PrintTemplate(com.axelor.apps.base.db.PrintTemplate) PrintTemplateService(com.axelor.apps.base.service.PrintTemplateService) Map(java.util.Map) AxelorException(com.axelor.exception.AxelorException)

Example 50 with Context

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);
}
Also used : Context(com.axelor.rpc.Context) AxelorException(com.axelor.exception.AxelorException) MetaModel(com.axelor.meta.db.MetaModel) MetaModelRepository(com.axelor.meta.db.repo.MetaModelRepository) PrintTemplateLineTest(com.axelor.apps.base.db.PrintTemplateLineTest) IOException(java.io.IOException) PrintTemplateLineService(com.axelor.apps.base.service.PrintTemplateLineService)

Aggregations

Context (com.axelor.rpc.Context)149 AxelorException (com.axelor.exception.AxelorException)52 BigDecimal (java.math.BigDecimal)37 Map (java.util.Map)37 HashMap (java.util.HashMap)26 ArrayList (java.util.ArrayList)23 SaleOrder (com.axelor.apps.sale.db.SaleOrder)19 List (java.util.List)18 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)17 Invoice (com.axelor.apps.account.db.Invoice)16 LinkedHashMap (java.util.LinkedHashMap)15 Product (com.axelor.apps.base.db.Product)14 Model (com.axelor.db.Model)13 StockMove (com.axelor.apps.stock.db.StockMove)12 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)12 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)11 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)11 LocalDate (java.time.LocalDate)11 Beans (com.axelor.inject.Beans)10 ActionRequest (com.axelor.rpc.ActionRequest)10