Package com.jada.content

Examples of com.jada.content.ContentBean


    api = new ContentApi(siteDomain, siteProfile, siteCurrency);
    siteInfo = api.getSite();
  }
 
  public void init() throws Exception {
    ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
    siteDomain = contentBean.getContentSessionBean().getSiteDomain();
    siteDomainLanguage = siteDomain.getSiteDomainLanguage();
    siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(siteDomain.getSiteDomainLanguage(), siteDomainLanguage);
    this.siteProfile = contentBean.getContentSessionBean().getSiteProfile();
    this.siteCurrency = contentBean.getContentSessionBean().getSiteCurrency();
    String value = siteDomainParamBean.getCategoryPageSize();
    if (!Format.isNullOrEmpty(value)) {
      pageSize = Format.getInt(value);
    }
    siteName = siteDomainLanguage.getSiteName();
    if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
      for (SiteDomainLanguage language : siteDomain.getSiteDomainLanguages()) {
        if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
          siteDomainLanguage = language;
        }
      }
      if (siteDomainLanguage.getSiteName() != null) {
        siteName = siteDomainLanguage.getSiteName();
View Full Code Here


            "/home";
    return result;
  }
 
  public String parseRepostURL(String url) throws Exception {
    ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
    ContentSessionBean sessionBean = contentBean.getContentSessionBean();
    url = url.replace("${siteDomainPrefix}", sessionBean.getSiteDomain().getSiteDomainPrefix());
    return url;
  }
