Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.Customer


    shoppingCart.initCustomer(customer, contentBean);
    }
   
    protected void saveCreditCard(ShoppingCartActionForm form, Site site, ShoppingCart shoppingCart, ContentBean contentBean) throws Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Customer customer = shoppingCart.getCustomer();
    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);
    }
    shoppingCart.setCustomerCreditCard(new CustomerCreditCardDAO(customerCreditCard));
    }
View Full Code Here


            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
      String commentId = request.getParameter("commentId");
      String alertType = request.getParameter("alertType");
    Customer customer = getCustomer(request);
    if (customer == null) {
        JSONEscapeObject jsonResult = new JSONEscapeObject();
      jsonResult.put("status", Constants.WEBSERVICE_STATUS_FAILED);
      MessageResources resources = this.getResources(request);
      jsonResult.put("message", resources.getMessage("error.content.signin"));
      String jsonString = jsonResult.toHtmlString();
      streamWebService(response, jsonString);
      return null;
    }
   
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    Comment comment = (Comment) em.find(Comment.class, Format.getLong(commentId));

      if (alertType.equals(Constants.ALERT_TYPE_MODERATOR)) {
        comment.setModeration(Constants.VALUE_YES);
        em.persist(comment);
      }
      else {
        Iterator<?> iterator = comment.getAgreeCustomers().iterator();
        while (iterator.hasNext()) {
          Customer c = (Customer) iterator.next();
          if (c.getCustId().equals(customer.getCustId())) {
            iterator.remove();
            break;
          }
        }
        iterator = comment.getDisagreeCustomers().iterator();
        while (iterator.hasNext()) {
          Customer c = (Customer) iterator.next();
          if (c.getCustId().equals(customer.getCustId())) {
            iterator.remove();
            break;
          }
        }
        if (alertType.equals(Constants.ALERT_TYPE_AGREE)) {
View Full Code Here

    Long custId = getCustId(request);
    if (custId == null) {
      return null;
    }
   
    Customer customer = (Customer) em.find(Customer.class, custId);
        return customer;
    }
View Full Code Here

    }
    else {
      orderHeader = new OrderHeader();
    }
   
    Customer customer = shoppingCart.getCustomer();
    if (customer != null) {
      OrderAddress custAddress = null;
      if (orderHeader.getCustAddress() != null) {
        custAddress = orderHeader.getCustAddress();
      }
      else {
        custAddress = new OrderAddress();
        custAddress.setRecCreateBy(Constants.USERNAME_SYSTEM);
        custAddress.setRecCreateDatetime(new Date());
      }
      CustomerAddress adddress = customer.getCustAddress();
      custAddress.setCustUseAddress(Constants.CUST_ADDRESS_USE_OWN);
      custAddress.setCustPrefix(adddress.getCustPrefix());
      custAddress.setCustFirstName(adddress.getCustFirstName());
      custAddress.setCustMiddleName(adddress.getCustMiddleName());
      custAddress.setCustLastName(adddress.getCustLastName());
      custAddress.setCustSuffix(adddress.getCustSuffix());
      custAddress.setCustAddressLine1(adddress.getCustAddressLine1());
      custAddress.setCustAddressLine2(adddress.getCustAddressLine2());
      custAddress.setCustCityName(adddress.getCustCityName());
      custAddress.setCustStateName(adddress.getCustStateName());
      custAddress.setCustStateCode(adddress.getCustStateCode());
      custAddress.setCustCountryName(adddress.getCustCountryName());
      custAddress.setCustCountryCode(adddress.getCustCountryCode());
      custAddress.setCustStateName(adddress.getCustStateName());
      custAddress.setCustZipCode(adddress.getCustZipCode());
      custAddress.setCustPhoneNum(adddress.getCustPhoneNum());
      custAddress.setCustFaxNum(adddress.getCustFaxNum());
      custAddress.setRecUpdateBy(Constants.USERNAME_SYSTEM);
      custAddress.setRecUpdateDatetime(new Date());
      Country country = CountryDAO.loadByCountryCode(siteId, adddress.getCustCountryCode());
      custAddress.setCountry(country);
      if (adddress.getCustStateCode() != null) {
        State state = StateDAO.loadByStateCode(siteId, adddress.getCustStateCode());
        custAddress.setState(state);
      }
      em.persist(custAddress);
      orderHeader.setCustAddress(custAddress);
    }
   
    CustomerAddress billingAddress = shoppingCart.getBillingAddress();
    if (billingAddress != null) {
      OrderAddress address = null;
      if (orderHeader.getBillingAddress() != null) {
        address = orderHeader.getBillingAddress();
      }
      else {
        address = new OrderAddress();
        address.setRecCreateBy(Constants.USERNAME_SYSTEM);
        address.setRecCreateDatetime(new Date());
      }
      address.setCustUseAddress(billingAddress.getCustUseAddress());
      address.setCustPrefix(billingAddress.getCustPrefix());
      address.setCustFirstName(billingAddress.getCustFirstName());
      address.setCustMiddleName(billingAddress.getCustMiddleName());
      address.setCustLastName(billingAddress.getCustLastName());
      address.setCustSuffix(billingAddress.getCustSuffix());
      address.setCustAddressLine1(billingAddress.getCustAddressLine1());
      address.setCustAddressLine2(billingAddress.getCustAddressLine2());
      address.setCustCityName(billingAddress.getCustCityName());
      address.setCustStateName(billingAddress.getCustStateName());
      address.setCustStateCode(billingAddress.getCustStateCode());
      address.setCustCountryName(billingAddress.getCustCountryName());
      address.setCustCountryCode(billingAddress.getCustCountryCode());
      address.setCustStateName(billingAddress.getCustStateName());
      address.setCustZipCode(billingAddress.getCustZipCode());
      address.setCustPhoneNum(billingAddress.getCustPhoneNum());
      address.setCustFaxNum(billingAddress.getCustFaxNum());
      address.setRecUpdateBy(Constants.USERNAME_SYSTEM);
      address.setRecUpdateDatetime(new Date());
      Country country = CountryDAO.loadByCountryCode(siteId, billingAddress.getCustCountryCode());
      address.setCountry(country);
      if (billingAddress.getCustStateCode() != null) {
        State state = StateDAO.loadByStateCode(siteId, billingAddress.getCustStateCode());
        address.setState(state);
      }
      em.persist(address);
      orderHeader.setBillingAddress(address);
    }
    CustomerAddress shippingAddress = shoppingCart.getShippingAddress();
    if (shippingAddress != null) {
      OrderAddress address = null;
      if (orderHeader.getShippingAddress() != null) {
        address = orderHeader.getShippingAddress();
      }
      else {
        address = new OrderAddress();
        address.setRecCreateBy(Constants.USERNAME_SYSTEM);
        address.setRecCreateDatetime(new Date());
      }
      address.setCustUseAddress(shippingAddress.getCustUseAddress());
      address.setCustPrefix(shippingAddress.getCustPrefix());
      address.setCustFirstName(shippingAddress.getCustFirstName());
      address.setCustMiddleName(shippingAddress.getCustMiddleName());
      address.setCustLastName(shippingAddress.getCustLastName());
      address.setCustSuffix(shippingAddress.getCustSuffix());
      address.setCustAddressLine1(shippingAddress.getCustAddressLine1());
      address.setCustAddressLine2(shippingAddress.getCustAddressLine2());
      address.setCustCityName(shippingAddress.getCustCityName());
      address.setCustStateName(shippingAddress.getCustStateName());
      address.setCustStateCode(shippingAddress.getCustStateCode());
      address.setCustCountryName(shippingAddress.getCustCountryName());
      address.setCustCountryCode(shippingAddress.getCustCountryCode());
      address.setCustStateName(shippingAddress.getCustStateName());
      address.setCustZipCode(shippingAddress.getCustZipCode());
      address.setCustPhoneNum(shippingAddress.getCustPhoneNum());
      address.setCustFaxNum(shippingAddress.getCustFaxNum());
      address.setRecUpdateBy(Constants.USERNAME_SYSTEM);
      address.setRecUpdateDatetime(new Date());
      Country country = CountryDAO.loadByCountryCode(siteId, shippingAddress.getCustCountryCode());
      address.setCountry(country);
      if (shippingAddress.getCustStateCode() != null) {
        State state = StateDAO.loadByStateCode(siteId, shippingAddress.getCustStateCode());
        address.setState(state);
      }
      em.persist(address);
      orderHeader.setShippingAddress(address);
    }
    if (customer != null) {
      orderHeader.setCustEmail(customer.getCustEmail());
    }
    orderHeader.setShippingTotal(Float.valueOf(shoppingCart.getShippingOrderTotal()));
    orderHeader.setShippingDiscountTotal(shoppingCart.getShippingDiscountTotal());
    orderHeader.setOrderTotal(Float.valueOf(shoppingCart.getOrderTotal()));
    orderHeader.setOrderDate(new Date());
