Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.SiteCurrencyClass


    Site site = SiteDAO.load(siteId);
    if (site == null) {
      throw new ItemSaveException(resources.getMessage("IE.ERROR.E109", "site", "siteId", siteId));
    }
    SiteProfileClass siteProfileClassDefault = site.getSiteProfileClassDefault();
    SiteCurrencyClass siteCurrencyClassDefault = site.getSiteCurrencyClassDefault();
   
   
   
    com.jada.jpa.entity.Item item = null;
    if (itemId != null) {
      item = ItemDAO.load(siteId, itemId);
      if (item == null) {
        throw new ItemSaveException(resources.getMessage("IE.ERROR.E109", "item", "itemId", itemId));
      }
     
    }
    else if (itemSkuCd != null) {
      item = ItemDAO.loadBySku(siteId, itemSkuCd);
    }
    if (item == null) {
      isNew = true;
      item = new com.jada.jpa.entity.Item();
      item.setItemUpcCd(itemSkuCd);
      item.setItemQty(0);
      item.setItemTypeCd(Constants.ITEM_TYPE_REGULAR);
      item.setItemBookedQty(0);
      item.setItemExpireOn(Format.HIGHDATE);
      item.setItemPublishOn(new Date());
      item.setItemHitCounter(0);
      item.setItemRating(Float.valueOf(0));
      item.setItemRatingCount(0);
      item.setSeqNum(0);
      item.setRecCreateBy(Constants.USERNAME_IMPORT);
      item.setRecCreateDatetime(new Date());
      item.setSite(site);
    }

    if (isNew) {
      if (isSimple) {
        boolean found = false;
        for (ItemLanguage itemLanguage : this.getItemLanguages()) {
          if (itemLanguage.getSiteProfileClassId() != null) {
            if (itemLanguage.getSiteProfileClassId().equals(siteProfileClassDefault.getSiteProfileClassId())) {
              found = true;
              break;
            }
          }
          else {
            if (itemLanguage.getSiteProfileClassName().equals(siteProfileClassDefault.getSiteProfileClassName())) {
              found = true;
              break;
            }
          }
        }
        if (!found) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E111", siteProfileClassDefault.getSiteProfileClassName()));
        }
        found = false;
        for (ItemPriceCurrency itemPriceCurrency : this.getItemPriceCurrencies()) {
          if (itemPriceCurrency.getSiteCurrencyClassId() != null) {
            if (itemPriceCurrency.getSiteCurrencyClassId().equals(siteCurrencyClassDefault.getSiteCurrencyClassId())) {
              found = true;
              break;
            }
          }
          else {
            if (itemPriceCurrency.getSiteCurrencyClassName().equals(siteCurrencyClassDefault.getSiteCurrencyClassName())) {
              found = true;
              break;
            }
          }
        }
        if (!found) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E112", siteCurrencyClassDefault.getSiteCurrencyClassName()));
        }
      }
    }
   
    item.setItemNum(itemNum);
    item.setItemSkuCd(itemSkuCd);
    item.setItemNaturalKey(Utility.encode(itemSkuCd));
    item.setItemSellable(itemSellable);
    item.setItemCost(itemCost);
    if (itemUpcCd != null) {
      item.setItemUpcCd(itemUpcCd);
    }
    if (itemTypeCd != null) {
      item.setItemTypeCd(itemTypeCd);
    }
    if (itemPublishOn != null) {
      item.setItemPublishOn(itemPublishOn);
    }
    if (itemExpireOn != null) {
      item.setItemExpireOn(itemExpireOn);
    }
    if (itemHitCounter != null) {
      item.setItemHitCounter(itemHitCounter);
    }
    if (itemRating != null) {
      item.setItemRating(itemRating);
    }
    if (itemRatingCount != null) {
      item.setItemRatingCount(itemRatingCount);
    }
    if (itemQty != null) {
      item.setItemQty(itemQty);
    }
    if (itemBookedQty != null) {
      item.setItemBookedQty(itemBookedQty);
    }
    item.setPublished(published);
    item.setRecUpdateBy(Constants.USERNAME_IMPORT);
    item.setRecUpdateDatetime(new Date());
   
    for (ItemLanguage itemLanguageImport : this.getItemLanguages()) {
      com.jada.jpa.entity.ItemLanguage itemLanguage = null;
      boolean found = false;
      for (com.jada.jpa.entity.ItemLanguage language : item.getItemLanguages()) {
        if (itemLanguageImport.getSiteProfileClassId() != null) {
          if (language.getSiteProfileClass().getSiteProfileClassId().equals(itemLanguageImport.getSiteProfileClassId())) {
            itemLanguage = language;
            found = true;
            break;
          }
        }
        else {
          if (language.getSiteProfileClass().getSiteProfileClassName().equals(itemLanguageImport.getSiteProfileClassName())) {
            itemLanguage = language;
            found = true;
            break;
          }
        }
      }
      if (!found) {
        itemLanguage = new com.jada.jpa.entity.ItemLanguage();
        itemLanguage.setItemImageOverride(String.valueOf(Constants.VALUE_NO));
        itemLanguage.setRecCreateBy(Constants.USERNAME_IMPORT);
        itemLanguage.setRecCreateDatetime(new Date());
        SiteProfileClass siteProfileClass = getSiteProfileClass(siteId, itemLanguageImport.getSiteProfileClassId(), itemLanguageImport.getSiteProfileClassName());
        if (siteProfileClass == null) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
                                   "siteProfileClass",
                                   "siteProfileClassId and siteProfileClassName",
                                   itemLanguageImport.getSiteProfileClassId().toString() + " and " + itemLanguageImport.getSiteProfileClassName()));
        }
        itemLanguage.setSiteProfileClass(siteProfileClass);
        itemLanguage.setItem(item);
       
        if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassDefault.getSiteProfileClassId())) {
          item.setItemLanguage(itemLanguage);
        }
      }
      itemLanguage.setItemShortDesc(itemLanguageImport.getItemShortDesc());
      itemLanguage.setItemDesc(itemLanguageImport.getItemDesc());
      itemLanguage.setPageTitle(itemLanguageImport.getPageTitle());
      itemLanguage.setMetaKeywords(itemLanguageImport.getMetaKeywords());
      itemLanguage.setMetaDescription(itemLanguageImport.getMetaDescription());
     
      itemLanguage.setItemImageOverride(itemLanguageImport.getItemImageOverride());
      for (com.jada.jpa.entity.ItemImage image : itemLanguage.getImages()) {
        em.remove(image);
      }
      itemLanguage.getImages().clear();
      for (ItemImage imageImport : itemLanguageImport.getImages()) {
        com.jada.jpa.entity.ItemImage itemImage = new com.jada.jpa.entity.ItemImage();
        itemImage = new com.jada.jpa.entity.ItemImage();
        itemImage.setContentType("image/jpeg");
        itemImage.setImageName("");
        itemImage.setImageHeight(-1);
        itemImage.setImageWidth(-1);
        itemImage.setRecCreateBy(Constants.USERNAME_IMPORT);
        itemImage.setRecCreateDatetime(new Date());
        itemLanguage.setImage(itemImage);
        itemImage.setRecUpdateBy(Constants.USERNAME_IMPORT);
        itemImage.setRecUpdateDatetime(new Date());
        itemImage.setImageValue(imageImport.getImageValue());
        em.persist(itemImage);
        if (imageImport.getDefaultImage().equals(String.valueOf(Constants.VALUE_YES))) {
          itemLanguage.setImage(itemImage);
        }
      }
     
      itemLanguage.setRecUpdateBy(Constants.USERNAME_IMPORT);
      itemLanguage.setRecUpdateDatetime(new Date());
      em.persist(itemLanguage);
    }
   
    for (ItemPriceCurrency itemPriceCurrencyImport : this.getItemPriceCurrencies()) {
      com.jada.jpa.entity.ItemPriceCurrency itemPriceCurrency = null;
      boolean found = false;
      for (com.jada.jpa.entity.ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
        if (currency.getItemPriceTypeCode() != itemPriceCurrencyImport.getItemPriceTypeCode()) {
          continue;
        }
        if (itemPriceCurrencyImport.getSiteCurrencyClassId() != null) {
          if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(itemPriceCurrencyImport.getSiteCurrencyClassId())) {
            itemPriceCurrency = currency;
            found = true;
            break;
          }
        }
        else {
          if (currency.getSiteCurrencyClass().getSiteCurrencyClassName().equals(itemPriceCurrencyImport.getSiteCurrencyClassName())) {
            itemPriceCurrency = currency;
            found = true;
            break;
          }
        }
      }
      if (!found) {
        itemPriceCurrency = new com.jada.jpa.entity.ItemPriceCurrency();
        itemPriceCurrency.setItemPriceTypeCode(itemPriceCurrencyImport.getItemPriceTypeCode());
        itemPriceCurrency.setRecCreateBy(Constants.USERNAME_IMPORT);
        itemPriceCurrency.setRecCreateDatetime(new Date());
        SiteCurrencyClass siteCurrencyClass = getSiteCurrencyClass(siteId, itemPriceCurrencyImport.getSiteCurrencyClassId(), itemPriceCurrencyImport.getSiteCurrencyClassName());
        if (siteCurrencyClass == null) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
                                   "siteCurrencyClass",
                                   "siteCurrencyClassId and siteCurrencyClassName",
                                   itemPriceCurrencyImport.getSiteCurrencyClassId().toString() + " and " + itemPriceCurrencyImport.getSiteCurrencyClassName()));
        }

        itemPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
        itemPriceCurrency.setItem(item);
       
        if (itemPriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassDefault.getSiteCurrencyClassId())) {
          if (itemPriceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
            item.setItemPrice(itemPriceCurrency);
          }
          else {
            item.setItemSpecPrice(itemPriceCurrency);
          }
        }
      }
      itemPriceCurrency.setItemPrice(itemPriceCurrencyImport.getItemPrice());
      itemPriceCurrency.setItemPricePublishOn(itemPriceCurrencyImport.getItemPricePublishOn());
      itemPriceCurrency.setItemPriceExpireOn(itemPriceCurrencyImport.getItemPriceExpireOn());
      itemPriceCurrency.setRecUpdateBy(Constants.USERNAME_IMPORT);
      itemPriceCurrency.setRecUpdateDatetime(new Date());
      em.persist(itemPriceCurrency);
     
      itemPriceCurrencyImport.setSiteCurrencyClassId(itemPriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId());
     
      if (isNew) {
        item.setItemPrice(itemPriceCurrency);
      }
      else {
        if (itemPriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassDefault.getSiteCurrencyClassId())) {
          if (itemPriceCurrency.getItemPriceTypeCode() == Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
            item.setItemPrice(itemPriceCurrency);
          }
          else {
            item.setItemSpecPrice(itemPriceCurrency);
          }
        }
      }
    }
    for (ItemPriceCurrency itemPriceCurrencyImport : this.getItemPriceCurrencies()) {
      if (itemPriceCurrencyImport.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
        continue;
      }
      // look for corresponding special price
      boolean found = false;
      for (ItemPriceCurrency itemSpecPriceCurrencyImport : this.getItemPriceCurrencies()) {
        if (itemSpecPriceCurrencyImport.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
          continue;
        }
        if (itemPriceCurrencyImport.getSiteCurrencyClassId().equals(itemSpecPriceCurrencyImport.getSiteCurrencyClassId())) {
          found = true;
          break;
        }
      }
      // if not found, ensure special price is removed.
      if (!found) {
        if (itemPriceCurrencyImport.getSiteCurrencyClassId().equals(siteCurrencyClassDefault.getSiteCurrencyClassId())) {
          item.setItemSpecPrice(null);
        }
        for (com.jada.jpa.entity.ItemPriceCurrency itemPriceCurrency : item.getItemPriceCurrencies()) {
          if (itemPriceCurrency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
            continue;
          }
          if (!itemPriceCurrencyImport.getSiteCurrencyClassId().equals(siteCurrencyClassDefault.getSiteCurrencyClassId())) {
            if (!itemPriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(itemPriceCurrencyImport.getSiteCurrencyClassId())) {
              continue;
            }
          }
          em.remove(itemPriceCurrency);
        }
      }
    }
   
    em.persist(item);
   
    CategorySearchUtil.itemPriceSearchUpdate(item, site, adminBean);
    CategorySearchUtil.itemDescSearchUpdate(item, site, adminBean);
   
    ShippingType shippingType = null;
    if (shippingTypeId != null) {
      shippingType = ShippingTypeDAO.load(siteId, shippingTypeId);
    }
    else {
      shippingType = ShippingTypeDAO.loadByName(siteId, shippingTypeName);
    }
    if (shippingType == null) {
      throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
           "shippingType",
           "shippingTypeId and shippingTypeName",
           shippingTypeId.toString() + " and " + shippingTypeName));
    }
    item.setShippingType(shippingType);
   
    ProductClass productClass = null;
    if (productClassId != null) {
      productClass = ProductClassDAO.load(siteId, productClassId);
    }
    else {
      productClass = ProductClassDAO.loadByName(siteId, productClassName);
    }
    if (productClass == null) {
      throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
           "productClass",
           "productClassId and productClassName",
           productClassId.toString() + " and " + productClassName));
    }
    item.setProductClass(productClass);
   
    if (itemParentId != null || itemParentSkuCd != null) {
      com.jada.jpa.entity.Item parent = null;
      if (itemParentId != null) {
        parent = ItemDAO.load(siteId, itemParentId);
      }
      else {
        parent = ItemDAO.loadBySku(siteId, itemParentSkuCd);
      }
      if (parent == null) {
        throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
             "item",
             "itemId and itemSkuCd",
             itemParentId.toString() + " and " + itemParentSkuCd));
      }
      item.setItemSkuParent(parent);
    }
   
    item.getCategories().clear();
    if (this.getCategories() != null) {
      for (Category categoryImport : this.getCategories()) {
        com.jada.jpa.entity.Category category = null;
        if (categoryImport.getCatId() != null) {
          category = CategoryDAO.load(siteId, categoryImport.getCatId());
        }
        else {
          category = CategoryDAO.loadByShortTitle(siteId, categoryImport.getCatShortTitle());
        }
        if (category == null) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
               "category",
               "catId and catShortTitle",
               categoryImport.getCatId().toString() + " and " + categoryImport.getCatShortTitle()));
        }
        item.getCategories().add(category);
      }
    }
   
    item.getItemsRelated().clear();
    if (this.getItemsRelated() != null) {
      for (Item i : this.getItemsRelated()) {
        com.jada.jpa.entity.Item child = null;
        if (i.getItemId() != null) {
          child = ItemDAO.load(siteId, i.getItemId());
        }
        else {
          child = ItemDAO.loadBySku(siteId, i.getItemSkuCd());
        }
        if (child == null) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
               "item",
               "itemId and itemSkuCd",
               i.getItemId().toString() + " and " + i.getItemSkuCd()));
        }
        item.getItemsRelated().add(child);
      }
    }
   
    item.getItemsUpSell().clear();
    if (this.getItemsUpSell() != null) {
      for (Item i : this.getItemsUpSell()) {
        com.jada.jpa.entity.Item child = null;
        if (i.getItemId() != null) {
          child = ItemDAO.load(siteId, i.getItemId());
        }
        else {
          child = ItemDAO.loadBySku(siteId, i.getItemSkuCd());
        }
        if (child == null) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
               "item",
               "itemId and itemSkuCd",
               i.getItemId().toString() + " and " + i.getItemSkuCd()));
        }
        item.getItemsUpSell().add(child);
      }
    }
   
    item.getItemsCrossSell().clear();
    if (this.getItemsCrossSell() != null) {
      for (Item i : this.getItemsCrossSell()) {
        com.jada.jpa.entity.Item child = null;
        if (i.getItemId() != null) {
          child = ItemDAO.load(siteId, i.getItemId());
        }
        else {
          child = ItemDAO.loadBySku(siteId, i.getItemSkuCd());
        }
        if (child == null) {
          throw new ItemSaveException(resources.getMessage("IE.ERROR.E109",
               "item",
               "itemId and itemSkuCd",
               i.getItemId().toString() + " and " + i.getItemSkuCd()));
        }
        item.getItemsCrossSell().add(child);
      }
    }
   
    if (this.getItemTierPrices() != null) {
      for (com.jada.xml.ie.ItemTierPrice itemTierPriceImport : this.getItemTierPrices()) {
        com.jada.jpa.entity.ItemTierPrice itemTierPrice = null;
        boolean foundTier = false;
        for (com.jada.jpa.entity.ItemTierPrice price : item.getItemTierPrices()) {
          if (!itemTierPriceImport.getItemTierQty().equals(price.getItemTierQty())) {
            continue;
          }
          if (price.getCustomerClass() == null) {
            if (itemTierPriceImport.getCustClassId() == null && itemTierPriceImport.getCustClassName() == null) {
              itemTierPrice = price;
              foundTier = true;
              break;
            }
          }
          else {
            if (itemTierPriceImport.getCustClassId() == null) {
              if (itemTierPriceImport.getCustClassName().equals(price.getCustomerClass().getCustClassName())) {
                itemTierPrice = price;
                foundTier = true;
                break;
              }
            }
            else {
              if (itemTierPriceImport.getCustClassId().equals(price.getCustomerClass().getCustClassId())) {
                itemTierPrice = price;
                foundTier = true;
                break;
              }
            }
          }
        }
        if (!foundTier) {
          if (!defaultCurrency && !defaultProfile) {
            throw new ItemSaveException("Item tier price does not exist in base record");
          }
          itemTierPrice = new com.jada.jpa.entity.ItemTierPrice();
          itemTierPrice.setRecCreateBy(Constants.USERNAME_IMPORT);
          itemTierPrice.setRecCreateDatetime(new Date());
          itemTierPrice.setItem(item);
        }
        itemTierPrice.setItemTierQty(itemTierPriceImport.getItemTierQty());
        itemTierPrice.setItemTierPricePublishOn(itemTierPriceImport.getItemTierPricePublishOn());
        itemTierPrice.setItemTierPriceExpireOn(itemTierPriceImport.getItemTierPriceExpireOn());
        itemTierPrice.setRecUpdateBy(Constants.USERNAME_IMPORT);
        itemTierPrice.setRecUpdateDatetime(new Date());
       
        for (ItemTierPriceCurrency itemTierPriceCurrencyImport : itemTierPriceImport.getItemTierPriceCurrencies()) {
          com.jada.jpa.entity.ItemTierPriceCurrency itemTierPriceCurrency = null;
          boolean found = false;
          for (com.jada.jpa.entity.ItemTierPriceCurrency currency : itemTierPrice.getItemTierPriceCurrencies()) {
            if (itemTierPriceCurrencyImport.getSiteCurrencyClassId() != null) {
              if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(itemTierPriceCurrencyImport.getSiteCurrencyClassId())) {
                itemTierPriceCurrency = currency;
                found = true;
                break;
              }
            }
            else {
              if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(itemTierPriceCurrencyImport.getSiteCurrencyClassName())) {
                itemTierPriceCurrency = currency;
                found = true;
                break;
              }
            }
          }
          if (itemTierPriceCurrencyImport.getItemPrice() == null) {
            if (found) {
              em.remove(itemTierPriceCurrency);
              itemTierPrice.getItemTierPriceCurrencies().remove(itemTierPriceCurrency);
            }
          }
          else {
            if (!found) {
              itemTierPriceCurrency = new com.jada.jpa.entity.ItemTierPriceCurrency();
              itemTierPriceCurrency.setRecCreateBy(Constants.USERNAME_IMPORT);
              itemTierPriceCurrency.setRecCreateDatetime(new Date());
              SiteCurrencyClass siteCurrencyClass = getSiteCurrencyClass(siteId, itemTierPriceCurrencyImport.getSiteCurrencyClassId(),
                                             itemTierPriceCurrencyImport.getSiteCurrencyClassName());
              itemTierPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
              itemTierPriceCurrency.setItemTierPrice(itemTierPrice);
              if (siteCurrencyClass.getSiteCurrencyClassId().equals(siteCurrencyClassDefault.getSiteCurrencyClassId())) {
                itemTierPrice.setItemTierPriceCurrency(itemTierPriceCurrency);
              }
            }
            itemTierPriceCurrency.setItemPrice(itemTierPriceCurrencyImport.getItemPrice());
            itemTierPriceCurrency.setRecUpdateBy(Constants.USERNAME_IMPORT);
View Full Code Here


    CouponCurrency couponCurrency = coupon.getCouponCurrency();
    if (couponCurrency == null) {
      couponCurrency = new CouponCurrency();
      couponCurrency.setCoupon(coupon);
      coupon.getCouponCurrencies().add(couponCurrency);
        SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) em.find(SiteCurrencyClass.class, form.getSiteCurrencyClassDefaultId());
        couponCurrency.setSiteCurrencyClass(siteCurrencyClass);
        couponCurrency.setRecCreateBy(adminBean.getUser().getUserId());
        couponCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        coupon.setCouponCurrency(couponCurrency);
    }
View Full Code Here

    }
    if (!found) {
      couponCurrency = new CouponCurrency();
      couponCurrency.setRecCreateBy(user.getUserId());
      couponCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) em.find(SiteCurrencyClass.class, siteCurrencyClassId);
        couponCurrency.setSiteCurrencyClass(siteCurrencyClass);
        couponCurrency.setCoupon(coupon);
        coupon.getCouponCurrencies().add(couponCurrency);
    }
    couponCurrency.setCouponDiscountAmount(null);
