コード例 #1
0
  @RequestMapping(value = BoUrls.STORE_EDIT_URL, method = RequestMethod.GET)
  public ModelAndView storeEdit(
      final HttpServletRequest request,
      final Model model,
      @ModelAttribute(ModelConstants.STORE_FORM) StoreForm storeForm)
      throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.STORE_EDIT.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);

    final String storeCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_STORE_CODE);
    if (StringUtils.isNotEmpty(storeCode)) {
      // EDIT MODE
      final Store store =
          retailerService.getStoreByCode(storeCode, FetchPlanGraphRetailer.fullStoreFetchPlan());

      // SANITY CHECK
      if (store != null) {
        modelAndView.addObject(
            ModelConstants.STORE_VIEW_BEAN,
            backofficeViewBeanFactory.buildViewBeanStore(requestData, store));
      } else {
        final String url = requestUtil.getLastRequestUrl(request);
        return new ModelAndView(new RedirectView(url));
      }

      model.addAttribute(
          ModelConstants.URL_BACK,
          backofficeUrlService.generateUrl(BoUrls.STORE_DETAILS, requestData, store));

      Object[] params = {store.getName() + " (" + store.getCode() + ")"};
      initPageTitleAndMainContentTitle(
          request, modelAndView, BoUrls.STORE_DETAILS.getKey(), params);

    } else {
      // ADD MODE

      initPageTitleAndMainContentTitle(request, modelAndView, BoUrls.STORE_ADD.getKey(), null);

      model.addAttribute(
          ModelConstants.URL_BACK,
          backofficeUrlService.generateUrl(BoUrls.STORE_LIST, requestData));
    }

    return modelAndView;
  }
コード例 #2
0
  @RequestMapping(value = BoUrls.STORE_DETAILS_URL, method = RequestMethod.GET)
  public ModelAndView storeDetails(final HttpServletRequest request, final Model model)
      throws Exception {
    ModelAndViewThemeDevice modelAndView =
        new ModelAndViewThemeDevice(
            getCurrentVelocityPath(request), BoUrls.STORE_DETAILS.getVelocityPage());
    final RequestData requestData = requestUtil.getRequestData(request);

    final String storeCode = request.getParameter(RequestConstants.REQUEST_PARAMETER_STORE_CODE);

    // SANITY CHECK
    if (StringUtils.isEmpty(storeCode)) {
      final String urlRedirect = backofficeUrlService.generateUrl(BoUrls.STORE_LIST, requestData);
      return new ModelAndView(new RedirectView(urlRedirect));
    }

    final Store retailer = retailerService.getStoreByCode(storeCode);

    // SANITY CHECK
    if (retailer != null) {
      modelAndView.addObject(
          ModelConstants.STORE_VIEW_BEAN,
          backofficeViewBeanFactory.buildViewBeanStore(requestData, retailer));
    } else {
      final String url = requestUtil.getLastRequestUrl(request);
      return new ModelAndView(new RedirectView(url));
    }

    model.addAttribute(
        ModelConstants.URL_BACK, backofficeUrlService.generateUrl(BoUrls.STORE_LIST, requestData));
    model.addAttribute(
        ModelConstants.URL_RETAILER_VIEW,
        backofficeUrlService.generateUrl(BoUrls.RETAILER_DETAILS, requestData, retailer));

    Object[] params = {retailer.getName() + " (" + retailer.getCode() + ")"};
    initPageTitleAndMainContentTitle(request, modelAndView, BoUrls.STORE_DETAILS.getKey(), params);

    return modelAndView;
  }