Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.CustomerAddress


  public CustomerDAO(Customer customer) {
    this.custId = customer.getCustId();
    this.custEmail = customer.getCustEmail();
    this.custSource = customer.getCustSource();
    this.custSourceRef = customer.getCustSourceRef();
    CustomerAddress customerAddress = null;
      for (CustomerAddress address : customer.getCustAddresses()) {
        if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_CUST)) {
          customerAddress = address;
          break;
        }
      }
    this.custFirstName = customerAddress.getCustFirstName();
    this.custMiddleName = customerAddress.getCustMiddleName();
    this.custLastName = customerAddress.getCustLastName();
  }
View Full Code Here


    }
    else {
      customer.setSiteDomain(contentBean.getSiteDomain());
    }
     
        CustomerAddress 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_SYSTEM);
        customerAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        customerAddress.setRecCreateBy(Constants.USERNAME_SYSTEM);
        customerAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        em.persist(customerAddress);
       
      em.persist(customer);
     
      setCustId(request, customer.getCustId());
View Full Code Here

    String emailAddress = payer.getPayer().trim();
   
        EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();

        Customer customer = null;
        CustomerAddress customerAddress = null;
        CustomerAddress billingAddress = null;
        CustomerAddress shippingAddress = null;

        String sql = "from Customer customer where custEmail = :custEmail";
        Query query = em.createQuery(sql);
        query.setParameter("custEmail", emailAddress);
        List<?> list = query.getResultList();
        if (list.size() > 0) {
          customer = (Customer) list.iterator().next();
          if (!customer.getActive().equals(Constants.VALUE_YES)) {
            throw new PaymentCustomerException("Customer suspended");
          }
        }
       
        if (customer == null) {
          customer = new Customer();
        CustomerClass customerClass = (CustomerClass) em.find(CustomerClass.class, payPalExpressCheckOut.getPaymentPaypalCustClassId());
        customer.setCustomerClass(customerClass);
          customer.setActive(Constants.VALUE_YES);
            customer.setRecCreateBy(Constants.USERNAME_CUSTOMER);
            customer.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        }
        else {
          customerAddress = customer.getCustAddress();
          for (CustomerAddress address : customer.getCustAddresses()) {
            if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_BILLING)) {
              billingAddress = address;
              continue;
            }
            if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_SHIPPING)) {
              shippingAddress = address;
              continue;
            }
          }
        }
       
        if (customerAddress == null) {
          customerAddress = new CustomerAddress();
          customerAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
          customerAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
          customerAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
          customerAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            customer.getCustAddresses().add(customerAddress);
            customer.setCustAddress(customerAddress);
        }
        if (billingAddress == null) {
            billingAddress = new CustomerAddress();
            billingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
            billingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
            billingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
            billingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            customer.getCustAddresses().add(billingAddress);
        }
        if (shippingAddress == null) {
            shippingAddress = new CustomerAddress();
            shippingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_SHIPPING);
            shippingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
            shippingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
            shippingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            customer.getCustAddresses().add(shippingAddress);
        }
       
        billingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
        billingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
        billingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        billingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        shoppingCart.setBillingAddress(billingAddress);
        if (billingAddress.getCustAddressId() == null) {
          em.persist(billingAddress);
        }
        shippingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_CUST);
        shippingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_SHIPPING);
        shippingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        shippingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        shoppingCart.setShippingAddress(shippingAddress);
        if (shippingAddress.getCustAddressId() == null) {
          em.persist(shippingAddress);
        }
       
        String stateName = Format.getString(payer.getAddress().getStateOrProvince());
        State state = Utility.getStateByNameOrCode(site.getSiteId(), stateName);