View Full Code Here

          }
        }
       
        vector = new Vector<LabelValueBean>();
      Long siteCurrencyClassDefaultId = null;
        SiteCurrencyClass siteCurrencyClassDefault = site.getSiteCurrencyClassDefault();
        if (siteCurrencyClassDefault != null) {
          siteCurrencyClassDefaultId = siteCurrencyClassDefault.getSiteCurrencyClassId();
          form.setSiteCurrencyClassDefaultId(siteCurrencyClassDefaultId);
          vector.add(new LabelValueBean(siteCurrencyClassDefault.getSiteCurrencyClassName(),
              siteCurrencyClassDefault.getSiteCurrencyClassId().toString()));
        }
       
      sql = "from   SiteCurrencyClass siteCurrencyClass " +
          "where  siteCurrencyClass.site.siteId = :siteId " +
          "order  by siteCurrencyClassName ";
      query = em.createQuery(sql);
      query.setParameter("siteId", site.getSiteId());
        iterator = query.getResultList().iterator();
        while (iterator.hasNext()) {
          SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next();
          if (siteProfileClassDefault != null) {
            if (siteCurrencyClass.getSiteCurrencyClassId().equals(siteCurrencyClassDefaultId)) {
              continue;
            }
          }
          vector.add(new LabelValueBean(siteCurrencyClass.getSiteCurrencyClassName(),
              siteCurrencyClass.getSiteCurrencyClassId().toString()));
        }
        LabelValueBean siteCurrencyClassBeans[] = new LabelValueBean[vector.size()];
        vector.copyInto(siteCurrencyClassBeans);
        form.setSiteCurrencyClassBeans(siteCurrencyClassBeans);
       
