Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.ShippingMethod


    sql = "from ShippingMethod where siteId = :siteId";
    query = em.createQuery(sql);
    query.setParameter("siteId", site.getSiteId());
    iterator = query.getResultList().iterator();
    while (iterator.hasNext()) {
       ShippingMethod shippingMethod = (ShippingMethod) iterator.next();
       em.remove(shippingMethod.getShippingMethodLanguage());
        em.remove(shippingMethod);
    }

    sql = "from ShippingRegion where siteId = :siteId";
    query = em.createQuery(sql);
View Full Code Here


        String sql = "from ShippingMethod where siteId = :siteId order by shippingMethodId";
        Query query = em.createQuery(sql);
        query.setParameter("siteId", Constants.SITE_SYSTEM);
        Iterator<?> iterator = query.getResultList().iterator();
        while (iterator.hasNext()) {
          ShippingMethod master = (ShippingMethod) iterator.next();
          ShippingMethod shippingMethod = new ShippingMethod();
          shippingMethod.setSite(site);
          shippingMethod.setSeqNum(master.getSeqNum());
          shippingMethod.setPublished(master.getPublished());
          shippingMethod.setRecUpdateBy(userId);
          shippingMethod.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
          shippingMethod.setRecCreateBy(userId);
          shippingMethod.setRecCreateDatetime(new Date(System.currentTimeMillis()));
         
          for (ShippingMethodLanguage language : master.getShippingMethodLanguages()) {
            ShippingMethodLanguage shippingMethodLanguage = new ShippingMethodLanguage();
            shippingMethodLanguage.setShippingMethodName(language.getShippingMethodName());
            shippingMethodLanguage.setRecUpdateBy(userId);
            shippingMethodLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
            shippingMethodLanguage.setRecCreateBy(userId);
            shippingMethodLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            em.persist(shippingMethodLanguage);
            if (language.getShippingMethodLangId().equals(master.getShippingMethodLanguage().getShippingMethodLangId())) {
              shippingMethod.setShippingMethodLanguage(shippingMethodLanguage);
            }
            shippingMethod.getShippingMethodLanguages().add(shippingMethodLanguage);
          }
         
          if (master.getShippingMethodRegions() != null) {
            Iterator<?> it = master.getShippingMethodRegions().iterator();
            while (it.hasNext()) {
              ShippingMethodRegion m_shippingMethodRegion = (ShippingMethodRegion) it.next();
              ShippingMethodRegion shippingMethodRegion = new ShippingMethodRegion();
              shippingMethodRegion.setPublished(m_shippingMethodRegion.getPublished());
              shippingMethodRegion.setRecUpdateBy(userId);
              shippingMethodRegion.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
              shippingMethodRegion.setRecCreateBy(userId);
              shippingMethodRegion.setRecCreateDatetime(new Date(System.currentTimeMillis()));
              shippingMethodRegion.setShippingMethod(shippingMethod);
              ShippingRegion shippingRegion = getShippingRegion(m_shippingMethodRegion.getShippingRegion().getShippingRegionName());
              shippingMethodRegion.setShippingRegion(shippingRegion);
             
              if (m_shippingMethodRegion.getShippingMethodRegionTypes() != null) {
                Iterator<?> it1 = m_shippingMethodRegion.getShippingMethodRegionTypes().iterator();
                while (it1.hasNext()) {
                  ShippingMethodRegionType m_shippingMethodRegionType = (ShippingMethodRegionType) it1.next();
                  ShippingMethodRegionType shippingMethodRegionType = new ShippingMethodRegionType();
                      shippingMethodRegionType.setPublished(m_shippingMethodRegionType.getPublished());
                      shippingMethodRegionType.setRecUpdateBy(userId);
                      shippingMethodRegionType.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
                      shippingMethodRegionType.setRecCreateBy(userId);
                      shippingMethodRegionType.setRecCreateDatetime(new Date(System.currentTimeMillis()));
                      shippingMethodRegionType.setShippingRegion(shippingRegion);
                      shippingMethodRegionType.setShippingMethod(shippingMethod);
                      shippingMethodRegionType.setShippingType(getShippingType(m_shippingMethodRegionType.getShippingType().getShippingTypeName()));
                     
                      ShippingRate m_shippingRate = m_shippingMethodRegionType.getShippingRate();
                      ShippingRate shippingRate = new ShippingRate();
                          PropertyUtils.copyProperties(shippingRate, m_shippingRate);
                      shippingRate.setPublished(m_shippingRate.getPublished());
                      shippingRate.setRecUpdateBy(userId);
                      shippingRate.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
                      shippingRate.setRecCreateBy(userId);
                      shippingRate.setRecCreateDatetime(new Date(System.currentTimeMillis()));
                      shippingMethodRegionType.setShippingRate(shippingRate);
                     
                      em.persist(shippingRate);
                      em.persist(shippingMethodRegionType);
                      shippingMethodRegion.getShippingMethodRegionTypes().add(shippingMethodRegionType);
                }
              }
             
              shippingMethod.getShippingMethodRegions().add(shippingMethodRegion);
            }
          }
          em.persist(shippingMethod);
        }
  }
