Package org.simplecart.account

Examples of org.simplecart.account.Customer


     * @return Customer object by ID
     * @param id
     * @param lock
     */
    public Customer findById(Long id, boolean lock) throws HibernateException {
        Customer customer = null;

        customer = (Customer) abstractFindById(id, lock);
        return customer;
    }
View Full Code Here


        HttpServletResponse res = (HttpServletResponse) response;
       
        cat.info ("Execute CustomerAuthFilter ... ");

        HttpSession session = req.getSession(); // get the session or create it
        Customer customer = (Customer) session.getAttribute(Constants.LOGGED_IN_USER_KEY);
        if (customer == null) {
            cat.info ("customer object is null; was not found in the session under key " + Constants.LOGGED_IN_USER_KEY);
            // redirect to the login page
            res.sendRedirect(req.getContextPath() + "/public/CustomerLogin.do");
        } else {
View Full Code Here

        errors = new ActionMessages();
        HttpSession session = request.getSession();

        // try first to find a logged in user object
        Customer customer = (Customer) session.getAttribute(Constants.LOGGED_IN_USER_KEY);

        // if no user is found fail otherwise succeed
        if (customer == null) return mapping.findForward(Constants.DISPLAY_PAGE_KEY);
        else return mapping.findForward(Constants.ERROR_KEY);
View Full Code Here

        HttpSession session = request.getSession();
        String username = (String) PropertyUtils.getSimpleProperty(form,"username");
        String password = (String) PropertyUtils.getSimpleProperty(form,"password");
        ActionMessages errors = new ActionMessages();
        SecurityService securityService = new CustomerSecurityService();
        Customer customer = null;

        // perform authentication
        try {
            customer = (Customer) securityService.authenticate(username, password);
        } catch (AuthenticationException e) {
View Full Code Here

       
        // cast form to appropriate type
        OrderForm billingForm = (OrderForm) form;
       
        // get the customer object from the session
        Customer customer = (Customer) session.getAttribute(Constants.LOGGED_IN_USER_KEY);
       
        // copy form-bean values to new Stake and Address objects
        CreditCardBillingDetails creditCardDetails = new CreditCardBillingDetails();
        creditCardDetails.setCreditCardType(CreditCardType.getInstance(billingForm.getCreditCardType()));
        creditCardDetails.setCreditCardExpirationMonth(billingForm.getCreditCardExpirationMonth());
        creditCardDetails.setCreditCardExpirationYear(billingForm.getCreditCardExpirationYear());
        creditCardDetails.setCreditCardNumber(billingForm.getCreditCardNumber());
        creditCardDetails.setCreditCardCVVSCode(billingForm.getCreditCardCVVSCode());
       
        // attache the address to this new customer
        customer.addBillingDetails(creditCardDetails);
       
        // get a DAO for the new Stake
        cdao = new CustomerDAO();
       
        // store the new Stake
View Full Code Here

        newAdmin.setAddress(generalAddress);

        dao.makePersistent(newAdmin);
       
        // create a sample customer
        Customer customer = new Customer();
        customer.setAddress(customerAddress);
        customer.setCompanyName("XYZ Corp.");
        customer.setEmailAddress("jim@xyzcorp.com");
        customer.setNameFirst("Jim");
        customer.setNameLast("Smith");
        customer.setUsername("jimmy");
        customer.setPassword("testpass");
       
        // create a searchDetails object
        SearchUtility searchDetails = new SearchUtility();
        searchDetails.setSearchMetaAuthor("daniel");
        searchDetails.setSearchMetaCopyright("daniel");
        searchDetails.setSearchMetaDate("today");
        searchDetails.setSearchMetaDescription("cool");
        searchDetails.setSearchMetaKeywords("daniel");
       
        // create a category
        InternetProductCategory category = new InternetProductCategory();
        category.setConsumerVisible(true);
        category.setName("Test Category");
        category.setDescription("Test Category");
        category.setSearchDetails(searchDetails);

        // create a product
        InternetProduct product = new InternetProduct();
        product.setConsumerVisible(true);
        product.setName("Test Product");
        product.setDescription("Test Product");
        product.setSearchDetails(searchDetails);

        // create an option
        InternetProductOption option1 = new InternetProductOption();
        option1.setConsumerVisible(true);
        option1.setDescription("fake option");
        option1.setName("faker option");
        option1.setStockKeepingUnitIdentifier("FAKE0");
        option1.setUnitPriceActualRetail((float)4.56);
        option1.setUnitPriceManufacturerSuggestedRetail((float)6.74);
        option1.setUnitWeightInOunces(2);
        option1.setSearchDetails(searchDetails);
       
        // create an option
        InternetProductOption option2 = new InternetProductOption();
        option2.setConsumerVisible(true);
        option2.setDescription("fake option");
        option2.setName("faker option");
        option2.setStockKeepingUnitIdentifier("FAKE1");
        option2.setUnitPriceActualRetail((float)4.56);
        option2.setUnitPriceManufacturerSuggestedRetail((float)6.74);
        option2.setUnitWeightInOunces(2);
        option2.setSearchDetails(searchDetails);

        // associate category, product and option
        category.associate(product);
        product.associate(option1);
        product.associate(option2);
       
        // persist option
        // TODO: I should be able to make a single call to save the category
        optdao.makePersistent(option1);
        optdao.makePersistent(option2);
        proddao.makePersistent(product);
        catdao.makePersistent(category);
       
        // create a sample order
        InternetSalesOrder salesOrder = new InternetSalesOrder();
        salesOrder.setAddress(orderAddress);
        salesOrder.setNotes("TEST NOTES!");
        salesOrder.setPlacedOn(new Date());
        salesOrder.addLineItem(new SalesOrderLineItem((float)3,(float)3.64,"line 1",option1));
        salesOrder.addLineItem(new SalesOrderLineItem((float)6,(float)4.91,"line 2",option2));

        // associate order
        customer.addOrder(salesOrder);
       
        cdao.makePersistent(customer);
        sdao.makePersistent(salesOrder);

        HibernateUtility.commitTransaction();
View Full Code Here

       
        // load the sesion for this request
        HttpSession session = request.getSession();
       
        // get the customer object from the session
        Customer customer = (Customer) session.getAttribute(Constants.LOGGED_IN_USER_KEY);
       
        // attache address to order
        Address orderAddress = (Address) session.getAttribute(Constants.PREPARE_ORDER_ADDRESS);
       
        // create a new order object
        InternetSalesOrder newOrder = new InternetSalesOrder (customer,orderAddress);
       
        // create the line items and add to order
        Shopcart shopcart = (Shopcart) session.getAttribute(Constants.SHOPCART);
        Iterator cartItems = shopcart.getItems().iterator();
        ShopcartItem currentItem;
        SalesOrderLineItem currentLineItem;
        ProductOption currentOption;

        // get a DAO for the new Stake
        InternetProductOptionDAO optionDAO = new InternetProductOptionDAO();
       
        while (cartItems.hasNext()) {
            currentItem = (ShopcartItem) cartItems.next();
            currentOption = optionDAO.findById(currentItem.getOptionId(),false);
            currentLineItem =
              new SalesOrderLineItem(
                    currentItem.getAmount(),
                    currentItem.getPrice(),
                    currentItem.getComment(),
                    currentOption);
            newOrder.getLineItems().add(currentLineItem);
        }
       
        // create the payment and attache to the order
        InternetPayment payment = new InternetPayment();
        CreditCardBillingDetails billing = (CreditCardBillingDetails) customer.getBillingDetails().iterator().next();
        payment.setCreditCardType(billing.getCreditCardType().toString());
        payment.setCreditCardNumber(billing.getCreditCardNumber());
        payment.setCreditCardCVVSCode(billing.getCreditCardCVVSCode());
        payment.setExpirationDate(billing.getCreditCardExpirationMonth()+"/"+billing.getCreditCardExpirationYear());
        payment.setPaymentAmount(shopcart.getCartTotal());
View Full Code Here

        PartyForm customerForm = (PartyForm) form;
       
        // copy form-bean values to new Stake and Address objects
        Address newAddress = new Address();
        PropertyUtils.copyProperties(newAddress, customerForm);
        Customer newCustomer = new Customer();
        PropertyUtils.copyProperties(newCustomer, customerForm);
       
        // attache the address to this new customer
        newCustomer.setAddress(newAddress);
       
        // store customer object in the session
        session.setAttribute(Constants.LOGGED_IN_USER_KEY,newCustomer);
       
        // get a DAO for the new Stake
        dao = new CustomerDAO();
       
        // store the new Stake
        dao.makePersistent(newCustomer);
       
        // commit this transaction
        HibernateUtility.commitTransaction();
        HibernateUtility.closeSession();
       
        //********** NOW LOG the CUSTOMER IN **********
       
        SecurityService securityService = new CustomerSecurityService();
        Customer customer = null;

        // perform authentication
        try {
            customer = (Customer) securityService.authenticate(customerForm.getUsername(), customerForm.getPassword());
        } catch (AuthenticationException e) {
View Full Code Here

        PartyForm customerForm = (PartyForm) form;
       
        // get a DAO for the new Stake
        dao = new CustomerDAO();
       
        Customer customer = null;
       
        try {
            // find customer objects and attach to request
            customer = dao.findById(customerForm.getId(), false);
           
            // copy form-bean values to new Stake and Address objects
            // NOTE: PropertyUtils will not work in this situation since there
            //       is an ID field which is different for Stake and Address
            customer.setNameFirst(customerForm.getNameFirst());
            customer.setNameLast(customerForm.getNameLast());
            customer.setUsername(customerForm.getUsername());
            customer.setPassword(customerForm.getPassword());
            customer.setEmailAddress(customerForm.getEmailAddress());
            customer.setCompanyName(customerForm.getCompanyName());
            customer.setPhone(customerForm.getPhone());
            customer.getAddress().setStreetLine1(customerForm.getStreetLine1());
            customer.getAddress().setStreetLine2(customerForm.getStreetLine2());
            customer.getAddress().setCity(customerForm.getCity());
            customer.getAddress().setState(customerForm.getState());
            customer.getAddress().setPostalCode(customerForm.getPostalCode());
           
            // update the Stake
            dao.makePersistent(customer);
           
            // close transaction and session
View Full Code Here

        if (dao == null){
            throw new AuthenticationException ("Error initializing dao");
        }

        // create example object for query
        Customer loginCustomer = new Customer();
        loginCustomer.setUsername(username);
       
        // find member object by example
        Collection matchingCustomers = dao.findByExample(loginCustomer);
        Iterator memberIter = matchingCustomers.iterator();
        if (memberIter.hasNext()) {
            loginCustomer = (Customer) memberIter.next();
        } else loginCustomer = null;

        if ((loginCustomer == null) || !password.equals(loginCustomer.getPassword())) {
            throw new AuthenticationException ("Error validating user");
        }

        // commit this transaction
        HibernateUtility.commitTransaction();
View Full Code Here

TOP

Related Classes of org.simplecart.account.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.