View Full Code Here

    return pageHeaderInfo;
  }
 
  public PageHeaderInfo getPageHomeHeaderInfo() {
    PageHeaderInfo pageHeaderInfo = new PageHeaderInfo();
    ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
    HomePage homePage = siteDomain.getHomePage();
    pageHeaderInfo.setPageTitle(siteName);
    pageHeaderInfo.setMetaKeywords(siteName);
    pageHeaderInfo.setMetaDescription(siteName);
    if (!Format.isNullOrEmpty(homePage.getHomePageLanguage().getHomePageTitle())) {
      pageHeaderInfo.setPageTitle(homePage.getHomePageLanguage().getHomePageTitle());
    }
    if (!Format.isNullOrEmpty(homePage.getHomePageLanguage().getMetaKeywords())) {
      pageHeaderInfo.setMetaKeywords(homePage.getHomePageLanguage().getMetaKeywords());
    }
    if (!Format.isNullOrEmpty(homePage.getHomePageLanguage().getMetaDescription())) {
      pageHeaderInfo.setMetaDescription(homePage.getHomePageLanguage().getMetaDescription());
    }
    if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
      for (HomePageLanguage language : homePage.getHomePageLanguages()) {
        if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
          if (language.getHomePageTitle() != null) {
            pageHeaderInfo.setPageTitle(language.getHomePageTitle());
          }
          if (language.getMetaKeywords() != null) {
            pageHeaderInfo.setMetaKeywords(language.getMetaKeywords());
View Full Code Here

          pageHeaderInfo.setMetaDescription(category.getCategoryLanguage().getCatShortTitle());
        }
        else {
          pageHeaderInfo.setMetaDescription(category.getCategoryLanguage().getMetaDescription());
        }
        ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
        if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
          for (CategoryLanguage language : category.getCategoryLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCatShortTitle() != null) {
                pageHeaderInfo.setPageTitle(language.getCatShortTitle());
              }
              if (!Format.isNullOrEmpty(language.getMetaKeywords())) {
                pageHeaderInfo.setMetaKeywords(language.getMetaKeywords());
View Full Code Here

     * @deprecated
     * Calling method getPageTitle() is deprecated.
     */
    @Deprecated
    public String getPageHomeTitle() {
    ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
    HomePage homePage = siteDomain.getHomePage();
    String homePageTitle = siteName;
    if (!Format.isNullOrEmpty(homePage.getHomePageLanguage().getHomePageTitle())) {
      homePageTitle = homePage.getHomePageLanguage().getHomePageTitle();
    }
    if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
      for (HomePageLanguage language : homePage.getHomePageLanguages()) {
        if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
          if (language.getHomePageTitle() != null) {
            homePageTitle = language.getHomePageTitle();
            break;
          }
        }
View Full Code Here

    Category category = dataApi.getCategory(siteDomain.getSite().getSiteId(), catNaturalKey);
        if (category == null) {
          return siteName + " - " + getLanguageByValue("Page not found");
        }
        String catShortTitle = category.getCategoryLanguage().getCatShortTitle();
        ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
        if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
          for (CategoryLanguage language : category.getCategoryLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCatShortTitle() != null) {
                catShortTitle = language.getCatShortTitle();
              }
              break;
            }
View Full Code Here

  public boolean isCustomerSession() throws Exception {
    return ContentLookupDispatchAction.isCustomerSession(request);
  }
 
  public boolean isShoppingCart() throws Exception {
    ContentBean contentBean = ContentLookupDispatchAction.getContentBean(request);
    SiteCurrency siteCurrency = contentBean.getContentSessionBean().getSiteCurrency();
    if (siteCurrency.getPayPalPaymentGateway() != null) {
      return true;
    }
    if (siteCurrency.getPaymentGateway() != null) {
      return true;
View Full Code Here

    }
    }
   
    protected void initCartInfo(ShoppingCartActionForm form, Site site, ShoppingCart shoppingCart, HttpServletRequest request, ActionMessages messages) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      ContentBean contentBean = getContentBean(request);
      Formatter formatter = contentBean.getFormatter();
      Long siteProfileClassId = contentBean.getContentSessionKey().getSiteProfileClassId();
     
      form.setCustomerSignin(isCustomerSession(request));
      form.setShippingQuoteLock(shoppingCart.isShippingQuoteLock());

      form.setCurrencyCode(contentBean.getContentSessionBean().getSiteCurrency().getSiteCurrencyClass().getCurrency().getCurrencyCode());
      if (shoppingCart.getShippingMethod() != null) {
        form.setShippingMethodId(shoppingCart.getShippingMethod().getShippingMethodId().toString());
      }
      Vector<ShoppingCartItemBean> vector = new Vector<ShoppingCartItemBean>();
      Iterator<?> iterator = shoppingCart.getShoppingCartItems().iterator();
      while (iterator.hasNext()) {
        ShoppingCartItem shoppingCartItem = (ShoppingCartItem) iterator.next();
        ShoppingCartItemBean bean = new ShoppingCartItemBean();
        Item item = shoppingCartItem.getItem();
        Item master = item;
        if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          master = item.getItemSkuParent();
        }
       
        bean.setItemId(item.getItemId().toString());
        bean.setItemNum(item.getItemNum());
        bean.setItemNaturalKey(item.getItemNaturalKey());
        bean.setItemQty(Format.getInt(shoppingCartItem.getItemQty()));
        int tierQty = shoppingCartItem.getTierPrice().getItemTierQty();
        float tierPrice = shoppingCartItem.getTierPrice().getItemTierPrice();
        bean.setItemPrice(formatItemPrice(contentBean, tierQty, tierPrice));
        bean.setItemSubTotal(formatter.formatCurrency(shoppingCartItem.getItemPriceTotal()));
        bean.setItemQtyError("");
       
       
        bean.setItemShortDesc(master.getItemLanguage().getItemShortDesc());
        ItemImage itemImage = master.getItemLanguage().getImage();
        if (itemImage != null) {
          bean.setImageId(itemImage.getImageId().toString());
        }
            if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()){
              for (ItemLanguage itemLanguage : master.getItemLanguages()) {
                if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                  if (itemLanguage.getItemShortDesc() != null) {
                    bean.setItemShortDesc(itemLanguage.getItemShortDesc());
                  }
                  if (itemLanguage.getItemImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
                    bean.setImageId(itemLanguage.getImage().getImageId().toString());
                  }
                  break;
                }
              }
            }
           
            Vector<ShoppingCartItemAttributeBean> shoppingCartItemAttributes = new Vector<ShoppingCartItemAttributeBean>();
            Iterator<?> itemAttributeInfoIterator = shoppingCartItem.getItemAttributeInfos().iterator();
            while (itemAttributeInfoIterator.hasNext()) {
              ItemAttributeInfo itemAttributeInfo = (ItemAttributeInfo) itemAttributeInfoIterator.next();
              ShoppingCartItemAttributeBean attributeBean = new ShoppingCartItemAttributeBean();
             
              ItemAttributeDetail itemAttributeDetail = (ItemAttributeDetail) em.find(ItemAttributeDetail.class, itemAttributeInfo.getItemAttribDetailId());
              CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_INPUT) {
                continue;
              }
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN) {
                continue;
              }
             
              attributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
              if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
                for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                    if (language.getCustomAttribDesc() != null) {
                      attributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                    }
                      break;
                  }
                }
              }
             
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
                attributeBean.setCustomAttribValue(itemAttributeInfo.getItemAttribDetailValue());
              }
              else {
                CustomAttributeOption customAttribOption = CustomAttributeOptionDAO.load(site.getSiteId(), itemAttributeInfo.getCustomAttribOptionId());
                attributeBean.setCustomAttribValue(customAttribOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
                if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
                  for (CustomAttributeOptionLanguage language : customAttribOption.getCustomAttributeOptionLanguages()) {
                    if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                      if (language.getCustomAttribValue() != null) {
                        attributeBean.setCustomAttribValue(language.getCustomAttribValue());
                      }
                      break;
                    }
                  }
                }
              }
              shoppingCartItemAttributes.add(attributeBean);
            }
            bean.setShoppingCartItemAttributes(shoppingCartItemAttributes);
        vector.add(bean);
      }
      form.setShoppingCartItemInfos(vector);
     
      Vector<ShoppingCartCouponBean> couponVector = new Vector<ShoppingCartCouponBean>();
      iterator = shoppingCart.getShoppingCartCoupons().iterator();
      while (iterator.hasNext()) {
        ShoppingCartCoupon shoppingCartCoupon = (ShoppingCartCoupon) iterator.next();
        Coupon coupon = shoppingCartCoupon.getCoupon();
        ShoppingCartCouponBean bean = new ShoppingCartCouponBean();
        bean.setCouponId(Format.getLong(coupon.getCouponId()));
        bean.setCouponCode(coupon.getCouponCode());
        bean.setCouponName(coupon.getCouponLanguage().getCouponName());
        if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
          for (CouponLanguage language : coupon.getCouponLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCouponName() != null) {
                bean.setCouponName(language.getCouponName());
              }
              break;
            }
          }
        }
        bean.setCouponAmount(formatter.formatCurrency(shoppingCartCoupon.getCouponAmount()));
        couponVector.add(bean);
      }
      form.setShoppingCartCouponInfos(couponVector);
     
      ItemTax taxes[] = shoppingCart.getTaxes();
       Vector<ShoppingCartTaxInfo> taxVector = new Vector<ShoppingCartTaxInfo>();
      if (taxes != null) {
        for (int i = 0; i < taxes.length; i++) {
          ShoppingCartTaxInfo taxInfo = new ShoppingCartTaxInfo();
          Tax tax = taxes[i].getTax();
          taxInfo.setTaxName(tax.getTaxLanguage().getTaxName());
          if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
            for (TaxLanguage language : tax.getTaxLanguages()) {
              if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                if (language.getTaxName() != null) {
                  taxInfo.setTaxName(language.getTaxName());
                }
                break;
              }
            }
          }
          taxInfo.setTaxAmount(formatter.formatCurrency(taxes[i].getTaxAmount()));
          taxVector.add(taxInfo);
        }
      }
      Collections.sort(taxVector);
      form.setShoppingCartTaxInfos(taxVector);
     
      form.setPriceTotal(formatter.formatCurrency(shoppingCart.getShoppingCartSubTotal()));
      form.setTaxTotal(formatter.formatCurrency(shoppingCart.getTaxTotal()));
      form.setShippingTotal(formatter.formatCurrency(shoppingCart.getShippingTotal()));
      form.setShippingDiscountTotal(formatter.formatCurrency(shoppingCart.getShippingDiscountTotal()));
      form.setShippingOrderTotal(formatter.formatCurrency(shoppingCart.getShippingOrderTotal()));
      form.setOrderTotal(formatter.formatCurrency(shoppingCart.getOrderTotal()));
     
      Vector<?> shippingMethodVector = shoppingCart.getShippingMethods();
      Vector<LabelValueBean> smVector = new Vector<LabelValueBean>();
      iterator = shippingMethodVector.iterator();
      while (iterator.hasNext()) {
        ShippingMethod shippingMethod = (ShippingMethod) iterator.next();
        LabelValueBean bean = new LabelValueBean();
        bean.setLabel(shippingMethod.getShippingMethodLanguage().getShippingMethodName());
        bean.setValue(shippingMethod.getShippingMethodId().toString());
            if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
          for (ShippingMethodLanguage language : shippingMethod.getShippingMethodLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getShippingMethodName() != null) {
                bean.setLabel(language.getShippingMethodName());
              }
              break;
            }
          }
            }
        smVector.add(bean);
      }
      LabelValueBean shippingMethods[] = new LabelValueBean[smVector.size()];
      smVector.copyInto(shippingMethods);
      form.setShippingMethods(shippingMethods);
     
      SiteDomainLanguage siteDomainLanguage = contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage();
      for (SiteDomainLanguage language : contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguages()) {
        if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
          siteDomainLanguage = language;
          break;
        }
      }
     
      SiteDomainParamBean siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage(), siteDomainLanguage);
      form.setShoppingCartMessage(siteDomainParamBean.getCheckoutShoppingCartMessage());
      PaymentEngine paymentEngine = shoppingCart.getPaymentEngine();
      if (paymentEngine != null) {
        form.setPaymentGatewayProvider(paymentEngine.getClass().getSimpleName());
      }
