Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.ItemTierPrice


    ItemTierPriceDisplayForm prices[] = form.getItemTierPrices();
    for (int i = 0; i < prices.length; i++) {
      ItemTierPriceDisplayForm price = prices[i];
      Iterator<?> iterator = item.getItemTierPrices().iterator();
      boolean found = false;
      ItemTierPrice itemTierPrice = null;
      ItemTierPriceCurrency itemTierPriceCurrency = null;
      if (!Format.isNullOrEmpty(price.getItemTierPriceId())) {
        while (iterator.hasNext()) {
          itemTierPrice = (ItemTierPrice) iterator.next();
          if (itemTierPrice.getItemTierPriceId().equals(Format.getLong(price.getItemTierPriceId()))) {
            found = true;
            itemTierPriceCurrency = itemTierPrice.getItemTierPriceCurrency();
            break;
          }
        }
      }
      if (!found) {
        itemTierPrice = new ItemTierPrice();
        itemTierPrice.setRecCreateBy(adminBean.getUser().getUserId());
        itemTierPrice.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        item.getItemTierPrices().add(itemTierPrice);
       
        itemTierPriceCurrency = new ItemTierPriceCurrency();
        itemTierPriceCurrency.setRecCreateBy(adminBean.getUser().getUserId());
        itemTierPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        itemTierPrice.setItemTierPriceCurrency(itemTierPriceCurrency);
        itemTierPrice.getItemTierPriceCurrencies().add(itemTierPriceCurrency);
        itemTierPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
      }
      itemTierPriceCurrency.setItemPrice(Format.getFloatObj(price.getItemTierPrice()));
      itemTierPriceCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      em.persist(itemTierPriceCurrency);

      itemTierPrice.setItemTierQty(Format.getIntObj(price.getItemTierQty()));
      itemTierPrice.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPrice.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (Format.isNullOrEmpty(price.getItemTierPricePublishOn())) {
        itemTierPrice.setItemTierPricePublishOn(Format.LOWDATE);
      }
      else {
        itemTierPrice.setItemTierPricePublishOn(Format.getDate(price.getItemTierPricePublishOn()));
      }
      if (Format.isNullOrEmpty(price.getItemTierPriceExpireOn())) {
        itemTierPrice.setItemTierPricePublishOn(Format.HIGHDATE);
      }
      else {
        itemTierPrice.setItemTierPricePublishOn(Format.getDate(price.getItemTierPriceExpireOn()));
      }
    }
   
    if (!Format.isNullOrEmpty(form.getCustomAttribGroupId())) {
      Long customAttribGroupId = Format.getLong(form.getCustomAttribGroupId());
View Full Code Here


    ItemMaintActionForm form = (ItemMaintActionForm) actionForm;
    AdminBean adminBean = getAdminBean(request);
    Site site = adminBean.getSite();
        initSiteProfiles(form, site);
 
    ItemTierPrice itemTierPrice = ItemTierPriceDAO.load(site.getSiteId(), Format.getLong(form.getItemTierPriceId()));
    streamWebService(response, getJSONItemTierPrice(itemTierPrice, form));
        return null;

  }