View Full Code Here

      ActionForward actionForward = actionMapping.findForward("success");
      Customer customer = getCustomer(request);
    String siteId = getContentBean(request).getContentSessionKey().getSiteId();

      customer = CustomerDAO.load(siteId, customer.getCustId());
      CustomerAddress billingAddress = getBillingAddress(customer);
      if (billingAddress != null) {
        form.setBillingCustPrefix(billingAddress.getCustPrefix());
        form.setBillingCustFirstName(billingAddress.getCustFirstName());
        form.setBillingCustMiddleName(billingAddress.getCustMiddleName());
        form.setBillingCustLastName(billingAddress.getCustLastName());
        form.setBillingCustSuffix(billingAddress.getCustSuffix());
        form.setBillingCustAddressLine1(billingAddress.getCustAddressLine1());
        form.setBillingCustAddressLine2(billingAddress.getCustAddressLine2());
        form.setBillingCustCityName(billingAddress.getCustCityName());
        form.setBillingCustStateCode(billingAddress.getCustStateCode());
        form.setBillingCustCountryCode(billingAddress.getCustCountryCode());
        form.setBillingCustZipCode(billingAddress.getCustZipCode());
        form.setBillingCustPhoneNum(billingAddress.getCustPhoneNum());
        form.setBillingCustFaxNum(billingAddress.getCustFaxNum());
      }
      CustomerAddress shippingAddress = getShippingAddress(customer);
      if (shippingAddress != null) {
        form.setShippingCustPrefix(shippingAddress.getCustPrefix());
        form.setShippingCustFirstName(shippingAddress.getCustFirstName());
        form.setShippingCustMiddleName(shippingAddress.getCustMiddleName());
        form.setShippingCustLastName(shippingAddress.getCustLastName());
        form.setShippingCustSuffix(shippingAddress.getCustSuffix());
        form.setShippingCustAddressLine1(shippingAddress.getCustAddressLine1());
        form.setShippingCustAddressLine2(shippingAddress.getCustAddressLine2());
        form.setShippingCustCityName(shippingAddress.getCustCityName());
        form.setShippingCustStateCode(shippingAddress.getCustStateCode());
        form.setShippingCustCountryCode(shippingAddress.getCustCountryCode());
        form.setShippingCustZipCode(shippingAddress.getCustZipCode());
        form.setShippingCustPhoneNum(shippingAddress.getCustPhoneNum());
        form.setShippingCustFaxNum(shippingAddress.getCustFaxNum());
      }
      else {
        form.setUseBilling(true);
      }
      initSearchInfo(form, siteId);