View Full Code Here

      shoppingCart.setOrderNum(null);
    }
   
    protected void finalizeOrder(ShoppingCartActionForm form, Site site, ShoppingCart shoppingCart, HttpServletRequest request, ActionMessages messages) throws Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      ContentBean contentBean = getContentBean(request);
      PaymentEngine paymentEngine = (PaymentEngine) shoppingCart.getPaymentEngine();
      createEmptySecureTemplateInfo(request);
    OrderEngine orderEngine = null;
    try {
        SiteDomainParamBean siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage(),
                                                 contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage());
        orderEngine = new OrderEngine(shoppingCart, null);
        if (shoppingCart.isCashPaymentOrder()) {
          orderEngine.processOrder();
          orderEngine.saveOrder();
        }
View Full Code Here

    }
   
    protected void initFromOrder(String orderNum, ShoppingCartActionForm form, Site site, HttpServletRequest request, ActionMessages messages) throws Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Long custId = ContentLookupDispatchAction.getCustId(request);
    ContentBean contentBean = getContentBean(request);
    Formatter formatter = contentBean.getFormatter();
    OrderHeader orderHeader = null;
    String sql = "select  orderHeader " +
                 "from    OrderHeader orderHeader " +
                 "where   orderHeader.siteDomain.site.siteId = :siteId " +
                 "and     orderHeader.orderNum = :orderNum ";
        Query query = em.createQuery(sql);
        query.setParameter("siteId", site.getSiteId());
        query.setParameter("orderNum", orderNum);
        List<?> list = query.getResultList();
        if (list.size() > 0) {
          orderHeader = (OrderHeader) list.get(0);
        }
        if (!orderHeader.getCustomer().getCustId().equals(custId)) {
          throw new SecurityException("Customer should not have access to other's customer order");
        }
        OrderEngine orderEngine = new OrderEngine(orderHeader, null);
       
        Iterator<?> iterator = orderHeader.getOrderItemDetails().iterator();
      Vector<ShoppingCartItemBean> vector = new Vector<ShoppingCartItemBean>();
        while (iterator.hasNext()) {
          OrderItemDetail orderItemDetail = (OrderItemDetail) iterator.next();
          ShoppingCartItemBean bean = new ShoppingCartItemBean();
          Item item = orderItemDetail.getItem();
          Item master = item;
          if (item != null) {
            if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
              master = item.getItemSkuParent();
            }
          }
         
          bean.setItemId("");
          if (item != null) {
            bean.setItemId(item.getItemId().toString());
          }
         
        bean.setItemNum(orderItemDetail.getItemNum());
        bean.setItemShortDesc(orderItemDetail.getItemShortDesc());
        bean.setItemQty(formatter.formatNumber(orderItemDetail.getItemOrderQty()));
        bean.setItemPrice(formatItemPrice(contentBean, orderItemDetail.getItemTierQty(), orderItemDetail.getItemTierPrice()));
        bean.setItemSubTotal(formatter.formatCurrency(orderItemDetail.getItemDetailAmount()));
        bean.setItemQtyError("");
      bean.setImageId(null);
      bean.setItemShortDesc(orderItemDetail.getItemShortDesc());
        if (item != null) {
          ItemImage itemImage = orderItemDetail.getItem().getItemLanguage().getImage();
          if (itemImage != null) {
            bean.setImageId(itemImage.getImageId().toString());
          }
          if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
            for (ItemLanguage language : master.getItemLanguages()) {
              if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                if (language.getItemImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
                  bean.setImageId("");
                  if (language.getImage() != null) {
                    bean.setImageId(language.getImage().getImageId().toString());
                  }
                }
                if (language.getItemShortDesc() != null) {
                  bean.setItemShortDesc(language.getItemShortDesc());
                }
                break;
              }
            }
          }
        }
       
        Vector<ShoppingCartItemAttributeBean> shoppingCartItemAttributes = new Vector<ShoppingCartItemAttributeBean>();
        if (item != null && item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          for (ItemAttributeDetail itemAttributeDetail : item.getItemAttributeDetails()) {
            CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
            if (customAttribute.getCustomAttribTypeCode() != Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
              continue;
            }
            ShoppingCartItemAttributeBean shoppingCartItemAttributeBean = new ShoppingCartItemAttributeBean();
           
            shoppingCartItemAttributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribDesc() != null) {
                      shoppingCartItemAttributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                    }
                    break;
                  }
                }
              }

              CustomAttributeOption customAttributeOption = itemAttributeDetail.getCustomAttributeOption();
              shoppingCartItemAttributeBean.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribValue() != null) {
                      shoppingCartItemAttributeBean.setCustomAttribValue(language.getCustomAttribValue());
                    }
                    break;
                  }
                }
              }
              shoppingCartItemAttributes.add(shoppingCartItemAttributeBean);
          }
        }
       
        for (OrderAttributeDetail orderAttributeDetail : orderItemDetail.getOrderAttributeDetails()) {
          ShoppingCartItemAttributeBean shoppingCartItemAttributeBean = new ShoppingCartItemAttributeBean();
          CustomAttribute customAttribute = orderAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
          shoppingCartItemAttributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
            if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
              for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                  if (language.getCustomAttribDesc() != null) {
                    shoppingCartItemAttributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                  }
                  break;
                }
              }
            }
           
            if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
              shoppingCartItemAttributeBean.setCustomAttribValue(orderAttributeDetail.getOrderAttribValue());
            }
            else {
              CustomAttributeOption customAttributeOption = orderAttributeDetail.getCustomAttributeOption();
              shoppingCartItemAttributeBean.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribValue() != null) {
                      shoppingCartItemAttributeBean.setCustomAttribValue(language.getCustomAttribValue());
                    }
                    break;
                  }
                }
              }
            }
            shoppingCartItemAttributes.add(shoppingCartItemAttributeBean);
        }
       
        bean.setShoppingCartItemAttributes(shoppingCartItemAttributes);
        vector.add(bean);
        }
        form.setShoppingCartItemInfos(vector);
       
      Vector<ShoppingCartCouponBean> couponVector = new Vector<ShoppingCartCouponBean>();
      iterator = orderHeader.getOrderOtherDetails().iterator();
       while (iterator.hasNext()) {
        OrderOtherDetail orderOtherDetail = (OrderOtherDetail) iterator.next();
        Coupon coupon = orderOtherDetail.getCoupon();
        ShoppingCartCouponBean bean = new ShoppingCartCouponBean();
        bean.setCouponCode(coupon.getCouponCode());
        bean.setCouponName(coupon.getCouponLanguage().getCouponName());
        if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
          for (CouponLanguage language : coupon.getCouponLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCouponName() != null) {
                bean.setCouponName(language.getCouponName());
              }
              break;
            }
          }
        }
        bean.setCouponAmount(Format.getFloat(orderOtherDetail.getOrderOtherDetailAmount()));
        couponVector.add(bean);
      }
      form.setShoppingCartCouponInfos(couponVector);

        sql = "select  orderDetailTax.taxName, sum(orderDetailTax.taxAmount) " +
              "from    OrderDetailTax orderDetailTax " +
              "left    join orderDetailTax.orderHeader orderHeader " +
              "where   orderHeader.orderHeaderId = :orderHeaderId " +
              "group   by orderDetailTax.taxName " +
              "order   by orderDetailTax.taxName ";
        query = em.createQuery(sql);
        query.setParameter("orderHeaderId", orderHeader.getOrderHeaderId());
        iterator = query.getResultList().iterator();
      Vector<ShoppingCartTaxInfo> taxVector = new Vector<ShoppingCartTaxInfo>();
      while (iterator.hasNext()) {
        Object object[] = (Object[]) iterator.next();
        String taxName = (String) object[0];
        Double taxAmount = (Double) object[1];
        ShoppingCartTaxInfo taxInfo = new ShoppingCartTaxInfo();
        taxInfo.setTaxName(taxName);
        taxInfo.setTaxAmount(formatter.formatCurrency(taxAmount.floatValue()));
        taxVector.add(taxInfo);
      }
      form.setShoppingCartTaxInfos(taxVector);
       
      form.setPriceTotal(formatter.formatCurrency(orderEngine.getOrderSubTotal()));
      form.setTaxTotal(formatter.formatCurrency(orderEngine.getOrderTaxTotal()));
      form.setShippingTotal(formatter.formatCurrency(orderHeader.getShippingTotal()));
      form.setShippingDiscountTotal(formatter.formatCurrency(orderHeader.getShippingDiscountTotal()));
      form.setShippingOrderTotal(formatter.formatCurrency(orderHeader.getShippingTotal() - orderHeader.getShippingDiscountTotal()));
      form.setOrderTotal(formatter.formatCurrency(orderHeader.getOrderTotal()));
     
      OrderAddress custAddress = orderHeader.getCustAddress();
      if (custAddress != null) {
        ShoppingCartAddressActionForm custAddressForm = new ShoppingCartAddressActionForm();
        custAddressForm.setCustUseAddress(custAddress.getCustUseAddress());
        custAddressForm.setCustPrefix(custAddress.getCustPrefix());
        custAddressForm.setCustFirstName(custAddress.getCustFirstName());
        custAddressForm.setCustMiddleName(custAddress.getCustMiddleName());
        custAddressForm.setCustLastName(custAddress.getCustLastName());
        custAddressForm.setCustSuffix(custAddress.getCustSuffix());
        custAddressForm.setCustAddressLine1(custAddress.getCustAddressLine1());
        custAddressForm.setCustAddressLine2(custAddress.getCustAddressLine2());
        custAddressForm.setCustCityName(custAddress.getCustCityName());
        custAddressForm.setCustStateName(custAddress.getCustStateName());
        custAddressForm.setCustStateCode(custAddress.getCustStateCode());
        custAddressForm.setCustZipCode(custAddress.getCustZipCode());
        custAddressForm.setCustCountryName(custAddress.getCustCountryName());
        custAddressForm.setCustCountryCode(custAddress.getCustCountryCode());
        custAddressForm.setCustPhoneNum(custAddress.getCustPhoneNum());
        custAddressForm.setCustFaxNum(custAddress.getCustFaxNum());
        form.setCustAddress(custAddressForm);
      }
     
      OrderAddress billingAddress = orderHeader.getBillingAddress();
      OrderAddress shippingAddress = orderHeader.getShippingAddress();
    if (billingAddress != null) {
        ShoppingCartAddressActionForm billingAddressForm = new ShoppingCartAddressActionForm();
        billingAddressForm.setCustUseAddress(billingAddress.getCustUseAddress());
        billingAddressForm.setCustPrefix(billingAddress.getCustPrefix());
        billingAddressForm.setCustFirstName(billingAddress.getCustFirstName());
        billingAddressForm.setCustMiddleName(billingAddress.getCustMiddleName());
        billingAddressForm.setCustLastName(billingAddress.getCustLastName());
        billingAddressForm.setCustSuffix(billingAddress.getCustSuffix());
        billingAddressForm.setCustAddressLine1(billingAddress.getCustAddressLine1());
        billingAddressForm.setCustAddressLine2(billingAddress.getCustAddressLine2());
        billingAddressForm.setCustCityName(billingAddress.getCustCityName());
        billingAddressForm.setCustStateName(billingAddress.getCustStateName());
        billingAddressForm.setCustStateCode(billingAddress.getCustStateCode());
        billingAddressForm.setCustZipCode(billingAddress.getCustZipCode());
        billingAddressForm.setCustCountryName(billingAddress.getCustCountryName());
        billingAddressForm.setCustCountryCode(billingAddress.getCustCountryCode());
        billingAddressForm.setCustPhoneNum(billingAddress.getCustPhoneNum());
        billingAddressForm.setCustFaxNum(billingAddress.getCustFaxNum());
        form.setBillingAddress(billingAddressForm);
    }
    if (shippingAddress != null) {
        ShoppingCartAddressActionForm shippingAddressForm = new ShoppingCartAddressActionForm();
        shippingAddressForm.setCustUseAddress(shippingAddress.getCustUseAddress());
        shippingAddressForm.setCustPrefix(shippingAddress.getCustPrefix());
        shippingAddressForm.setCustFirstName(shippingAddress.getCustFirstName());
        shippingAddressForm.setCustMiddleName(shippingAddress.getCustMiddleName());
        shippingAddressForm.setCustLastName(shippingAddress.getCustLastName());
        shippingAddressForm.setCustSuffix(shippingAddress.getCustSuffix());
        shippingAddressForm.setCustAddressLine1(shippingAddress.getCustAddressLine1());
        shippingAddressForm.setCustAddressLine2(shippingAddress.getCustAddressLine2());
        shippingAddressForm.setCustCityName(shippingAddress.getCustCityName());
        shippingAddressForm.setCustStateName(shippingAddress.getCustStateName());
        shippingAddressForm.setCustStateCode(shippingAddress.getCustStateCode());
        shippingAddressForm.setCustZipCode(shippingAddress.getCustZipCode());
        shippingAddressForm.setCustCountryName(shippingAddress.getCustCountryName());
        shippingAddressForm.setCustCountryCode(shippingAddress.getCustCountryCode());
        shippingAddressForm.setCustPhoneNum(shippingAddress.getCustPhoneNum());
        shippingAddressForm.setCustFaxNum(shippingAddress.getCustFaxNum());
        form.setShippingAddress(shippingAddressForm);
    }
      form.setCustEmail(orderHeader.getCustEmail());
      form.setShippingMethodName(orderHeader.getShippingMethodName());
      PaymentTran payment = orderHeader.getPaymentTran();
      if (payment == null) {
        for (InvoiceHeader invoiceHeader : orderHeader.getInvoiceHeaders()) {
          payment = invoiceHeader.getPaymentTran();
        }
      }
      if (payment != null) {
        form.setPaymentGatewayProvider(orderHeader.getPaymentGatewayProvider());
        if (orderHeader.getPaymentGatewayProvider().equals(PayPalEngine.class.getSimpleName())) {
            form.setPayPal(true);
            form.setAuthCode(payment.getAuthCode());
        }
        else {
          form.setPayPal(false);
          form.setCreditCardDesc(orderHeader.getCreditCardDesc());
          String custCreditCardNum = AESEncoder.getInstance().decode(orderHeader.getCustCreditCardNum());
          custCreditCardNum = Utility.maskCreditCardNumber(custCreditCardNum);
          form.setCustCreditCardNum(custCreditCardNum);
          form.setAuthCode(payment.getAuthCode());
        }
      }
      else {
        form.setCashPaymentOrder(true);
      }
      form.setOrderNum(orderNum);
      form.setOrderDatetime(formatter.formatFullDate(orderHeader.getOrderDate()));
      PaymentGateway paymentGateway = null;
      if (paymentGateway != null) {
        if (orderHeader.getPaymentGatewayProvider().equals(PayPalEngine.class.getSimpleName())) {
          form.setPayPal(true);
        }
        PaymentTran paymentTran = orderHeader.getPaymentTran();
        if (paymentTran == null) {
          Iterator<?> invoiceIterator = orderHeader.getInvoiceHeaders().iterator();
          if (invoiceIterator.hasNext()) {
            InvoiceHeader invoiceHeader = (InvoiceHeader) invoiceIterator.next();
            paymentTran = invoiceHeader.getPaymentTran();
          }
        }
      if (paymentTran != null) {
        form.setAuthCode(paymentTran.getAuthCode());
      }
      }
     
      Long siteProfileId = contentBean.getContentSessionBean().getSiteProfile().getSiteProfileId();
      SiteDomainLanguage siteDomainLanguage = contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage();
      if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
        for (SiteDomainLanguage language : contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguages()) {
          if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileId)) {
            siteDomainLanguage = language;
          }
        }
      }
      SiteDomainParamBean siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage(), siteDomainLanguage);
      form.setShoppingCartMessage(siteDomainParamBean.getCheckoutShoppingCartMessage());
      form.setCurrencyCode(orderHeader.getSiteCurrency().getSiteCurrencyClass().getCurrency().getCurrencyCode());
    }
View Full Code Here

TOP

Related Classes of com.jada.content.ContentBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.