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;
}
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);
}
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);
}
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);
}
}
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;
}
Aggregations