View Full Code Here

      ActionForward actionForward = actionMapping.findForward("success");
      Customer customer = getCustomer(request);
    String siteId = getContentBean(request).getContentSessionKey().getSiteId();
      customer = CustomerDAO.load(siteId, customer.getCustId());
     
    CustomerAddress custAddress = customer.getCustAddress();
    if (custAddress != null) {
      form.setCustFirstName(custAddress.getCustFirstName());
      form.setCustMiddleName(custAddress.getCustMiddleName());
      form.setCustLastName(custAddress.getCustLastName());
      form.setCustAddressLine1(custAddress.getCustAddressLine1());
      form.setCustAddressLine2(custAddress.getCustAddressLine2());
      form.setCustCityName(custAddress.getCustCityName());
      form.setCustStateCode(custAddress.getCustStateCode());
      form.setCustStateName(custAddress.getCustStateName());
      form.setCustCountryCode(custAddress.getCustCountryCode());
      form.setCustCountryName(custAddress.getCustCountryName());
      form.setCustZipCode(custAddress.getCustZipCode());
      form.setCustPhoneNum(custAddress.getCustPhoneNum());
      form.setCustFaxNum(custAddress.getCustFaxNum());
      if (!Format.isNullOrEmpty(custAddress.getCustStateCode())) {
        form.setCustStateName(Utility.getStateName(siteId, custAddress.getCustStateCode()));
      }
      else {
        form.setCustStateName(custAddress.getCustStateName());
      }
      if (!Format.isNullOrEmpty(custAddress.getCustCountryCode())) {
        form.setCustCountryName(Utility.getCountryName(siteId, custAddress.getCustCountryCode()));
      }
    }
   
    CustomerAddress billingAddress = null;
    for (CustomerAddress address : customer.getCustAddresses()) {
      if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_BILLING)) {
        billingAddress = address;
        break;
      }
    }
    if (billingAddress != null) {
      form.setBillingCustAddressId(Format.getLong(billingAddress.getCustAddressId()));
      form.setBillingCustFirstName(billingAddress.getCustFirstName());
      form.setBillingCustMiddleName(billingAddress.getCustMiddleName());
      form.setBillingCustLastName(billingAddress.getCustLastName());
      form.setBillingCustAddressLine1(billingAddress.getCustAddressLine1());
      form.setBillingCustAddressLine2(billingAddress.getCustAddressLine2());
      form.setBillingCustCityName(billingAddress.getCustCityName());
      form.setBillingCustStateCode(billingAddress.getCustStateCode());
      form.setBillingCustCountryCode(billingAddress.getCustCountryCode());
      form.setBillingCustZipCode(billingAddress.getCustZipCode());
      form.setBillingCustPhoneNum(billingAddress.getCustPhoneNum());
      form.setBillingCustFaxNum(billingAddress.getCustFaxNum());
      form.setBillingUseAddress(billingAddress.getCustUseAddress());
      if (!Format.isNullOrEmpty(billingAddress.getCustStateCode())) {
        form.setBillingCustStateName(Utility.getStateName(siteId, billingAddress.getCustStateCode()));
      }
      else {
        form.setBillingCustStateName(billingAddress.getCustStateName());
      }
      if (!Format.isNullOrEmpty(billingAddress.getCustCountryCode())) {
        form.setBillingCustCountryName(Utility.getCountryName(siteId, billingAddress.getCustCountryCode()));
      }
    }
    else {
      form.setBillingUseAddress(Constants.CUST_ADDRESS_USE_CUST);
    }
   
    CustomerAddress shippingAddress = null;
    for (CustomerAddress address : customer.getCustAddresses()) {
      if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_SHIPPING)) {
        shippingAddress = address;
        break;
      }
    }
    if (shippingAddress != null) {
      form.setShippingCustAddressId(Format.getLong(shippingAddress.getCustAddressId()));
      form.setShippingCustFirstName(shippingAddress.getCustFirstName());
      form.setShippingCustMiddleName(shippingAddress.getCustMiddleName());
      form.setShippingCustLastName(shippingAddress.getCustLastName());
      form.setShippingCustAddressLine1(shippingAddress.getCustAddressLine1());
      form.setShippingCustAddressLine2(shippingAddress.getCustAddressLine2());
      form.setShippingCustCityName(shippingAddress.getCustCityName());
      form.setShippingCustStateCode(shippingAddress.getCustStateCode());
      form.setShippingCustCountryCode(shippingAddress.getCustCountryCode());
      form.setShippingCustZipCode(shippingAddress.getCustZipCode());
      form.setShippingCustPhoneNum(shippingAddress.getCustPhoneNum());
      form.setShippingCustFaxNum(shippingAddress.getCustFaxNum());
      form.setShippingUseAddress(shippingAddress.getCustUseAddress());
      if (!Format.isNullOrEmpty(shippingAddress.getCustStateCode())) {
        form.setShippingCustStateName(Utility.getStateName(siteId, shippingAddress.getCustStateCode()));
      }
      else {
        form.setShippingCustStateName(shippingAddress.getCustStateName());
      }
      if (!Format.isNullOrEmpty(shippingAddress.getCustCountryCode())) {
        form.setShippingCustCountryName(Utility.getCountryName(siteId, shippingAddress.getCustCountryCode()));
      }
    }
    else {
      form.setShippingUseAddress(Constants.CUST_ADDRESS_USE_CUST);
    }
