Package org.hoteia.qalingo.core.domain

Examples of org.hoteia.qalingo.core.domain.Customer


        customer.setActive(true);
        customer.setDateCreate(new Date());
        customer.setDateUpdate(new Date());

        // WE SAVE A FIRST TIME TO EVICT DETACH ENTITY ISSUE WITH CUSTOMERGROUP - NOT THE BEST WAY
        Customer savedCustomer = customerService.saveOrUpdateCustomer(customer);
       
        CustomerGroup customerGroup = customerGroupService.getCustomerGroupByCode(CustomerGroup.GROUP_FO_CUSTOMER);
        customer.getGroups().add(customerGroup);
       
        savedCustomer = customerService.saveOrUpdateCustomer(customer);
       
        Customer reloadedCustomer = customerService.getCustomerById(savedCustomer.getId());
        requestUtil.updateCurrentCustomer(request, reloadedCustomer);
       
        return reloadedCustomer;
    }
View Full Code Here


    }
   
    public Customer deleteAddressCustomer(final RequestData requestData, final String customerAddressId) throws Exception {
        final HttpServletRequest request = requestData.getRequest();
        String customerLogin = requestUtil.getCurrentCustomerLogin(request);
        Customer customer = customerService.getCustomerByLoginOrEmail(customerLogin);
        CustomerAddress customerAddress = customer.getAddress(new Long(customerAddressId));
       
        // SANITY CHECK : wrong address id for this customer
        if(customerAddress == null){
            throw new Exception("");
        }
       
        Set<CustomerAddress> customerAddresses = customer.getAddresses();
       
        // SANITY CHECK : min address equal zero
        if(customerAddresses.size() < 2){
            throw new Exception("");
        }
       
        for (Iterator<CustomerAddress> iterator = customerAddresses.iterator(); iterator.hasNext();) {
            CustomerAddress customerAddressIterator = (CustomerAddress) iterator.next();
            if(customerAddressIterator.getId().equals(new Long(customerAddressId))){
                customerAddress = customerAddressIterator;
            }
        }
        customer.getAddresses().remove(customerAddress);
       
        // UPDATE CUSTOMER
        customerService.saveOrUpdateCustomer(customer);
       
        // UPDATE SESSION
        customer = customerService.getCustomerByLoginOrEmail(customer.getEmail());
        requestUtil.updateCurrentCustomer(request, customer);
       
        return customer;
    }
View Full Code Here

    }
   
    public Customer addProductSkuToWishlist(final RequestData requestData, final String catalogCategoryCode, final String productSkuCode) throws Exception {
        final HttpServletRequest request = requestData.getRequest();
        final MarketArea marketArea = requestData.getMarketArea();
        Customer customer = requestData.getCustomer();
        customer = checkCustomerMarketArea(requestData, customer);
       
        customerService.addProductSkuToWishlist(marketArea, customer, catalogCategoryCode, productSkuCode);
        // TODO : denis : 20140904 : is it necessary to reload or not ?
        customer = customerService.getCustomerByLoginOrEmail(customer.getEmail());
        requestUtil.updateCurrentCustomer(request, customer);

        return customer;
    }
View Full Code Here

    }
   
    public Customer removeProductSkuFromWishlist(final RequestData requestData, final String productSkuCode) throws Exception {
        final HttpServletRequest request = requestData.getRequest();
        final MarketArea marketArea = requestData.getMarketArea();
        Customer customer = requestData.getCustomer();
        customer = checkCustomerMarketArea(requestData, customer);
       
        customerService.removeProductSkuFromWishlist(marketArea, customer, productSkuCode);
        // TODO : denis : 20140904 : is it necessary to reload or not ?
        customer = customerService.getCustomerByLoginOrEmail(customer.getEmail());
        requestUtil.updateCurrentCustomer(request, customer);
       
        return customer;
    }
View Full Code Here

    }
   
    public void savePaymentInformation(RequestData requestData, PaymentForm paymentForm) throws Exception {
        final HttpServletRequest request = requestData.getRequest();
        final MarketArea marketArea = requestData.getMarketArea();
        Customer customer = requestData.getCustomer();
       
        final CustomerPaymentInformation customerPaymentInformation = new CustomerPaymentInformation();
        customerPaymentInformation.setPaymentType(paymentForm.getPaymentType());
        customerPaymentInformation.setCardHolderName(paymentForm.getCardHolderName());
        customerPaymentInformation.setCardNumber(paymentForm.getCardNumber());
        customerPaymentInformation.setCardExpMonth(paymentForm.getCardExpMonth());
        customerPaymentInformation.setCardExpYear(paymentForm.getCardExpYear());
        customerPaymentInformation.setCardCVV(paymentForm.getCardCVV());
        customerPaymentInformation.setCustomerMarketAreaId(marketArea.getId());
       
        customerService.savePaymentInformation(customer, customerPaymentInformation);
        customer = customerService.getCustomerByLoginOrEmail(customer.getEmail());
        requestUtil.updateCurrentCustomer(request, customer);
    }