View Full Code Here

      }
    }

       String itemTierPriceId = form.getItemTierPriceId();
    Item item = ItemDAO.load(site.getSiteId(), Format.getLong(form.getItemId()));
    ItemTierPrice itemTierPrice = null;
    ItemTierPriceCurrency itemTierPriceCurrency = null;
    boolean exist = true;
    if (!Format.isNullOrEmpty(itemTierPriceId)) {
      itemTierPrice = ItemTierPriceDAO.load(site.getSiteId(), Format.getLong(itemTierPriceId));
      itemTierPriceCurrency = itemTierPrice.getItemTierPriceCurrency();
    }
    else {
      itemTierPrice = new ItemTierPrice();
      itemTierPrice.setRecCreateBy(adminBean.getUser().getUserId());
      itemTierPrice.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      itemTierPrice.setItem(item);
     
      itemTierPriceCurrency = new ItemTierPriceCurrency();
      exist = false;
      itemTierPriceCurrency.setRecCreateBy(adminBean.getUser().getUserId());
      itemTierPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      itemTierPrice.setItemTierPriceCurrency(itemTierPriceCurrency);
      itemTierPrice.getItemTierPriceCurrencies().add(itemTierPriceCurrency);
      SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassDefaultId());
      itemTierPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
    }
    if (form.isSiteCurrencyClassDefault()) {
      itemTierPriceCurrency.setItemPrice(Format.getFloat(form.getItemTierPrice()));
      itemTierPriceCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (!exist) {
        em.persist(itemTierPriceCurrency);
      }

      itemTierPrice.setItemTierQty(Format.getIntObj(form.getItemTierQty()));
      if (!Format.isNullOrEmpty(form.getItemTierPricePublishOn())) {
        itemTierPrice.setItemTierPricePublishOn(Format.getDate(form.getItemTierPricePublishOn()));
      }
      else {
        itemTierPrice.setItemTierPricePublishOn(null);
      }
      if (!Format.isNullOrEmpty(form.getItemTierPriceExpireOn())) {
        itemTierPrice.setItemTierPriceExpireOn(Format.getDate(form.getItemTierPriceExpireOn()));
      }
      else {
        itemTierPrice.setItemTierPriceExpireOn(null);
      }
      itemTierPrice.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPrice.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (Format.isNullOrEmpty(form.getCustClassId())) {
        itemTierPrice.setCustomerClass(null);
      }
      else {
        CustomerClass customerClass = CustomerClassDAO.load(site.getSiteId(), Format.getLong(form.getCustClassId()));
        itemTierPrice.setCustomerClass(customerClass);
      }
      em.persist(itemTierPrice);
    }
    else {
      itemTierPriceCurrency = null;
      SiteCurrencyClass siteCurrencyClass = SiteCurrencyClassDAO.load(form.getSiteCurrencyClassId());
      for (ItemTierPriceCurrency priceCurrency : itemTierPrice.getItemTierPriceCurrencies()) {
        if (priceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
          itemTierPriceCurrency = priceCurrency;
          break;
        }
      }
      exist = true;
      if (itemTierPriceCurrency == null) {
        itemTierPriceCurrency = new ItemTierPriceCurrency();
        exist = false;
        itemTierPriceCurrency.setRecCreateBy(adminBean.getUser().getUserId());
        itemTierPriceCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        itemTierPriceCurrency.setItemTierPrice(itemTierPrice);
        itemTierPriceCurrency.setSiteCurrencyClass(siteCurrencyClass);
      }
      if (form.isItemTierPriceOverride()) {
        itemTierPriceCurrency.setItemPrice(Format.getFloat(form.getItemTierPrice()));
      }
      else {
        itemTierPriceCurrency.setItemPrice(null);
      }
      itemTierPriceCurrency.setRecUpdateBy(adminBean.getUser().getUserId());
      itemTierPriceCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      if (!exist) {
        em.persist(itemTierPriceCurrency);
      }
    }

    item.setRecUpdateBy(adminBean.getUser().getUserId());
    item.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    em.persist(item);

    jsonResult = new JSONEscapeObject();
    jsonResult.put("status", Constants.WEBSERVICE_STATUS_SUCCESS);
    jsonResult.put("itemTierPriceId", itemTierPrice.getItemTierPriceId());
    jsonResult.put("recUpdateBy", item.getRecUpdateBy());
    jsonResult.put("recUpdateDatetime", Format.getFullDatetime(item.getRecUpdateDatetime()));
    streamWebService(response, jsonResult.toHtmlString());
    return null;
  }
View Full Code Here

      query = em.createQuery(sql);
      query.setParameter("itemId", item.getItemId());
      iterator = query.getResultList().iterator();
      Vector<ItemTierPriceDisplayForm> vector = new Vector<ItemTierPriceDisplayForm>();
      while (iterator.hasNext()) {
        ItemTierPrice itemTierPrice = (ItemTierPrice) iterator.next();
        ItemTierPriceDisplayForm priceForm = new ItemTierPriceDisplayForm();
        priceForm.setItemTierPriceId(itemTierPrice.getItemTierPriceId().toString());
        priceForm.setCustClassId("");
        if (itemTierPrice.getCustomerClass() != null) {
          priceForm.setCustClassId(itemTierPrice.getCustomerClass().getCustClassId().toString());
        }
        priceForm.setItemTierQty(itemTierPrice.getItemTierQty().toString());
        priceForm.setItemTierPrice(Format.getFloat(itemTierPrice.getItemTierPriceCurrency().getItemPrice()));
        priceForm.setItemTierPricePublishOn(Format.getDate(itemTierPrice.getItemTierPricePublishOn()));
        priceForm.setItemTierPriceExpireOn(Format.getDate(itemTierPrice.getItemTierPriceExpireOn()));
        vector.add(priceForm);
      }
      ItemTierPriceDisplayForm itemTierPrices[] = new ItemTierPriceDisplayForm[vector.size()];
      vector.copyInto(itemTierPrices);
      form.setItemTierPrices(itemTierPrices);
