Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.Customer


            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Customer customer = CustomerDAO.load(siteId, getCustomer(request).getCustId());
   
    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());
View Full Code Here


            HttpServletResponse response)
        throws Throwable {
      MyAccountAddressActionForm form = (MyAccountAddressActionForm) actionForm;
      init(request, form);
      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;
      }
    }
View Full Code Here

      initSearchInfo(form, siteId);
            ActionForward actionForward = actionMapping.findForward("error");
            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()));
        em.persist(customer);
        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
    messages.add("message", new ActionMessage("content.text.information.updated"));
    saveMessages(request, messages)

      init(request, form);
    initSearchInfo(form, siteId);
View Full Code Here

      query = em.createQuery(sql);
      query.setParameter("siteId", site.getSiteId());
      CustomerClass customerClass = (CustomerClass) query.getSingleResult();

     
      Customer customer = new Customer();
      customer.setSite(site);
    if (singleCheckout == Constants.VALUE_YES) {
      SiteDomain siteDomain = (SiteDomain) em.find(SiteDomain.class, defaultSiteDomainId);
      customer.setSiteDomain(siteDomain);
    }
    else {
      customer.setSiteDomain(contentBean.getSiteDomain());
    }
      customer.setCustPublicName(form.getCustPublicName());
      customer.setCustEmail(form.getCustEmail1());
      customer.setCustPassword(AESEncoder.getInstance().encode(form.getCustPassword()));
      customer.setCustSource(Constants.CUSTOMER_SOURCE_REGISTER);
      customer.setCustSourceRef("");
      customer.setActive(Constants.ACTIVE_YES);
        customer.setRecUpdateBy(Constants.USERNAME_CUSTOMER);
        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());
    form.setCustPassword("");
    form.setCustPassword1("");
    messages.add("message", new ActionMessage("content.text.information.updated"));
    saveMessages(request, messages)
View Full Code Here

            HttpServletResponse response)
        throws Throwable {
      MyAccountPaymentActionForm form = (MyAccountPaymentActionForm) actionForm;
      init(request, form);
      ActionForward actionForward = actionMapping.findForward("success");
      Customer customer = getCustomer(request);
    String siteId = getContentBean(request).getContentSessionKey().getSiteId();

    CustomerCreditCard custCreditCard = null;
      customer = CustomerDAO.load(siteId, customer.getCustId());
      Iterator<?> iterator = customer.getCustCreditCards().iterator();
      if (iterator.hasNext()) {
        custCreditCard = (CustomerCreditCard) iterator.next();
      }
     
      if (custCreditCard != null) {
View Full Code Here

            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
      }
     
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Customer customer = CustomerDAO.load(siteId, getCustomer(request).getCustId());
    CustomerCreditCard customerCreditCard = null;
      Iterator<?> iterator = customer.getCustCreditCards().iterator();
    boolean found = false;
    if (iterator.hasNext()) {
      found = true;
      customerCreditCard = (CustomerCreditCard) iterator.next();
      customerCreditCard.setRecCreateBy(Constants.USERNAME_SYSTEM);
      customerCreditCard.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    else {
      customerCreditCard = new CustomerCreditCard();
      customerCreditCard.setRecUpdateBy(Constants.USERNAME_SYSTEM);
      customerCreditCard.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
      customerCreditCard.setRecCreateBy(Constants.USERNAME_SYSTEM);
      customerCreditCard.setRecCreateDatetime(new Date(System.currentTimeMillis()));
    }
    customerCreditCard.setCustCreditCardFullName(form.getCustCreditCardFullName());
    customerCreditCard.setCustCreditCardNum(AESEncoder.getInstance().encode(form.getCustCreditCardNum()));
    customerCreditCard.setCustCreditCardExpiryMonth(form.getCustCreditCardExpiryMonth());
    customerCreditCard.setCustCreditCardExpiryYear(form.getCustCreditCardExpiryYear());
    customerCreditCard.setCustCreditCardVerNum(form.getCustCreditCardVerNum());
    String creditCardId = form.getCreditCardId();
    CreditCard creditCard = (CreditCard) em.find(CreditCard.class, Format.getLong(creditCardId));
    customerCreditCard.setCreditCard(creditCard);
    if (customerCreditCard.getCustCreditCardId() == null) {
      em.persist(customerCreditCard);
    }
    if (!found) {
      customer.getCustCreditCards().add(customerCreditCard);
    }

      initSearchInfo(form, siteId);
    messages.add("message", new ActionMessage("content.text.information.updated"));
    saveMessages(request, messages)
View Full Code Here

          messages.add("msg", new ActionMessage("content.text.myaccount.forgot.successful"));
        }
      saveMessages(request, messages);
      }
     
      Customer customer = getCustomer(request);
      if (customer != null) {
        MyAccountLoginActionForm form = (MyAccountLoginActionForm) actionForm;
        mergeOrder(request, form, customer);
       
        String target = request.getParameter("target");
View Full Code Here

      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
       
        Customer customer = (Customer) list.get(0);
        String password = AESEncoder.getInstance().decode(customer.getCustPassword());
        if (!password.equals(form.getCustPassword())) {
          idSecurity.fail();
          form.setCustPassword("");
          messages.add("login", new ActionMessage("content.error.login.invalid"));
      saveMessages(request, messages);
            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        idSecurity.reset();
       
        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
        // to init in order to avoid lazy initialization.
        customer.getRecCreateDatetime();
        mergeOrder(request, form, customer);
       
        /*
        if (!Format.isNullOrEmpty(form.getUrl())) {
          response.sendRedirect(form.getUrl());
View Full Code Here

public class MyAccountPortalAction extends ContentLookupDispatchAction {
    Logger logger = Logger.getLogger(MyAccountLoginAction.class);
   
    public void init(HttpServletRequest request, MyAccountPortalActionForm form) throws Exception {
      Customer customer = getCustomer(request);
      form.setDisplayFirstName(customer.getCustAddress().getCustFirstName());
      form.setDisplayLastName(customer.getCustAddress().getCustLastName());
    }
View Full Code Here

        CustomerMaintActionForm form = (CustomerMaintActionForm) actionForm;
        if (form == null) {
            form = new CustomerMaintActionForm();
        }
    String custId = request.getParameter("custId");
        Customer customer = new Customer();
        customer = CustomerDAO.load(site.getSiteId(), Format.getLong(custId));
       
        copyProperties(form, customer);
        initSearchInfo(request, form, site.getSiteId(), customer);
View Full Code Here

TOP

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

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.