@RequestMapping(value = BoUrls.PRODUCT_MARKETING_EDIT_URL, method = RequestMethod.GET)
  public ModelAndView productMarketingEdit(
      final HttpServletRequest request, final HttpServletResponse response, ModelMap modelMap)
      throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.PRODUCT_MARKETING_EDIT.getVelocityPage());

    final MarketArea currentMarketArea = requestUtil.getCurrentMarketArea(request);
    final Retailer currentRetailer = requestUtil.getCurrentRetailer(request);

    final String productMarketingCode =
        request.getParameter(RequestConstants.REQUEST_PARAMETER_PRODUCT_MARKETING_CODE);
    final ProductMarketing productMarketing =
        productMarketingService.getProductMarketingByCode(
            currentMarketArea.getId(), currentRetailer.getId(), productMarketingCode);

    // "business.product.marketing.edit";

    initProductMarketingModelAndView(request, modelAndView, productMarketing);
    modelAndView.addObject(
        "productMarketingForm", formFactory.buildProductMarketingForm(request, productMarketing));
    initSpecificSeo(request, modelAndView, "", productMarketing.getBusinessName());

    //		modelAndView.addObject("productMarketingDetails",
    // viewBeanFactory.buildUserEditViewBean(request, currentLocalization, user));

    return modelAndView;
  }
  protected PagedListHolder<DeliveryMethodViewBean> initList(
      final HttpServletRequest request, String sessionKey, final RequestData requestData)
      throws Exception {
    final MarketArea marketArea = requestData.getMarketArea();

    PagedListHolder<DeliveryMethodViewBean> deliveryMethodViewBeanPagedListHolder =
        new PagedListHolder<DeliveryMethodViewBean>();

    final List<DeliveryMethodViewBean> deliveryMethodViewBeans =
        new ArrayList<DeliveryMethodViewBean>();

    final List<DeliveryMethod> deliveryMethods =
        deliveryMethodService.findDeliveryMethodsByMarketAreaId(marketArea.getId());
    for (Iterator<DeliveryMethod> iterator = deliveryMethods.iterator(); iterator.hasNext(); ) {
      DeliveryMethod deliveryMethod = (DeliveryMethod) iterator.next();
      deliveryMethodViewBeans.add(
          backofficeViewBeanFactory.buildViewBeanDeliveryMethod(
              requestUtil.getRequestData(request), deliveryMethod));
    }
    deliveryMethodViewBeanPagedListHolder =
        new PagedListHolder<DeliveryMethodViewBean>(deliveryMethodViewBeans);
    deliveryMethodViewBeanPagedListHolder.setPageSize(Constants.PAGE_SIZE);
    request.getSession().setAttribute(sessionKey, deliveryMethodViewBeanPagedListHolder);

    return deliveryMethodViewBeanPagedListHolder;
  }
 /* (non-Javadoc)
  * @see fr.hoteia.qalingo.core.solr.service.ProductSkuSolrService#addOrUpdateProductSku(fr.hoteia.qalingo.core.domain.ProductSku)
  */
 public void addOrUpdateProductSku(
     final ProductSku productSku, final MarketArea marketArea, final Retailer retailer)
     throws SolrServerException, IOException {
   if (productSku.getId() == null) {
     throw new IllegalArgumentException("Id  cannot be blank or null.");
   }
   if (logger.isDebugEnabled()) {
     logger.debug("Indexing productSku " + productSku.getId());
     logger.debug("Indexing productSku " + productSku.getBusinessName());
     logger.debug("Indexing productSku " + productSku.getDescription());
     logger.debug("Indexing productSku " + productSku.getCode());
   }
   ProductSkuSolr productSkuSolr = new ProductSkuSolr();
   productSkuSolr.setId(productSku.getId());
   productSkuSolr.setBusinessname(productSku.getBusinessName());
   productSkuSolr.setDescription(productSku.getDescription());
   productSkuSolr.setCode(productSku.getCode());
   ProductSkuPrice productSkuPrice = productSku.getPrice(marketArea.getId(), retailer.getId());
   if (productSkuPrice != null) {
     BigDecimal salePrice = productSkuPrice.getSalePrice();
     productSkuSolr.setPrice(salePrice.toString());
   }
   productSkuSolrServer.addBean(productSkuSolr);
   productSkuSolrServer.commit();
 }
 public String getInvoiceTemplateByMarketArea(final MarketArea marketArea) {
   String invoiceTemplate = marketArea.getInvoiceTemplate();
   if (StringUtils.isEmpty(invoiceTemplate)) {
     invoiceTemplate = getDefaultInvoiceTemplate();
   }
   return invoiceTemplate;
 }
 public String getShippingConfirmationTemplateByMarketArea(final MarketArea marketArea) {
   String shippingConfirmationTemplate = marketArea.getShippingConfirmationTemplate();
   if (StringUtils.isEmpty(shippingConfirmationTemplate)) {
     shippingConfirmationTemplate = getDefaultShippingConfirmationTemplate();
   }
   return shippingConfirmationTemplate;
 }
 public String getOrderConfirmationTemplateByMarketArea(final MarketArea marketArea) {
   String orderConfirmationTemplate = marketArea.getOrderConfirmationTemplate();
   if (StringUtils.isEmpty(orderConfirmationTemplate)) {
     orderConfirmationTemplate = getDefaultOrderConfirmationTemplate();
   }
   return orderConfirmationTemplate;
 }
  public String buildChangeLanguageUrl(final RequestData requestData) throws Exception {
    final MarketPlace marketPlace = requestData.getMarketPlace();
    final Market market = requestData.getMarket();
    final MarketArea marketArea = requestData.getMarketArea();
    final Localization localization = requestData.getMarketAreaLocalization();
    final Retailer retailer = requestData.getMarketAreaRetailer();
    final CurrencyReferential currency = requestData.getMarketAreaCurrency();

    String url =
        buildDefaultPrefix(requestData) + FoUrls.CHANGE_LANGUAGE.getUrlWithoutWildcard() + "?";
    url =
        url
            + RequestConstants.REQUEST_PARAMETER_MARKET_PLACE_CODE
            + "="
            + replaceSpaceAndUnderscore(marketPlace.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_CODE
            + "="
            + replaceSpaceAndUnderscore(market.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_AREA_CODE
            + "="
            + replaceSpaceAndUnderscore(marketArea.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_AREA_LANGUAGE
            + "="
            + replaceSpaceAndUnderscore(localization.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_AREA_RETAILER_CODE
            + "="
            + replaceSpaceAndUnderscore(retailer.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_AREA_CURRENCY_CODE
            + "="
            + replaceSpaceAndUnderscore(currency.getCode());
    return url;
  }
 public List<CustomerWishlistPojo> getWishlist(
     final Customer customer, final MarketArea marketArea) {
   final CustomerMarketArea customerMarketArea =
       customer.getCurrentCustomerMarketArea(marketArea.getId());
   Set<CustomerWishlist> wishlistProducts = customerMarketArea.getWishlistProducts();
   List<CustomerWishlistPojo> wishlists =
       PojoUtil.mapAll(dozerBeanMapper, wishlistProducts, CustomerWishlistPojo.class);
   return wishlists;
 }
  @RequestMapping(value = BoUrls.PRODUCT_SKU_EDIT_URL, method = RequestMethod.POST)
  public ModelAndView productSkuEdit(
      final HttpServletRequest request,
      final HttpServletResponse response,
      @Valid ProductSkuForm productSkuForm,
      BindingResult result,
      ModelMap modelMap)
      throws Exception {

    // "business.product.marketing.edit";

    final MarketArea currentMarketArea = requestUtil.getCurrentMarketArea(request);
    final Retailer currentRetailer = requestUtil.getCurrentRetailer(request);
    final String productSkuCode = productSkuForm.getCode();

    String urlRedirect =
        backofficeUrlService.generateUrl(BoUrls.HOME, requestUtil.getRequestData(request));

    if (StringUtils.isNotEmpty(productSkuCode)) {
      if (result.hasErrors()) {
        return productSkuEdit(request, response);
      }

      // SANITY CHECK
      final ProductSku productSku =
          productSkuService.getProductSkuByCode(
              currentMarketArea.getId(), currentRetailer.getId(), productSkuCode);
      if (productSku != null) {
        // UPDATE PRODUCT MARKETING
        webBackofficeService.updateProductSku(productSku, productSkuForm);

      } else {
        // CREATE PRODUCT MARKETING
        webBackofficeService.createProductSku(productSku, productSkuForm);
      }

      urlRedirect =
          backofficeUrlService.generateUrl(
              BoUrls.PRODUCT_SKU_DETAILS, requestUtil.getRequestData(request), productSku);
    }

    return new ModelAndView(new RedirectView(urlRedirect));
  }
  @RequestMapping(value = BoUrls.PRODUCT_MARKETING_DETAILS_URL, method = RequestMethod.GET)
  public ModelAndView productMarketingDetails(
      final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.PRODUCT_MARKETING_DETAILS.getVelocityPage());

    final MarketArea currentMarketArea = requestUtil.getCurrentMarketArea(request);
    final Retailer currentRetailer = requestUtil.getCurrentRetailer(request);
    final String productMarketingCode =
        request.getParameter(RequestConstants.REQUEST_PARAMETER_PRODUCT_MARKETING_CODE);
    final ProductMarketing productMarketing =
        productMarketingService.getProductMarketingByCode(
            currentMarketArea.getId(), currentRetailer.getId(), productMarketingCode);

    // "business.product.marketing.details";
    initProductMarketingModelAndView(request, modelAndView, productMarketing);
    initSpecificSeo(request, modelAndView, "", productMarketing.getBusinessName());

    return modelAndView;
  }
  @RequestMapping(value = BoUrls.PRODUCT_SKU_EDIT_URL, method = RequestMethod.GET)
  public ModelAndView productSkuEdit(
      final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.PRODUCT_SKU_EDIT.getVelocityPage());

    final MarketArea currentMarketArea = requestUtil.getCurrentMarketArea(request);
    final Retailer currentRetailer = requestUtil.getCurrentRetailer(request);
    final String productSkuCode =
        request.getParameter(RequestConstants.REQUEST_PARAMETER_PRODUCT_SKU_CODE);
    final ProductSku productSku =
        productSkuService.getProductSkuByCode(
            currentMarketArea.getId(), currentRetailer.getId(), productSkuCode);

    initProductSkuModelAndView(request, modelAndView, productSku);
    modelAndView.addObject("productSkuForm", formFactory.buildProductSkuForm(request, productSku));
    initSpecificSeo(request, modelAndView, "", productSku.getBusinessName());

    return modelAndView;
  }
  @RequestMapping(value = BoUrls.DELIVERY_METHOD_LIST_URL, method = RequestMethod.GET)
  public ModelAndView deliveryMethodList(final HttpServletRequest request, final Model model)
      throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.DELIVERY_METHOD_LIST.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);
    final MarketArea marketArea = requestData.getMarketArea();

    displayList(request, model, requestData);

    Object[] params = {marketArea.getName() + " (" + marketArea.getCode() + ")"};
    initPageTitleAndMainContentTitle(
        request, modelAndView, BoUrls.DELIVERY_METHOD_LIST.getKey() + ".by.market.area", params);

    model.addAttribute(
        ModelConstants.URL_ADD,
        backofficeUrlService.generateUrl(BoUrls.DELIVERY_METHOD_ADD, requestData));

    return modelAndView;
  }
  public String buildChangeContextUrl(final RequestData requestData) throws Exception {
    final MarketPlace marketPlace = requestData.getMarketPlace();
    final Market market = requestData.getMarket();
    final MarketArea marketArea = requestData.getMarketArea();
    final Localization localization = requestData.getMarketAreaLocalization();
    final Retailer retailer = requestData.getMarketAreaRetailer();

    String url =
        buildDefaultPrefix(requestData) + FoUrls.CHANGE_CONTEXT.getUrlWithoutWildcard() + "?";
    url =
        url
            + RequestConstants.REQUEST_PARAMETER_MARKET_PLACE_CODE
            + "="
            + handleString(marketPlace.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_CODE
            + "="
            + handleString(market.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_AREA_CODE
            + "="
            + handleString(marketArea.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_MARKET_LANGUAGE
            + "="
            + handleString(localization.getCode());
    url =
        url
            + "&"
            + RequestConstants.REQUEST_PARAMETER_RETAILER_CODE
            + "="
            + handleString(retailer.getCode());
    return url;
  }