Search in sources :

Example 1 with TraceBackService

use of com.axelor.exception.service.TraceBackService in project axelor-open-suite by axelor.

the class StockMoveController method plan.

public void plan(ActionRequest request, ActionResponse response) {
    try {
        StockMove stockMove = request.getContext().asType(StockMove.class);
        // we have to inject TraceBackService to use non static methods
        TraceBackService traceBackService = Beans.get(TraceBackService.class);
        long tracebackCount = traceBackService.countMessageTraceBack(stockMove);
        Beans.get(StockMoveService.class).plan(Beans.get(StockMoveRepository.class).find(stockMove.getId()));
        response.setReload(true);
        if (traceBackService.countMessageTraceBack(stockMove) > tracebackCount) {
            traceBackService.findLastMessageTraceBack(stockMove).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TraceBackService(com.axelor.exception.service.TraceBackService) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveService(com.axelor.apps.stock.service.StockMoveService) AxelorException(com.axelor.exception.AxelorException)

Example 2 with TraceBackService

use of com.axelor.exception.service.TraceBackService in project axelor-open-suite by axelor.

the class ManufOrderController method partialFinish.

public void partialFinish(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        // we have to inject TraceBackService to use non static methods
        TraceBackService traceBackService = Beans.get(TraceBackService.class);
        long tracebackCount = traceBackService.countMessageTraceBack(manufOrder);
        if (!Beans.get(ManufOrderWorkflowService.class).partialFinish(manufOrder)) {
            response.setNotify(I18n.get(IExceptionMessage.MANUF_ORDER_EMAIL_NOT_SENT));
        } else if (traceBackService.countMessageTraceBack(manufOrder) > tracebackCount) {
            traceBackService.findLastMessageTraceBack(manufOrder).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
        }
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : IExceptionMessage(com.axelor.apps.production.exceptions.IExceptionMessage) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) BirtException(org.eclipse.birt.core.exception.BirtException) CostSheetRepository(com.axelor.apps.production.db.repo.CostSheetRepository) ProductRepository(com.axelor.apps.base.db.repo.ProductRepository) ActionView(com.axelor.meta.schema.actions.ActionView) ProdProductRepository(com.axelor.apps.production.db.repo.ProdProductRepository) LoggerFactory(org.slf4j.LoggerFactory) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException) ActionResponse(com.axelor.rpc.ActionResponse) I18n(com.axelor.i18n.I18n) ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) ActionRequest(com.axelor.rpc.ActionRequest) ProdProductProductionRepository(com.axelor.apps.production.service.ProdProductProductionRepository) ProdProduct(com.axelor.apps.production.db.ProdProduct) StringTool(com.axelor.apps.tool.StringTool) ManufOrderPrintService(com.axelor.apps.production.service.manuforder.ManufOrderPrintService) Logger(org.slf4j.Logger) TraceBackRepository(com.axelor.exception.db.repo.TraceBackRepository) MethodHandles(java.lang.invoke.MethodHandles) CostSheet(com.axelor.apps.production.db.CostSheet) TraceBackService(com.axelor.exception.service.TraceBackService) IOException(java.io.IOException) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) Collectors(java.util.stream.Collectors) ManufOrderWorkflowService(com.axelor.apps.production.service.manuforder.ManufOrderWorkflowService) List(java.util.List) IReport(com.axelor.apps.production.report.IReport) CostSheetService(com.axelor.apps.production.service.costsheet.CostSheetService) ReportSettings(com.axelor.apps.report.engine.ReportSettings) Beans(com.axelor.inject.Beans) Product(com.axelor.apps.base.db.Product) ManufOrder(com.axelor.apps.production.db.ManufOrder) ReportFactory(com.axelor.apps.ReportFactory) LocalDate(java.time.LocalDate) ObjectUtils(com.axelor.common.ObjectUtils) ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) Context(com.axelor.rpc.Context) ManufOrderStockMoveService(com.axelor.apps.production.service.manuforder.ManufOrderStockMoveService) Singleton(com.google.inject.Singleton) TraceBackService(com.axelor.exception.service.TraceBackService) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 3 with TraceBackService