View Full Code Here

      }
      em.persist(itemPriceCurrency);
    }
   
    for (ItemTierPrice sourceTierPrice : source.getItemTierPrices()) {
      ItemTierPrice itemTierPrice = new ItemTierPrice();
      itemTierPrice.setItemTierQty(sourceTierPrice.getItemTierQty());
      itemTierPrice.setItemTierPricePublishOn(sourceTierPrice.getItemTierPricePublishOn());
      itemTierPrice.setItemTierPriceExpireOn(sourceTierPrice.getItemTierPriceExpireOn());
      itemTierPrice.setRecUpdateBy(user.getUserId());
      itemTierPrice.setRecUpdateDatetime(new Date());
      itemTierPrice.setRecCreateBy(user.getUserId());
      itemTierPrice.setRecCreateDatetime(new Date());
      itemTierPrice.setCustomerClass(sourceTierPrice.getCustomerClass());
      item.getItemTierPrices().add(itemTierPrice);
     
      for (ItemTierPriceCurrency sourceTierPriceCurrency : sourceTierPrice.getItemTierPriceCurrencies()) {
        ItemTierPriceCurrency itemTierPriceCurrency = new ItemTierPriceCurrency();
        itemTierPriceCurrency.setItemPrice(sourceTierPriceCurrency.getItemPrice());
        itemTierPriceCurrency.setRecUpdateBy(user.getUserId());
        itemTierPriceCurrency.setRecUpdateDatetime(new Date());
        itemTierPriceCurrency.setRecCreateBy(user.getUserId());
        itemTierPriceCurrency.setRecCreateDatetime(new Date());
        itemTierPriceCurrency.setSiteCurrencyClass(sourceTierPriceCurrency.getSiteCurrencyClass());
        itemTierPrice.getItemTierPriceCurrencies().add(itemTierPriceCurrency);
        em.persist(itemTierPriceCurrency);
        if (sourceTierPriceCurrency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(adminBean.getSite().getSiteCurrencyClassDefault().getSiteCurrencyClassId())) {
          itemTierPrice.setItemTierPriceCurrency(itemTierPriceCurrency);
        }
      }
      em.persist(itemTierPrice);
    }
    em.persist(item);
View Full Code Here

public class ItemTierPriceDAO extends ItemTierPrice {
  private static final long serialVersionUID = 2927973275751752923L;

  public static ItemTierPrice load(String siteId, Long itemTierPriceId) throws SecurityException, Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      ItemTierPrice itemTierPrice = (ItemTierPrice) em.find(ItemTierPrice.class, itemTierPriceId);
    if (!itemTierPrice.getItem().getSite().getSiteId().equals(siteId)) {
      throw new SecurityException();
    }
    return itemTierPrice;
  }
View Full Code Here

  public ItemEligibleTierPrice[] getItemEligibleTierPrice(Item item) {
    Vector<ItemEligibleTierPrice> prices = new Vector<ItemEligibleTierPrice>();
    Iterator<?> iterator = item.getItemTierPrices().iterator();
    while (iterator.hasNext()) {
      ItemTierPrice itemTierPrice = (ItemTierPrice) iterator.next();
      if (itemTierPrice.getCustomerClass() != null) {
        if (customer == null) {
          continue;
        }
        if (!itemTierPrice.getCustomerClass().getCustClassId().equals(customer.getCustomerClass().getCustClassId())) {
          continue;
        }
      }
      if (!Utility.isDateBetween(itemTierPrice.getItemTierPricePublishOn(), itemTierPrice.getItemTierPriceExpireOn())) {
        continue;
      }
      ItemEligibleTierPrice price = new ItemEligibleTierPrice();
      price.setItemTierQty(itemTierPrice.getItemTierQty());
      float p = itemTierPrice.getItemTierPriceCurrency().getItemPrice();
      Long defaultSiteCurrencyClassId = contentBean.getSiteDomain().getSite().getSiteDomainDefault().getSiteCurrencyDefault().getSiteCurrencyClass().getSiteCurrencyClassId();
      if (!defaultSiteCurrencyClassId.equals(siteCurrencyClassId)) {
        boolean found = false;
        for (ItemTierPriceCurrency currency : itemTierPrice.getItemTierPriceCurrencies()) {
          if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
            if (currency.getItemPrice() != null) {
              p = currency.getItemPrice();
              found = true;
            }
            break;
          }
        }
        if (!found) {
          p = currencyConverter.convert(p);
        }
      }
      price.setItemTierPrice(p);
      price.setItemTierPricePublishOn(itemTierPrice.getItemTierPricePublishOn());
      price.setItemTierPriceExpireOn(itemTierPrice.getItemTierPriceExpireOn());
      prices.add(price);
    }
    ItemEligibleTierPrice itemEligibleTierPrice[] = new ItemEligibleTierPrice[prices.size()];
    prices.copyInto(itemEligibleTierPrice);
    return itemEligibleTierPrice;
View Full Code Here

TOP

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

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.