public String getOrderConfirmationWebPath(final OrderCustomer order) {
   final String documentWebRootPath = buildWebPathSegment(order);
   final String fullPath =
       documentWebRootPath
           + "/"
           + order.getPrefixHashFolder()
           + "/"
           + OrderDocumentType.ORDER_CONFIRMATION.getPropertyKey()
           + "-"
           + order.getOrderNum()
           + ".pdf";
   return fullPath;
 }
 public String getInvoiceWebPath(final OrderCustomer order) {
   final String documentWebRootPath = buildWebPathSegment(order);
   final String fullPath =
       documentWebRootPath
           + "/"
           + order.getPrefixHashFolder()
           + "/"
           + OrderDocumentType.INVOICE.getPropertyKey()
           + "-"
           + order.getOrderNum()
           + ".pdf";
   return fullPath;
 }
 public String getOrderConfirmationFilePath(final OrderCustomer order) {
   final String filePathPrefix = buildFilePathSegment(order);
   final String fullFilePath =
       filePathPrefix
           + OrderDocumentType.ORDER_CONFIRMATION.getPropertyKey()
           + "-"
           + order.getOrderNum()
           + ".pdf";
   return fullFilePath;
 }
 public String getInvoiceFilePath(final OrderCustomer order) {
   final String filePathPrefix = buildFilePathSegment(order);
   final String fullFilePath =
       filePathPrefix
           + OrderDocumentType.INVOICE.getPropertyKey()
           + "-"
           + order.getOrderNum()
           + ".pdf";
   return fullFilePath;
 }
 private String buildFilePathSegment(final OrderCustomer order) {
   final EngineSetting documentFileRootPathEngineSetting =
       engineSettingService.getDocumentFileRootPath();
   String documentFileRootPath = documentFileRootPathEngineSetting.getDefaultValue();
   String filePathSegment = documentFileRootPath + "/" + order.getPrefixHashFolder() + "/";
   File file = new File(filePathSegment);
   if (!file.exists()) {
     file.mkdirs();
   }
   return filePathSegment;
 }
  public void generateOrderConfirmation(final OrderCustomer order) {
    try {
      final MarketArea marketArea = marketService.getMarketAreaById(order.getMarketAreaId());
      final Localization localization =
          localizationService.getLocalizationById(order.getLocalizationId());
      final Locale locale = localization.getLocale();

      // WE SET TO NULL USELESS DATA - BETTER WAY SHOULD BE TO USE A SPECIFIC DOZER RULE
      for (Iterator<OrderItem> iterator = order.getOrderItems().iterator(); iterator.hasNext(); ) {
        OrderItem orderItem = (OrderItem) iterator.next();
        orderItem.getProductSku().setPrices(null);
        orderItem.getProductSku().setStocks(null);
        orderItem.getProductSku().setProductMarketing(null);
        orderItem.getProductSku().setRetailers(null);
      }

      final OrderCustomerPojo orderCustomerPojo = orderPojoService.handleOrderMapping(order);

      final String jrxml = getOrderConfirmationTemplateByMarketArea(marketArea);
      File fileJrxml = new File(jrxml);
      final String resourcePath = jrxml.replace(fileJrxml.getName(), "");
      final JasperReport jasperReport = JasperCompileManager.compileReport(jrxml);

      Map<String, Object> parameters = new HashMap<String, Object>();
      parameters.put("RESOURCE_PATH", resourcePath);
      parameters.put("RECORD_DELIMITER", "\r\n");
      parameters.put("order", orderCustomerPojo);
      Object[] orderInformationsParams = {orderCustomerPojo.getOrderNum()};
      parameters.put(
          "orderInformations",
          coreMessageSource.getDocumentMessage(
              ScopeDocumentMessage.ORDER_CONFIRMATION,
              "header_order_informations",
              orderInformationsParams,
              locale));
      parameters.put("date", orderCustomerPojo.getDateUpdate().toString());
      parameters.put("billingAddress", orderCustomerPojo.getBillingAddress());
      parameters.put("shippingAddress", orderCustomerPojo.getShippingAddress());

      Map<String, String> wording =
          coreMessageSource.loadWording(I18nKeyValueUniverse.DOCUMENT.getPropertyKey(), locale);
      parameters.put("wording", wording);

      List<OrderItem> orderItems = new ArrayList<OrderItem>();
      Set<OrderShipment> orderShipments = orderCustomerPojo.getOrderShipments();
      for (Iterator<OrderShipment> iterator = orderShipments.iterator(); iterator.hasNext(); ) {
        OrderShipment orderShipment = (OrderShipment) iterator.next();
        orderItems.addAll(orderShipment.getOrderItems());
      }

      // TODO : denis : one page/table by OrderShipment

      JRDataSource datasource = new JRBeanCollectionDataSource(orderItems, true);

      final JasperPrint jasperPrint =
          JasperFillManager.fillReport(jasperReport, parameters, datasource);

      String fullFilePath = getOrderConfirmationFilePath(order);
      JasperExportManager.exportReportToPdfFile(jasperPrint, fullFilePath);

    } catch (Exception e) {
      logger.error("", e);
    }
  }
 public String buildOrderConfirmationFileName(final OrderCustomer order) {
   return OrderDocumentType.ORDER_CONFIRMATION.getPropertyKey()
       + "-"
       + order.getOrderNum()
       + ".pdf";
 }
 public String buildInvoiceFileName(final OrderCustomer order) {
   return OrderDocumentType.INVOICE.getPropertyKey() + "-" + order.getOrderNum() + ".pdf";
 }