View Full Code Here

   
    customer.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
    customer.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    em.persist(customer);
   
      CustomerAddress billingAddress = getBillingAddress(customer);
      if (billingAddress == null) {
        billingAddress = new CustomerAddress();
        billingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
        billingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        customer.getCustAddresses().add(billingAddress);
      }
      billingAddress.setCustPrefix(form.getBillingCustPrefix());
      billingAddress.setCustFirstName(form.getBillingCustFirstName());
      billingAddress.setCustMiddleName(form.getBillingCustMiddleName());
      billingAddress.setCustLastName(form.getBillingCustLastName());
      billingAddress.setCustSuffix(form.getBillingCustSuffix());
      billingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
      billingAddress.setCustAddressLine1(form.getBillingCustAddressLine1());
      billingAddress.setCustAddressLine2(form.getBillingCustAddressLine2());
      billingAddress.setCustCityName(form.getBillingCustCityName());
      billingAddress.setCustStateCode(form.getBillingCustStateCode());
      billingAddress.setCustStateName(Utility.getStateName(siteId, form.getBillingCustStateCode()));
      billingAddress.setCustCountryCode(form.getBillingCustCountryCode());
      billingAddress.setCustCountryName(Utility.getCountryName(siteId, form.getBillingCustCountryCode()));
      billingAddress.setCustZipCode(form.getBillingCustZipCode());
      billingAddress.setCustPhoneNum(form.getBillingCustPhoneNum());
    billingAddress.setCustFaxNum(form.getBillingCustPhoneNum());
    billingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
    billingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    if (billingAddress.getCustAddressId() == null) {
      em.persist(billingAddress);
    }
   
      CustomerAddress shippingAddress = getShippingAddress(customer);
      if (form.isUseBilling()) {
        if (shippingAddress != null) {
          customer.getCustAddresses().remove(shippingAddress);
          em.remove(shippingAddress);
        }
      }
      else {
          if (shippingAddress == null) {
            shippingAddress = new CustomerAddress();
            shippingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
            shippingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
            customer.getCustAddresses().add(shippingAddress);
          }
          shippingAddress.setCustPrefix(form.getShippingCustPrefix());
          shippingAddress.setCustFirstName(form.getShippingCustFirstName());
          shippingAddress.setCustMiddleName(form.getShippingCustMiddleName());
          shippingAddress.setCustLastName(form.getShippingCustLastName());
          shippingAddress.setCustSuffix(form.getShippingCustSuffix());
          shippingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
          shippingAddress.setCustAddressLine1(form.getShippingCustAddressLine1());
          shippingAddress.setCustAddressLine2(form.getShippingCustAddressLine2());
          shippingAddress.setCustCityName(form.getShippingCustCityName());
          shippingAddress.setCustStateCode(form.getShippingCustStateCode());
          shippingAddress.setCustStateName(Utility.getStateName(siteId, form.getShippingCustStateCode()));
          shippingAddress.setCustCountryCode(form.getShippingCustCountryCode());
          shippingAddress.setCustCountryName(Utility.getCountryName(siteId, form.getShippingCustCountryCode()));
          shippingAddress.setCustZipCode(form.getShippingCustZipCode());
          shippingAddress.setCustPhoneNum(form.getShippingCustPhoneNum());
        shippingAddress.setCustFaxNum(form.getShippingCustPhoneNum());
        shippingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        shippingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        if (shippingAddress.getCustAddressId() == null) {
          em.persist(shippingAddress);
        }
      }
      initSearchInfo(form, siteId);
    messages.add("message", new ActionMessage("message.information.updated"));
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 = 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_SYSTEM);
        customerAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        customerAddress.setRecCreateBy(Constants.USERNAME_SYSTEM);
        customerAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
        em.persist(customerAddress);
            
        em.persist(customer);

        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
View Full Code Here

        return actionForward;
    }
   
    public CustomerAddress getShippingAddress(Customer customer) {
      Iterator<?> iterator = customer.getCustAddresses().iterator();
      CustomerAddress address = null;
      while (iterator.hasNext()) {
        address = (CustomerAddress) iterator.next();
        if (!address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_SHIPPING)) {
          continue;
        }
      }
      return address;
    }
