Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.ShippingMethodRegion


  private ShippingRate findRate(ShippingMethod shippingMethod, ShippingRegion shippingRegion, ShippingType shippingType, User user) throws Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    ShippingRate shippingRate = null;
    boolean foundRegion = false;
    boolean foundRegionType = false;
    ShippingMethodRegion shippingMethodRegion = null;
    for (ShippingMethodRegion smr : shippingMethod.getShippingMethodRegions()) {
      if (smr.getShippingRegion().getShippingRegionId() != shippingRegion.getShippingRegionId()) {
        continue;
      }
      shippingMethodRegion = smr;
      foundRegion = true;
      for (ShippingMethodRegionType shippingMethodRegionType : shippingMethodRegion.getShippingMethodRegionTypes()) {
        if (!shippingMethodRegionType.getShippingType().getShippingTypeId().equals(shippingType.getShippingTypeId())) {
          continue;
        }
        foundRegionType = true;
        shippingRate = shippingMethodRegionType.getShippingRate();
        return shippingRate;
      }
    }
    if (!foundRegion) {
      shippingMethodRegion = new ShippingMethodRegion();
      shippingMethodRegion.setPublished(Constants.VALUE_NO);
      shippingMethodRegion.setRecUpdateBy(user.getUserId());
      shippingMethodRegion.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      shippingMethodRegion.setRecCreateBy(user.getUserId());
      shippingMethodRegion.setRecCreateDatetime(new Date(System.currentTimeMillis()));
      shippingMethodRegion.setShippingRegion(shippingRegion);
      shippingMethodRegion.setShippingMethod(shippingMethod);
        em.persist(shippingMethodRegion);
        shippingMethod.getShippingMethodRegions().add(shippingMethodRegion);
    }
    if (!foundRegionType) {
        ShippingMethodRegionType shippingMethodRegionType = new ShippingMethodRegionType();
        shippingMethodRegionType.setPublished(Constants.VALUE_NO);
        shippingMethodRegionType.setRecUpdateBy(user.getUserId());
        shippingMethodRegionType.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        shippingMethodRegionType.setRecCreateBy(user.getUserId());
        shippingMethodRegionType.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        shippingMethodRegionType.setShippingMethod(shippingMethod);
        shippingMethodRegionType.setShippingMethodRegion(shippingMethodRegion);
        shippingMethodRegionType.setShippingRegion(shippingRegion);
        shippingMethodRegionType.setShippingType(shippingType);
        em.persist(shippingMethodRegionType);
        shippingMethodRegion.getShippingMethodRegionTypes().add(shippingMethodRegionType);
    }
    return null;
  }
View Full Code Here


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

          for (int i = 0; i < shippingRegionIds.length; i++) {
              ShippingRegion shippingRegion = new ShippingRegion();
              shippingRegion = ShippingRegionDAO.load(site.getSiteId(), Format.getLong(shippingRegionIds[i]));
              Iterator<?> iterator = shippingRegion.getShippingMethodRegions().iterator();
              while (iterator.hasNext()) {
                ShippingMethodRegion shippingMethodRegion = (ShippingMethodRegion) iterator.next();
                em.remove(shippingMethodRegion);
              }
              em.remove(shippingRegion);
          }
        }
View Full Code Here

public class ShippingMethodRegionDAO extends ShippingMethodRegion {
  private static final long serialVersionUID = 3113741951884384536L;

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

         
          Iterator<?> shippingMethodRegions = shippingMethod.getShippingMethodRegions().iterator();
          boolean found = false;
          boolean doNotShip = false;
          while (shippingMethodRegions.hasNext()) {
            ShippingMethodRegion shippingMethodRegion = (ShippingMethodRegion) shippingMethodRegions.next();
            Long shippingRegionId = shippingMethodRegion.getShippingRegion().getShippingRegionId();
            Iterator<ShippingRegion> matchedRegionIterator = matchedRegion.iterator();
           
            while (matchedRegionIterator.hasNext()) {
              ShippingRegion matchedShippingRegion = (ShippingRegion) matchedRegionIterator.next();
              if (!matchedShippingRegion.getShippingRegionId().equals(shippingRegionId)) {
                continue;
              }
              found = true;
              if (shippingMethodRegion.getPublished() == Constants.VALUE_NO) {
                doNotShip = true;
                break;
              }
            }
            if (doNotShip) {
View Full Code Here

  }
 
  private float calculateShippingTotal(ShippingMethod shippingMethod) {
    CustomerAddress address = getEffectiveShippingAddress();
      Iterator<?> iterator = shippingMethod.getShippingMethodRegions().iterator();
      ShippingMethodRegion shippingMethodRegion = null;
      boolean found = false;
      while (iterator.hasNext() && !found) {
        ShippingMethodRegion smRegion = (ShippingMethodRegion) iterator.next();
        if (smRegion.getPublished() == Constants.PUBLISHED_NO) {
          continue;
        }
        if (smRegion.getShippingRegion().getPublished() == Constants.PUBLISHED_NO) {
          continue;
        }
        if (smRegion.getShippingRegion().getSystemRecord() == Constants.VALUE_YES) {
          shippingMethodRegion = smRegion;
        }
        Iterator<?> countries = smRegion.getShippingRegion().getCountries().iterator();
        while (countries.hasNext()) {
          Country country = (Country) countries.next();
          if (country.getCountryId().equals(address.getCountry().getCountryId())) {
            shippingMethodRegion = smRegion;
            found = true;
            break;
          }
        }
        if (!found) {
            Iterator<?> states = smRegion.getShippingRegion().getStates().iterator();
            while (states.hasNext()) {
              State state = (State) states.next();
              if (state.getStateId().equals(address.getState().getStateId())) {
                shippingMethodRegion = smRegion;
                found = true;
                break;
              }
            }
        }
          String zipCode = address.getCustZipCode();
          if (!found && !Format.isNullOrEmpty(zipCode)) {
            for (ShippingRegionZip shippingRegionZip : smRegion.getShippingRegion().getZipCodes()) {
              if (shippingRegionZip.getZipCodeExpression() == Constants.VALUE_YES) {
                if (zipCode.matches(shippingRegionZip.getZipCodeStart())) {
                    shippingMethodRegion = smRegion;
                  found = true;
                  break;
View Full Code Here

TOP

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

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.