View Full Code Here

    sql = "from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId";
    query = em.createQuery(sql);
    query.setParameter("siteId", site.getSiteId());
    iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
      SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next();
      siteCurrencyClass.setCurrency(null);
        em.remove(siteCurrencyClass);
    }
   
    sql = "from Currency currency where currency.site.siteId = :siteId";
    query = em.createQuery(sql);
View Full Code Here

                              HttpServletResponse response)
        throws Throwable {

    Site site = getAdminBean(request).getSite();
        SiteCurrencyClassMaintActionForm form = (SiteCurrencyClassMaintActionForm) actionForm;
        SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassId());
        form.setMode("U");
        copyProperties(form, siteCurrencyClass);
        createAdditionalInfo(form, site.getSiteId());
        FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
        ActionForward actionForward = actionMapping.findForward("success");
View Full Code Here

            HttpServletResponse response)
    throws Throwable {
   
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    SiteCurrencyClassMaintActionForm form = (SiteCurrencyClassMaintActionForm) actionForm;
        SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassId());

    try {
      CategorySearchUtil.removeSiteCurrencyClass(getAdminBean(request).getUserId(), siteCurrencyClass);
      em.remove(siteCurrencyClass);
      em.getTransaction().commit();
View Full Code Here

    }
        createAdditionalInfo(form, site.getSiteId());

    AdminBean adminBean = getAdminBean(request);

    SiteCurrencyClass siteCurrencyClass = new SiteCurrencyClass();
    if (!insertMode) {
          siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassId());
    }

    ActionMessages errors = validate(form);
    if (errors.size() != 0) {
      saveMessages(request, errors);
      return mapping.findForward("error");
    }

    if (insertMode) {
      siteCurrencyClass.setSite(site);
      siteCurrencyClass.setSystemRecord(Constants.VALUE_NO);
      siteCurrencyClass.setRecCreateBy(adminBean.getUser().getUserId());
      siteCurrencyClass.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    siteCurrencyClass.setSiteCurrencyClassName(form.getSiteCurrencyClassName());
    siteCurrencyClass.setRecUpdateBy(adminBean.getUser().getUserId());
    siteCurrencyClass.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
   
    String localeTokens[] = form.getLocale().split("-");
    siteCurrencyClass.setCurrencyLocaleLanguage(localeTokens[0]);
    siteCurrencyClass.setCurrencyLocaleCountry("");
    if (localeTokens.length > 1) {
      siteCurrencyClass.setCurrencyLocaleCountry(localeTokens[1]);
    }
   
    Currency currency = CurrencyDAO.load(site.getSiteId(), Format.getLong(form.getCurrencyId()));
    siteCurrencyClass.setCurrency(currency);
   
    if (insertMode) {
      em.persist(siteCurrencyClass);
      em.flush();
      CategorySearchUtil.createSiteCurrencyClass(site.getSiteCurrencyClassDefault(), siteCurrencyClass, site.getSiteId(), adminBean.getUserId());
    }
    else {
      // em.update(siteCurrencyClass);
    }
    form.setMode("U");
    form.setSiteCurrencyClassId(siteCurrencyClass.getSiteCurrencyClassId());
        FormUtils.setFormDisplayMode(request, form, FormUtils.EDIT_MODE);
    return mapping.findForward("success");
  }