View Full Code Here

      }
      return null;
    }
   
    public void maintainOpenOrder(HttpServletRequest request, ShoppingCart shoppingCart) throws Exception {
    Customer customer = getCustomer(request);
    if (customer == null) {
      return;
    }
   
    if (shoppingCart.getShoppingCartItems().size() == 0) {
View Full Code Here

      if (!create) {
        return null;
      }
     
      shoppingCart = new ShoppingCart(contentBean);
      Customer customer = ContentLookupDispatchAction.getCustomer(request);
      if (customer != null) {
        shoppingCart.initCustomer(customer, contentBean);
      }
     
      PaymentEngine engine = PaymentManager.getPaymentEngine(contentBean.getContentSessionBean().getSiteCurrency(), request);
View Full Code Here

            "and      customerClass.systemRecord = 'Y'";
    query = em.createQuery(sql);
    query.setParameter("siteId", siteId);
    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.setCustEmail(form.getCustEmail());
        customer.setCustPassword(AESEncoder.getInstance().encode(form.getCustPassword()));
        customer.setCustPublicName(form.getCustPublicName());
        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 = 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();
       
        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
    shoppingCart.setCustomer(new CustomerDAO(customer));
    shoppingCart.setCustAddress(customerAddress);

        ActionForward actionForward = actionMapping.findForward("createSuccess");
        return actionForward;
View Full Code Here

            ActionForward actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        idSecurity.reset();
       
        Customer customer = (Customer) list.get(0);
        if (!customer.getActive().equals(Constants.VALUE_YES)) {
          messages.add("login", new ActionMessage("content.error.login.suspended"));
      saveMessages(request, messages);
            ActionForward actionForward = null;
            if (shoppingCart.isShippingQuoteLock()) {
              actionForward = actionMapping.findForward("quote");
                return actionForward;
            }
            actionForward = actionMapping.findForward("error");
            return actionForward;
        }
        ContentLookupDispatchAction.setCustId(request, customer.getCustId());
        shoppingCart.initCustomer(customer, contentBean);
        shoppingCart.setShippingPickUp(shoppingCart.isEstimatePickUp());
        shoppingCart.setShippingMethod(null);
       
        OrderHeader orderHeader = shoppingCart.locateAbundentOrder();
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.