View Full Code Here

        requestUtil.updateCurrentCustomer(request, customer);
    }
   
    public OrderCustomer buildAndSaveNewOrder(final RequestData requestData) throws Exception {
        final HttpServletRequest request = requestData.getRequest();
        final Customer customer = requestData.getCustomer();
        final Cart cart = requestData.getCart();
       
        OrderCustomer orderCustomer = checkoutService.checkout(customer, cart);
       
        requestUtil.deleteCurrentCartAndSaveEngineSession(request);
View Full Code Here

       
        return orderCustomer;
    }
   
    public Customer saveNewsletterSubscription(final RequestData requestData, final String email) throws Exception {
        Customer customer = customerService.getCustomerByLoginOrEmail(email);
        MarketArea marketArea = requestData.getMarketArea();
       
        // SANITY CHECK : CHECK IF THE OPTIN ALREADY EXIST FOR THE MARKET AREA
        if(customer != null){
            CustomerMarketArea customerMarketArea = customer.getCurrentCustomerMarketArea(marketArea.getId());
            if(customerMarketArea != null){
                CustomerOptin customerOptin = customerMarketArea.getOptins(CustomerOptin.OPTIN_TYPE_WWW_NEWSLETTER);
                if(customerOptin != null){
                    throw new UniqueNewsletterSubscriptionException();
                }
            }
        }
       
        CustomerOptin customerOptin = new CustomerOptin();
        customerOptin.setType(CustomerOptin.OPTIN_TYPE_WWW_NEWSLETTER);
        customerOptin.setOrigin("MCOMMERCE");

        // HANDLE OPTIN
        if(customer != null){
            customer = checkCustomerMarketArea(requestData, customer);
            CustomerMarketArea customerMarketArea = customer.getCurrentCustomerMarketArea(marketArea.getId());
            if(customerMarketArea == null){
                customerMarketArea = new CustomerMarketArea();
                customerMarketArea.addOptins(customerOptin);
                customer.getCustomerMarketAreas().add(customerMarketArea);
            } else {
                customerMarketArea.addOptins(customerOptin);
            }
        } else {
            customer = new Customer();
            customer.setEmail(email);
            customer.setAnonymous(true);
            customer = checkCustomerMarketArea(requestData, customer);
            CustomerMarketArea customerMarketArea = new CustomerMarketArea();
            customerMarketArea.addOptins(customerOptin);
            customer.getCustomerMarketAreas().add(customerMarketArea);
        }
       
        customer = updateCurrentCustomer(requestData, customer);
        return customer;
    }
View Full Code Here

        return customer;
    }
   
    public Customer saveNewsletterUnsubscription(final RequestData requestData, final String email) throws Exception {
        final HttpServletRequest request = requestData.getRequest();
        Customer customer = customerService.getCustomerByLoginOrEmail(email);
        MarketArea marketArea = requestData.getMarketArea();
       
        // SANITY CHECK : CHECK IF THE OPTIN ALREADY EXIST FOR THE MARKET AREA
        if(customer != null){
            CustomerMarketArea customerMarketArea = customer.getCurrentCustomerMarketArea(marketArea.getId());
            if(customerMarketArea != null){
                CustomerOptin customerOptin = customerMarketArea.getOptins(CustomerOptin.OPTIN_TYPE_WWW_NEWSLETTER);
                if(customerOptin != null){
                    customerMarketArea.getOptins().remove(customerOptin);
                }
View Full Code Here

    return customerAddressForm;
  }
 
  public CartForm buildCartForm(final RequestData requestData) throws Exception {
    final CartForm cartForm = new CartForm();
    Customer customer = requestData.getCustomer();
    if(customer != null) {
       Set<CustomerAddress> addresses = customer.getAddresses();
       for (Iterator<CustomerAddress> iterator = addresses.iterator(); iterator.hasNext();) {
        CustomerAddress customerAddress = (CustomerAddress) iterator.next();
        if(customerAddress.isDefaultBilling()) {
          cartForm.setBillingAddressId(customerAddress.getId().toString());
        }
View Full Code Here

   
    // CUSTOMER
   
    public Customer createOrUpdateCustomer(Customer customer, final CustomerForm customerForm) throws Exception {
        if(customer == null){
            customer = new Customer();
        }
        customer.setLogin(customerForm.getLogin());
        customer.setLastname(customerForm.getLastname());
        customer.setFirstname(customerForm.getFirstname());
        customer.setEmail(customerForm.getEmail());
View Full Code Here

TOP

Related Classes of org.hoteia.qalingo.core.domain.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.