View Full Code Here

            return actionForward;
      }
     
    Customer customer = CustomerDAO.load(siteId, getCustomer(request).getCustId());
       
        CustomerAddress custAddress = customer.getCustAddress();
    if (custAddress == null) {
      custAddress = new CustomerAddress();
      customer.setCustAddress(custAddress);
      custAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
      customer.getCustAddresses().add(custAddress);
      custAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
      custAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    custAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
    custAddress.setCustFirstName(form.getCustFirstName());
    custAddress.setCustMiddleName(form.getCustMiddleName());
    custAddress.setCustLastName(form.getCustLastName());
    custAddress.setCustSuffix(form.getCustSuffix());
    custAddress.setCustAddressLine1(form.getCustAddressLine1());
    custAddress.setCustAddressLine2(form.getCustAddressLine2());
    custAddress.setCustCityName(form.getCustCityName());
    if (Format.isNullOrEmpty(form.getCustStateName())) {
      custAddress.setCustStateCode(form.getCustStateCode());
      custAddress.setCustStateName(Utility.getStateName(siteId, form.getCustStateCode()));
    }
    else {
      custAddress.setCustStateCode("");
      custAddress.setCustStateName(form.getCustStateName());
    }
    custAddress.setCustCountryCode(form.getCustCountryCode());
    custAddress.setCustCountryName(Utility.getCountryName(siteId, form.getCustCountryCode()));
    custAddress.setCustZipCode(form.getCustZipCode());
    custAddress.setCustPhoneNum(form.getCustPhoneNum());
    custAddress.setCustFaxNum(form.getCustFaxNum());
    custAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
    custAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    custAddress.setState(StateDAO.loadByStateCode(siteId, form.getCustStateCode()));
    custAddress.setCountry(CountryDAO.loadByCountryCode(siteId, form.getCustCountryCode()));
    custAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
    custAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    if (custAddress.getCustAddressId() == null) {
      em.persist(custAddress);
    }
   
    CustomerAddress billingAddress = null;
    for (CustomerAddress address : customer.getCustAddresses()) {
      if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_BILLING)) {
        billingAddress = address;
        break;
      }
    }
    if (billingAddress == null) {
      billingAddress = new CustomerAddress();
      billingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
      customer.getCustAddresses().add(billingAddress);
      billingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
      billingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    billingAddress.setCustUseAddress(form.getBillingUseAddress());
    if (form.billingUseAddress.equals(Constants.CUST_ADDRESS_USE_OWN)) {
      billingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
      billingAddress.setCustPrefix(form.getBillingCustPrefix());
      billingAddress.setCustFirstName(form.getBillingCustFirstName());
      billingAddress.setCustMiddleName(form.getBillingCustMiddleName());
      billingAddress.setCustLastName(form.getBillingCustLastName());
      billingAddress.setCustSuffix(form.getBillingCustSuffix());
      billingAddress.setCustAddressLine1(form.getBillingCustAddressLine1());
      billingAddress.setCustAddressLine2(form.getBillingCustAddressLine2());
      billingAddress.setCustCityName(form.getBillingCustCityName());
      if (Format.isNullOrEmpty(form.getBillingCustStateName())) {
        billingAddress.setCustStateCode(form.getBillingCustStateCode());
        billingAddress.setCustStateName(Utility.getStateName(siteId, form.getBillingCustStateCode()));
      }
      else {
        billingAddress.setCustStateCode("");
        billingAddress.setCustStateName(form.getBillingCustStateName());
      }
      billingAddress.setCustCountryCode(form.getBillingCustCountryCode());
      billingAddress.setCustCountryName(Utility.getCountryName(siteId, form.getBillingCustCountryCode()));
      billingAddress.setCustZipCode(form.getBillingCustZipCode());
      billingAddress.setCustPhoneNum(form.getBillingCustPhoneNum());
      billingAddress.setCustFaxNum(form.getBillingCustFaxNum());
      billingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
      billingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      billingAddress.setState(StateDAO.loadByStateCode(siteId, form.getBillingCustStateCode()));
      billingAddress.setCountry(CountryDAO.loadByCountryCode(siteId, form.getBillingCustCountryCode()));
    }
    billingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
    billingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    if (billingAddress.getCustAddressId() == null) {
      em.persist(billingAddress);
    }
   
    CustomerAddress shippingAddress = null;
    for (CustomerAddress address : customer.getCustAddresses()) {
      if (address.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_SHIPPING)) {
        shippingAddress = address;
        break;
      }
    }
    if (shippingAddress == null) {
      shippingAddress = new CustomerAddress();
      shippingAddress.setCustAddressType(Constants.CUSTOMER_ADDRESS_SHIPPING);
      customer.getCustAddresses().add(shippingAddress);
      shippingAddress.setRecCreateBy(Constants.USERNAME_CUSTOMER);
      shippingAddress.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    shippingAddress.setCustUseAddress(form.getShippingUseAddress());
    if (form.shippingUseAddress.equals(Constants.CUST_ADDRESS_USE_OWN)) {
      shippingAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
      shippingAddress.setCustPrefix(form.getShippingCustPrefix());
      shippingAddress.setCustFirstName(form.getShippingCustFirstName());
      shippingAddress.setCustMiddleName(form.getShippingCustMiddleName());
      shippingAddress.setCustLastName(form.getShippingCustLastName());
      shippingAddress.setCustSuffix(form.getShippingCustSuffix());
      shippingAddress.setCustAddressLine1(form.getShippingCustAddressLine1());
      shippingAddress.setCustAddressLine2(form.getShippingCustAddressLine2());
      shippingAddress.setCustCityName(form.getShippingCustCityName());
      if (Format.isNullOrEmpty(form.getShippingCustStateName())) {
        shippingAddress.setCustStateCode(form.getShippingCustStateCode());
        shippingAddress.setCustStateName(Utility.getStateName(siteId, form.getShippingCustStateCode()));
      }
      else {
        shippingAddress.setCustStateCode("");
        shippingAddress.setCustStateName(form.getShippingCustStateName());
      }
      shippingAddress.setCustCountryCode(form.getShippingCustCountryCode());
      shippingAddress.setCustCountryName(Utility.getCountryName(siteId, form.getShippingCustCountryCode()));
      shippingAddress.setCustZipCode(form.getShippingCustZipCode());
      shippingAddress.setCustPhoneNum(form.getShippingCustPhoneNum());
      shippingAddress.setCustFaxNum(form.getShippingCustFaxNum());
      shippingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
      shippingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      shippingAddress.setState(StateDAO.loadByStateCode(siteId, form.getShippingCustStateCode()));
      shippingAddress.setCountry(CountryDAO.loadByCountryCode(siteId, form.getShippingCustCountryCode()));
    }
    shippingAddress.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
    shippingAddress.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    if (shippingAddress.getCustAddressId() == null) {
      em.persist(shippingAddress);
    }
   
        customer.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        customer.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
View Full Code Here

    customer.setActive(Constants.VALUE_NO);
    if (!Format.isNullOrEmpty(form.getActive())) {
      customer.setActive(form.getActive().equals("Y") ? Constants.VALUE_YES : Constants.VALUE_NO);
    }
   
    CustomerAddress address = customer.getCustAddress();
    if (address == null) {
      address = new CustomerAddress();
      customer.setCustAddress(address);
      customer.getCustAddresses().add(address);
          address.setRecCreateBy(adminBean.getUserId());
          address.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    address.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
    address.setCustAddressType(Constants.CUSTOMER_ADDRESS_CUST);
      address.setCustPrefix(form.getCustPrefix());
      address.setCustLastName(form.getCustLastName());
      address.setCustMiddleName(form.getCustMiddleName());
      address.setCustFirstName(form.getCustFirstName());
      address.setCustSuffix(form.getCustSuffix());
      address.setCustPhoneNum(form.getCustPhoneNum());
      address.setCustFaxNum(form.getCustFaxNum());
      address.setCustAddressLine1(form.getCustAddressLine1());
      address.setCustAddressLine2(form.getCustAddressLine2());
      address.setCustStateCode(form.getCustStateCode());
      address.setCustStateName("");
      if (Format.isNullOrEmpty(form.getCustStateCode())) {
        address.setCustStateName(Utility.getStateName(adminBean.getSiteId(), form.getCustStateCode()));
      }
      address.setCustCountryCode(form.getCustCountryCode());
      address.setCustCountryName("");
      if (Format.isNullOrEmpty(form.getCustCountryCode())) {
        address.setCustCountryName(Utility.getCountryName(adminBean.getSiteId(), form.getCustCountryCode()));
      }
      address.setCustZipCode(form.getCustZipCode());
        address.setRecUpdateBy(adminBean.getUserId());
        address.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(address);

    address = null;
    for (CustomerAddress a : customer.getCustAddresses()) {
      if (a.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_BILLING)) {
        address = a;
      }
    }
    if (address == null) {
      address = new CustomerAddress();
      customer.getCustAddresses().add(address);
          address.setRecCreateBy(adminBean.getUserId());
          address.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    address.setCustUseAddress(form.getBillingCustUseAddress());
    address.setCustAddressType(Constants.CUSTOMER_ADDRESS_BILLING);
      address.setCustPrefix(form.getBillingCustPrefix());
      address.setCustLastName(form.getBillingCustLastName());
      address.setCustMiddleName(form.getBillingCustMiddleName());
      address.setCustFirstName(form.getBillingCustFirstName());
      address.setCustSuffix(form.getBillingCustSuffix());
      address.setCustPhoneNum(form.getBillingCustPhoneNum());
      address.setCustFaxNum(form.getBillingCustFaxNum());
      address.setCustAddressLine1(form.getBillingCustAddressLine1());
      address.setCustAddressLine2(form.getBillingCustAddressLine2());
      address.setCustStateCode(form.getBillingCustStateCode());
      address.setCustStateName("");
      if (!Format.isNullOrEmpty(form.getBillingCustStateCode())) {
        address.setCustStateName(Utility.getStateName(adminBean.getSiteId(), form.getBillingCustStateCode()));
      }
      address.setCustCountryCode(form.getBillingCustCountryCode());
      address.setCustCountryName("");
      if (!Format.isNullOrEmpty(form.getBillingCustCountryCode())) {
        address.setCustCountryName(Utility.getCountryName(adminBean.getSiteId(), form.getBillingCustCountryCode()));
      }
      address.setCustZipCode(form.getBillingCustZipCode());
        address.setRecUpdateBy(adminBean.getUserId());
        address.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(address);
   
    address = null;
    for (CustomerAddress a : customer.getCustAddresses()) {
      if (a.getCustAddressType().equals(Constants.CUSTOMER_ADDRESS_SHIPPING)) {
        address = a;
      }
    }
    if (address == null) {
      address = new CustomerAddress();
      customer.getCustAddresses().add(address);
          address.setRecCreateBy(adminBean.getUserId());
          address.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    address.setCustUseAddress(form.getShippingCustUseAddress());
    address.setCustAddressType(Constants.CUSTOMER_ADDRESS_SHIPPING);
      address.setCustPrefix(form.getShippingCustPrefix());
      address.setCustLastName(form.getShippingCustLastName());
      address.setCustMiddleName(form.getShippingCustMiddleName());
      address.setCustFirstName(form.getShippingCustFirstName());
      address.setCustSuffix(form.getShippingCustSuffix());
      address.setCustPhoneNum(form.getShippingCustPhoneNum());
      address.setCustFaxNum(form.getShippingCustFaxNum());
      address.setCustAddressLine1(form.getShippingCustAddressLine1());
      address.setCustAddressLine2(form.getShippingCustAddressLine2());
      address.setCustStateCode(form.getShippingCustStateCode());
      address.setCustStateName("");
      if (!Format.isNullOrEmpty(form.getShippingCustStateCode())) {
        address.setCustStateName(Utility.getStateName(adminBean.getSiteId(), form.getShippingCustStateCode()));
      }
      address.setCustCountryCode(form.getShippingCustCountryCode());
      address.setCustCountryName("");
      if (!Format.isNullOrEmpty(form.getShippingCustCountryCode())) {
        address.setCustCountryName(Utility.getCountryName(adminBean.getSiteId(), form.getShippingCustCountryCode()));
      }
      address.setCustZipCode(form.getShippingCustZipCode());
        address.setRecUpdateBy(adminBean.getUserId());
        address.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
        em.persist(address);

    customer.setRecUpdateBy(adminBean.getUser().getUserId());
    customer.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
    if (!Format.isNullOrEmpty(form.getCustPassword())) {
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.