Search in sources :

Example 6 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class MapService method getJSON.

private JSONObject getJSON(Response response) throws AxelorException, JSONException {
    LOG.debug("Gmap connection status code: {}, message: {}", response.getStatusCode(), response.getStatusMessage());
    AppBase appBase = appBaseService.getAppBase();
    if (response.getStatusCode() != HttpStatus.SC_OK) {
        String msg = String.format("%d: %s", response.getStatusCode(), response.getStatusMessage());
        throw new AxelorException(appBase, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, msg);
    }
    JSONObject json = new JSONObject(response.getContentAsString());
    String status = json.getString("status");
    if (!"OK".equalsIgnoreCase(status)) {
        String msg = json.has("error_message") ? String.format("%s: %s", status, json.getString("error_message")) : status;
        throw new AxelorException(appBase, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, msg);
    }
    return json;
}
Also used : AxelorException(com.axelor.exception.AxelorException) JSONObject(wslite.json.JSONObject) AppBase(com.axelor.apps.base.db.AppBase)

Example 7 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class StockMovePrintServiceImpl method prepareReportSettings.

@Override
public ReportSettings prepareReportSettings(StockMove stockMove, String format) throws AxelorException {
    if (stockMove.getPrintingSettings() == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, String.format(I18n.get(IExceptionMessage.STOCK_MOVES_MISSING_PRINTING_SETTINGS), stockMove.getStockMoveSeq()), stockMove);
    }
    String locale = ReportSettings.getPrintingLocale(stockMove.getPartner());
    String title = getFileName(stockMove);
    AppBase appBase = appBaseService.getAppBase();
    ReportSettings reportSetting = ReportFactory.createReport(IReport.STOCK_MOVE, title + " - ${date}");
    return reportSetting.addParam("StockMoveId", stockMove.getId()).addParam("Timezone", stockMove.getCompany() != null ? stockMove.getCompany().getTimezone() : null).addParam("Locale", locale).addParam("GroupProducts", appBase.getIsRegroupProductsOnPrintings() && stockMove.getGroupProductsOnPrintings()).addParam("GroupProductTypes", appBase.getRegroupProductsTypeSelect()).addParam("GroupProductLevel", appBase.getRegroupProductsLevelSelect()).addParam("GroupProductProductTitle", appBase.getRegroupProductsLabelProducts()).addParam("GroupProductServiceTitle", appBase.getRegroupProductsLabelServices()).addParam("HeaderHeight", stockMove.getPrintingSettings().getPdfHeaderHeight()).addParam("FooterHeight", stockMove.getPrintingSettings().getPdfFooterHeight()).addFormat(format);
}
Also used : AxelorException(com.axelor.exception.AxelorException) ReportSettings(com.axelor.apps.report.engine.ReportSettings) AppBase(com.axelor.apps.base.db.AppBase)

Example 8 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class AddressController method check.

public void check(ActionRequest request, ActionResponse response) {
    AppBase appBase = request.getContext().asType(AppBase.class);
    LOG.debug("validate g = {}", appBase);
    LOG.debug("validate g.qasWsdlUrl = {}", appBase.getQasWsdlUrl());
    String msg = Beans.get(AddressService.class).check(appBase.getQasWsdlUrl()) ? appBase.getQasWsdlUrl() + " " + I18n.get(IExceptionMessage.ADDRESS_1) : I18n.get(IExceptionMessage.ADDRESS_2);
    response.setFlash(msg);
}
Also used : AppBase(com.axelor.apps.base.db.AppBase)

Example 9 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class AppBaseController method checkMapApi.

public void checkMapApi(ActionRequest request, ActionResponse response) {
    try {
        AppBase appBase = request.getContext().asType(AppBase.class);
        Integer apiType = appBase.getMapApiSelect();
        if (apiType == 1) {
            Beans.get(MapService.class).testGMapService();
            response.setFlash(IExceptionMessage.GENERAL_6);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : MapService(com.axelor.apps.base.service.MapService) AxelorException(com.axelor.exception.AxelorException) AppBase(com.axelor.apps.base.db.AppBase)

Example 10 with AppBase

use of com.axelor.apps.base.db.AppBase in project axelor-open-suite by axelor.

the class KilometricService method getDistanceUsingOSM.

protected BigDecimal getDistanceUsingOSM(String fromCity, String toCity) throws JSONException, AxelorException, URISyntaxException, IOException {
    AppBase appBase = appBaseService.getAppBase();
    BigDecimal distance = BigDecimal.ZERO;
    if (appBase.getOsmRoutingServiceApiSelect() == AppBaseRepository.ROUTING_API_YOURS) {
        distance = this.getDistanceUsingYOURSApi(fromCity, toCity);
    } else if (appBase.getOsmRoutingServiceApiSelect() == AppBaseRepository.ROUTING_API_OSRM) {
        distance = this.getDistanceUsingOSRMApi(fromCity, toCity);
    }
    return distance;
}
Also used : BigDecimal(java.math.BigDecimal) AppBase(com.axelor.apps.base.db.AppBase)

Aggregations

AppBase (com.axelor.apps.base.db.AppBase)18 AxelorException (com.axelor.exception.AxelorException)8 BigDecimal (java.math.BigDecimal)5 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)4 User (com.axelor.auth.db.User)3 JSONException (wslite.json.JSONException)3 Company (com.axelor.apps.base.db.Company)2 CurrencyConversionLine (com.axelor.apps.base.db.CurrencyConversionLine)2 Lead (com.axelor.apps.crm.db.Lead)2 ReportSettings (com.axelor.apps.report.engine.ReportSettings)2 Transactional (com.google.inject.persist.Transactional)2 MalformedURLException (java.net.MalformedURLException)2 LocalDate (java.time.LocalDate)2 AppLeave (com.axelor.apps.base.db.AppLeave)1 EventsPlanning (com.axelor.apps.base.db.EventsPlanning)1 CompanyRepository (com.axelor.apps.base.db.repo.CompanyRepository)1 MapService (com.axelor.apps.base.service.MapService)1 UserService (com.axelor.apps.base.service.user.UserService)1 Employee (com.axelor.apps.hr.db.Employee)1 HRConfig (com.axelor.apps.hr.db.HRConfig)1