Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.CustomerAddress


    return address;
  }
 
  public Vector<?> getShippingMethods() throws Exception {
    Vector<ShippingMethod> shippingMethods = new Vector<ShippingMethod>();
    CustomerAddress address = getEffectiveShippingAddress();
    if (address == null) {
      return shippingMethods;
    }
   
    Long countryId = null;
    if (address.getCountry() != null) {
      countryId = address.getCountry().getCountryId();
    }
    Long stateId = null;
    if (address.getState() != null) {
      stateId = address.getState().getStateId();
    }
   
    Vector<ShippingRegion> matchedRegion = new Vector<ShippingRegion>();
   
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Query query = em.createQuery("from   ShippingRegion " +
                      "where  siteId = :siteId ");
    query.setParameter("siteId", contentSessionKey.getSiteId());
        Iterator<?> iterator = query.getResultList().iterator();
        ShippingRegion defaultRegion = null;
        while (iterator.hasNext()) {
          ShippingRegion shippingRegion = (ShippingRegion) iterator.next();
          if (shippingRegion.getPublished() == Constants.VALUE_NO) {
            continue;
          }
          if (shippingRegion.getSystemRecord() == Constants.VALUE_YES) {
          if (shippingRegion.getPublished() == Constants.VALUE_YES) {
            defaultRegion = shippingRegion;
            continue;
          }
        }
         
          boolean isFound = false;
        Iterator<?> countries = shippingRegion.getCountries().iterator();
        while (countries.hasNext()) {
          Country country = (Country) countries.next();
          if (country.getCountryId().equals(countryId)) {
            isFound = true;
          }
        }
        if (!isFound) {
            Iterator<?> states = shippingRegion.getStates().iterator();
            while (states.hasNext()) {
              State state = (State) states.next();
              if (state.getStateId().equals(stateId)) {
                isFound = true;
              }
            }
        }
          String zipCode = address.getCustZipCode();
          if (!isFound && !Format.isNullOrEmpty(zipCode)) {
            for (ShippingRegionZip shippingRegionZip : shippingRegion.getZipCodes()) {
              if (shippingRegionZip.getZipCodeExpression() == Constants.VALUE_YES) {
                if (zipCode.matches(shippingRegionZip.getZipCodeStart())) {
                  isFound = true;
View Full Code Here


        }
        shippingOrderTotal = shippingTotal - shippingDiscountTotal;
  }
 
  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;
View Full Code Here

        customer.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        customer.setRecCreateBy(Constants.USERNAME_CUSTOMER);
        customer.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        customer.setCustomerClass(customerClass);
       
        CustomerAddress customerAddress = shoppingCart.getEstimateAddress();
        if (customerAddress == null) {
          customerAddress = new CustomerAddress();
        }
        customer.setCustAddress(customerAddress);
        customer.getCustAddresses().add(customerAddress);
        customerAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
        customerAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
        customerAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        customerAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        customerAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
        customerAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        em.persist(customerAddress);

        em.persist(customer);
        em.flush();
       
View Full Code Here

TOP

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

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.