View Full Code Here

      query.getResultList().toArray(siteProfileClasses);
     
      sql = "from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId";
      query = em.createQuery(sql);
      query.setParameter("siteId", site.getSiteId());
      SiteCurrencyClass siteCurrencyClasses[] = new SiteCurrencyClass[query.getResultList().size()];
      query.getResultList().toArray(siteCurrencyClasses);
     
      OutputStream outputStream = null;
      if (form.getExportLocation().equals(Constants.IE_EXPORT_LOCATION_LOCAL)) {
        if (form.getExportType().equals(Constants.IE_EXPORT_TYPE_CSV)) {
View Full Code Here

    Query query = em.createQuery("from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId");
    query.setParameter("siteId", site.getSiteId());
    Iterator<?> iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
      SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next();
      if (specialPrice != null) {
        ItemPriceSearch itemPriceSearch = new ItemPriceSearch();
        ItemPriceCurrency itemPriceCurrency = null;
        for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
          if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
            continue;
          }
          if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
            itemPriceCurrency = currency;
            break;
          }
        }
        if (itemPriceCurrency == null || itemPriceCurrency.getItemPrice() == null) {
          itemPriceSearch.setItemPrice(specialPrice.getItemPrice());
          itemPriceSearch.setExchangeFactor(Integer.valueOf(1));
        }
        else {
          itemPriceSearch.setItemPrice(itemPriceCurrency.getItemPrice());
          itemPriceSearch.setExchangeFactor(Integer.valueOf(0))
        }
        itemPriceSearch.setItemPricePublishOn(specialPrice.getItemPricePublishOn());
        itemPriceSearch.setItemPriceExpireOn(specialPrice.getItemPriceExpireOn());
        itemPriceSearch.setRecUpdateBy(adminBean.getUser().getUserId());
        itemPriceSearch.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        itemPriceSearch.setRecCreateBy(adminBean.getUser().getUserId());
        itemPriceSearch.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        itemPriceSearch.setSiteCurrencyClass(siteCurrencyClass);
        itemPriceSearch.setItem(master);
        em.persist(itemPriceSearch);
        master.getItemPriceSearches().add(itemPriceSearch);
      }
      ItemPriceCurrency itemPriceCurrency = null;
      for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
        if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
          continue;
        }
        if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
          itemPriceCurrency = currency;
          break;
        }
      }
      ItemPriceSearch itemPriceSearch = new ItemPriceSearch();
View Full Code Here

TOP

Related Classes of com.jada.jpa.entity.SiteCurrencyClass

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.