View Full Code Here

     
      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;
View Full Code Here

public class ShippingMethodDAO extends ShippingMethod {
  private static final long serialVersionUID = 4497338014468025543L;

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

                                "order  by seqNum");
        query.setParameter("siteId", contentSessionKey.getSiteId());
        query.setParameter("published", String.valueOf(Constants.PUBLISHED_YES));
        iterator = query.getResultList().iterator();
        while (iterator.hasNext()) {
          ShippingMethod shippingMethod = (ShippingMethod) iterator.next();
         
          Iterator<?> shippingMethodRegions = shippingMethod.getShippingMethodRegions().iterator();
          boolean found = false;
          boolean doNotShip = false;
          while (shippingMethodRegions.hasNext()) {
            ShippingMethodRegion shippingMethodRegion = (ShippingMethodRegion) shippingMethodRegions.next();
            Long shippingRegionId = shippingMethodRegion.getShippingRegion().getShippingRegionId();
View Full Code Here

    Vector<?> shippingMethods = getShippingMethods();
      if (shippingMethod != null) {
        Enumeration<?> enumeration = shippingMethods.elements();
        boolean found = false;
        while (enumeration.hasMoreElements()) {
          ShippingMethod sm = (ShippingMethod) enumeration.nextElement();
          if (sm.getShippingMethodId().equals(shippingMethod.getShippingMethodId())) {
            found = true;
            break;
          }
        }
        // This shipping method is no longer valid, customer might have changed address.
        if (!found) {
            logger.debug("Invalidating shipping method");
          shippingMethod = null;
        }
      }
      // New order or the shipping method just got invalidated.  Extract from list as default.  Use the cheapest shipping method for better customer experience.
      if (shippingMethod == null) {
        if (shippingMethods.size() > 0) {
          Iterator<?> iterator = shippingMethods.iterator();
          float lowestTotal = Float.MAX_VALUE;
          while (iterator.hasNext()) {
            ShippingMethod sm = (ShippingMethod) iterator.next();
            float tmpTotal = calculateShippingTotal(sm);
            if (lowestTotal > tmpTotal) {
              lowestTotal = tmpTotal;
              shippingMethod = sm;
            }
View Full Code Here

        shoppingCart.setShippingPickUp(true);
        shoppingCart.setShippingMethod(null);
      }
      else {
        shoppingCart.setShippingPickUp(false);
          ShippingMethod shippingMethod = null;
          if (shippingMethodId != null) {
            shippingMethod = ShippingMethodDAO.load(site.getSiteId(), Format.getLong(shippingMethodId));
          }
          shoppingCart.setShippingMethod(shippingMethod);
      }
View Full Code Here

TOP

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

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.