use of com.axelor.exception.service.TraceBackService in project axelor-open-suite by axelor.

the class InvoiceController method validateAndVentilate.

/**
 * Called by the validate button, if the ventilation is skipped in invoice config
 *
 * @param request
 * @param response
 */
public void validateAndVentilate(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    try {
        // we have to inject TraceBackService to use non static methods
        TraceBackService traceBackService = Beans.get(TraceBackService.class);
        long tracebackCount = traceBackService.countMessageTraceBack(invoice);
        Beans.get(InvoiceService.class).validateAndVentilate(invoice);
        response.setReload(true);
        if (traceBackService.countMessageTraceBack(invoice) > tracebackCount) {
            traceBackService.findLastMessageTraceBack(invoice).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TraceBackService(com.axelor.exception.service.TraceBackService) Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) AxelorException(com.axelor.exception.AxelorException)

Example 4 with TraceBackService

use of com.axelor.exception.service.TraceBackService in project axelor-open-suite by axelor.

the class InvoiceController method validate.

/**
 * Fonction appeler par le bouton valider
 *
 * @param request
 * @param response
 * @return
 */
public void validate(ActionRequest request, ActionResponse response) throws AxelorException {
    Invoice invoice = request.getContext().asType(Invoice.class);
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    try {
        // we have to inject TraceBackService to use non static methods
        TraceBackService traceBackService = Beans.get(TraceBackService.class);
        long tracebackCount = traceBackService.countMessageTraceBack(invoice);
        Beans.get(InvoiceService.class).validate(invoice);
        response.setReload(true);
        if (traceBackService.countMessageTraceBack(invoice) > tracebackCount) {
            traceBackService.findLastMessageTraceBack(invoice).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TraceBackService(com.axelor.exception.service.TraceBackService) Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) AxelorException(com.axelor.exception.AxelorException)

Example 5 with TraceBackService

use of com.axelor.exception.service.TraceBackService in project axelor-open-suite by axelor.

the class InvoiceController method ventilate.

/**
 * Called from invoice form view, on clicking ventilate button. Call {@link
 * InvoiceService#ventilate(Invoice)}.
 *
 * @param request
 * @param response
 */
public void ventilate(ActionRequest request, ActionResponse response) {
    Invoice invoice = request.getContext().asType(Invoice.class);
    invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
    try {
        // we have to inject TraceBackService to use non static methods
        TraceBackService traceBackService = Beans.get(TraceBackService.class);
        long tracebackCount = traceBackService.countMessageTraceBack(invoice);
        Beans.get(InvoiceService.class).ventilate(invoice);
        response.setReload(true);
        if (traceBackService.countMessageTraceBack(invoice) > tracebackCount) {
            traceBackService.findLastMessageTraceBack(invoice).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TraceBackService(com.axelor.exception.service.TraceBackService) Invoice(com.axelor.apps.account.db.Invoice) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

AxelorException (com.axelor.exception.AxelorException)8 TraceBackService (com.axelor.exception.service.TraceBackService)8 Invoice (com.axelor.apps.account.db.Invoice)4 InvoiceService (com.axelor.apps.account.service.invoice.InvoiceService)3 StockMove (com.axelor.apps.stock.db.StockMove)3 TraceBackRepository (com.axelor.exception.db.repo.TraceBackRepository)3 I18n (com.axelor.i18n.I18n)3 Beans (com.axelor.inject.Beans)3 ActionView (com.axelor.meta.schema.actions.ActionView)3 ActionRequest (com.axelor.rpc.ActionRequest)3 ActionResponse (com.axelor.rpc.ActionResponse)3 Context (com.axelor.rpc.Context)3 Singleton (com.google.inject.Singleton)3 BigDecimal (java.math.BigDecimal)3 LocalDate (java.time.LocalDate)3 ReportFactory (com.axelor.apps.ReportFactory)2 Product (com.axelor.apps.base.db.Product)2 ProductRepository (com.axelor.apps.base.db.repo.ProductRepository)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 CostSheet (com.axelor.apps.production.db.CostSheet)2