Examples of CustomerInfo


Examples of com.emc.plants.pojo.beans.CustomerInfo

      
       @Test
       public void testGetCustomerInfo(){
        
         String customerID="abc.def@xyz.com";
         CustomerInfo customerInfo = login.getCustomerInfo(customerID);
         assertEquals("Result", "abc" ,customerInfo.getFirstName() );
        
       }
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

         String addr2="yy";
         String addrCity="zz";
         String addrState="xyz";
         String addrZip="560016";
         String phone="9988776644";
         CustomerInfo customerInfo = login.updateUser(customerID, firstName, lastName, addr1, addr2, addrCity, addrState, addrZip, phone);
         assertEquals("Result", "defXXX" ,customerInfo.getLastName());
       }
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

*/
    System.out.println("Spring Context :: " + context.getBean("loginBean"));

    Login loginBean = (Login) context.getBean("loginBean");

    CustomerInfo cInfo = (CustomerInfo)loginBean.getCustomerInfo("123");
   
    System.out.println("First Name :: "+cInfo.getFirstName());
    }
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

                Util.debug(fields[5]);
                Util.debug(fields[6]);
                Util.debug(fields[7]);
                Util.debug(fields[8]);
                Util.debug(fields[9]);
                CustomerInfo customerInfo = login.createNewUser(customerID, password, firstName, lastName, addr1, addr2, addrCity, addrState, addrZip, phone);
            }
        } catch (Exception e) {
            Util.debug("Unable to populate CUSTOMER table with text data: " + e);
        }
        /**
 
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

    HttpSession session = req.getSession(true);
    long key = (Long) session.getAttribute(Util.ATTR_ORDERKEY);
    req.setAttribute(Util.ATTR_ORDERID, key);
    long orderKey = key;
    logger.debug("completecheckout: order id ="+orderKey );
    CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);
    // Check the available inventory and backorder if necessary.
    shoppingCart = (ShoppingCart) session.getAttribute(Util.ATTR_CART);
    // Make sure ShopingCart reference has not timed out.
    try
    {
      logger.debug("completecheckout: ShoppingCart timeout? check getItems() method");
      shoppingCart.getItems();
    }
    // TODO: what exception gets thrown?
    catch (RuntimeException e)
    {
      // ShoppingCart timed out, so create a new one.
      logger.debug("completecheckout: ShoppingCart ref must have timed out");
      ShoppingCartContents cartContents = (ShoppingCartContents) session.getAttribute(Util.ATTR_CART_CONTENTS);
      if (cartContents != null)
      {
        shoppingCart.setCartContents(cartContents);
      }
      else
      {
        logger.debug("NoSuchObject Exception!!!");
        logger.debug("Major Problem!!!");
        shoppingCart = null;
      }
    }
    if (shoppingCart != null)
    {
      ShoppingCartItem si;
      Collection items = shoppingCart.getItems();
      for (Object o : items)
      {
        si = (ShoppingCartItem) o;
        shoppingCart.checkInventory(si);
        logger.debug("ShoppingCart.checkInventory() - checking Inventory quantity of item: " + si.getID());
      }
    }

   
    try
    {
      PaymentInfoPublisher pInfoPublisher = (PaymentInfoPublisher)Util.getSpringBean("paymentInfoPublisher");
     
      pInfoPublisher.publishMessage("Order placed successfully for Customer : " +customerInfo.getCustomerID()+" with Order ID : "+orderKey);
    }
    catch (Exception e)
    {
      logger.error("Exception during Posting message to RabbitMQ :"+e);
      e.printStackTrace();
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

  @RequestMapping(method = RequestMethod.POST)
  public String accountUpdate(HttpServletRequest req) throws ServletException {

         String url;
         HttpSession session = req.getSession(true);
         CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);
         if (customerInfo == null)
         {
            url = ACTION_LOGIN;
            req.setAttribute(Util.ATTR_UPDATING, "true");
            req.setAttribute(Util.ATTR_RESULTS, "\nYou must login first.");
         }
         else
         {
            url = ACTION_ACCOUNT;
            req.setAttribute(Util.ATTR_EDITACCOUNTINFO, customerInfo);
         }

         String userid = customerInfo.getCustomerID();
         String firstName = req.getParameter("fname");
         String lastName = req.getParameter("lname");
         String addr1 = req.getParameter("addr1");
         String addr2 = req.getParameter("addr2");
         String addrCity = req.getParameter("city");
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

  public String performTask(HttpServletRequest req,
      HttpServletResponse resp){
    logger.debug("InitCheckOutShoppingController:performTask");
    String url;
    HttpSession session = req.getSession(true);
    CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);
    if (customerInfo == null)
    {
      req.setAttribute(Util.ATTR_RESULTS, "You must login or register before checking out.");
      session.setAttribute(Util.ATTR_CHECKOUT, new Boolean(true));
      url = Util.PAGE_LOGIN;
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

                  session.removeAttribute(Util.ATTR_CHECKOUT);
                  session.removeAttribute(Util.ATTR_ORDERKEY);
               }

               // Store customer userid in HttpSession.
               CustomerInfo customerInfo = login.getCustomerInfo(userid);
               session.setAttribute(Util.ATTR_CUSTOMER, customerInfo);
               Util.debug("updating=" + updating + "=");

               // Was customer trying to edit account information.
               if (updating.equals("true"))
               {
                  req.setAttribute(Util.ATTR_EDITACCOUNTINFO, customerInfo);

                  requestDispatch( getServletConfig().getServletContext(),
                                   req, resp, Util.PAGE_ACCOUNT );
               }
               else
               {
                  // See if user was in the middle of checking out.
                  Boolean checkingOut = (Boolean) session.getAttribute(Util.ATTR_CHECKOUT);
                  Util.debug("checkingOut=" + checkingOut + "=");
                  if ((checkingOut != null) && (checkingOut.booleanValue()))
                  {
                     Util.debug("must be checking out");
                     requestDispatch( getServletConfig().getServletContext(),
                                      req, resp, Util.PAGE_ORDERINFO);
                  }
                  else
                  {
                     Util.debug("must NOT be checking out");
                     String url;
                     String category = (String) session.getAttribute(Util.ATTR_CATEGORY);

                     // Default to plants
                      Util.debug("category : "+category);
                     if ((category == null) || (category.equals("null")))
                     {
                        url = Util.PAGE_PROMO;
                     }
                     else
                     {
                        url = Util.PAGE_SHOPPING;
                        req.setAttribute(Util.ATTR_INVITEMS,
                                         catalog.getItemsByCategory(Integer.parseInt(category)));
                     }

                     requestDispatch( getServletConfig().getServletContext(),
                                      req, resp, url);
                  }
               }
            }
         }
         catch (ServletException e)
         {
           e.printStackTrace();
            req.setAttribute(Util.ATTR_RESULTS, "/nException occurred");
            throw e;
         }
         catch (Exception e)
         {
            req.setAttribute(Util.ATTR_RESULTS, "/nException occurred");
            e.printStackTrace();
            throw new ServletException(e.getMessage());
         }
      }
      else if (action.equals(ACTION_REGISTER))
      {
         // Register a new user.
//         try
//         {
            String url;
            HttpSession session = req.getSession(true);

            String userid = req.getParameter("userid");
            String password = req.getParameter("passwd");
            String cpassword = req.getParameter("vpasswd");
            String firstName = req.getParameter("fname");
            String lastName = req.getParameter("lname");
            String addr1 = req.getParameter("addr1");
            String addr2 = req.getParameter("addr2");
            String addrCity = req.getParameter("city");
            String addrState = req.getParameter("state");
            String addrZip = req.getParameter("zip");
            String phone = req.getParameter("phone");

            //validate all user input
            //This could be done more eloquently using a framework such as Struts...
            if (!Util.validateString(userid)){
              req.setAttribute(Util.ATTR_RESULTS, "Email address contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(firstName)){
              req.setAttribute(Util.ATTR_RESULTS, "First Name contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(lastName)){
              req.setAttribute(Util.ATTR_RESULTS, "Last Name contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(addr1)){
              req.setAttribute(Util.ATTR_RESULTS, "Address Line 1 contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(addr2)){
              req.setAttribute(Util.ATTR_RESULTS, "Address Line 2 contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(addrCity)){
              req.setAttribute(Util.ATTR_RESULTS, "City contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(addrState)){
              req.setAttribute(Util.ATTR_RESULTS, "State contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(addrZip)){
              req.setAttribute(Util.ATTR_RESULTS, "Zip contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            else if (!Util.validateString(phone)){
              req.setAttribute(Util.ATTR_RESULTS, "Phone Number contains invalid characters.");
                url = Util.PAGE_REGISTER;
            }
            // Make sure passwords match.
            else if (!password.equals(cpassword))
            {
               req.setAttribute(Util.ATTR_RESULTS, "Passwords do not match.");
               url = Util.PAGE_REGISTER;
            }
            else
            {
               // Create the new user.
               CustomerInfo customerInfo =
                     login.createNewUser(userid, password, firstName,
                                         lastName, addr1, addr2,
                                         addrCity, addrState, addrZip, phone);

               if (customerInfo != null)
               {
                  // Store customer info in HttpSession.
                  session.setAttribute(Util.ATTR_CUSTOMER, customerInfo);

                  // See if user was in the middle of checking out.
                  Boolean checkingOut = (Boolean) session.getAttribute(Util.ATTR_CHECKOUT);
                  if ((checkingOut != null) && (checkingOut.booleanValue()))
                  {
                     url = Util.PAGE_ORDERINFO;
                  }
                  else
                  {
                     String category = (String) session.getAttribute(Util.ATTR_CATEGORY);

                     // Default to plants
                     if (category == null)
                     {
                        url = Util.PAGE_PROMO;
                     }
                     else
                     {
                        url = Util.PAGE_SHOPPING;
                        req.setAttribute(Util.ATTR_INVITEMS,
                                         catalog.getItemsByCategory(Integer.parseInt(category)));
                     }
                  }
               }
               else
               {
                  url = Util.PAGE_REGISTER;
                  req.setAttribute(Util.ATTR_RESULTS, "New user NOT created!");
               }
            }
            requestDispatch( getServletConfig().getServletContext(),
                             req, resp, url);
//         }
//         catch (CreateException e) { }
      }
      else if (action.equals(ACTION_ACCOUNT))
      {
         String url;
         HttpSession session = req.getSession(true);
         CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);
         if (customerInfo == null)
         {
            url = Util.PAGE_LOGIN;
            req.setAttribute(Util.ATTR_UPDATING, "true");
            req.setAttribute(Util.ATTR_RESULTS, "\nYou must login first.");
         }
         else
         {
            url = Util.PAGE_ACCOUNT;
            req.setAttribute(Util.ATTR_EDITACCOUNTINFO, customerInfo);
         }
         requestDispatch( getServletConfig().getServletContext(),
                          req, resp, url);
      }
      else if (action.equals(ACTION_ACCOUNTUPDATE))
      {
//         try
//         {
            String url;
            HttpSession session = req.getSession(true);
            CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);

            String userid = customerInfo.getCustomerID();
            String firstName = req.getParameter("fname");
            String lastName = req.getParameter("lname");
            String addr1 = req.getParameter("addr1");
            String addr2 = req.getParameter("addr2");
            String addrCity = req.getParameter("city");
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

    }
    else if (action.equals(ACTION_INITCHECKOUT))
    {
      String url;
      HttpSession session = req.getSession(true);
      CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);
      if (customerInfo == null)
      {
        req.setAttribute(Util.ATTR_RESULTS, "You must login or register before checking out.");
        session.setAttribute(Util.ATTR_CHECKOUT, new Boolean(true));
        url = Util.PAGE_LOGIN;
      }
      else
      {
        url = Util.PAGE_ORDERINFO;
      }
      requestDispatch(getServletConfig().getServletContext(), req, resp, url);
    }
    else if (action.equals(ACTION_ORDERINFODONE))
    {
      OrderInfo orderinfo = null;
      ShoppingCart shoppingCart = null;
      HttpSession session = req.getSession(true);
      CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);
      String customerID = customerInfo.getCustomerID();
      shoppingCart = (ShoppingCart) session.getAttribute(Util.ATTR_CART);
      // Make sure ShopingCart reference has not timed out.
      try
      {
        Util.debug("orderinfodone: ShoppingCart timeout? check getItems() method");
        shoppingCart.getItems();
      }
      // TODO: what exception gets thrown?
      catch (RuntimeException e)
      {
        // ShoppingCart timed out, so create a new one.
        Util.debug("orderinfodone: ShoppingCart ref must have timed out");
        ShoppingCartContents cartContents = (ShoppingCartContents) session.getAttribute(Util.ATTR_CART_CONTENTS);
        if (cartContents != null)
        {
          shoppingCart = (ShoppingCart) WebUtil.getSpringBean(this.getServletContext(), "shopping");
          shoppingCart.setCartContents(cartContents);
        }
        else
        {
          Util.debug("NoSuchObject Exception!!!");
          Util.debug("Major Problem!!!");
          shoppingCart = null;
        }
      }
      Util.debug("orderinfodone: got cart?");
      if (shoppingCart != null)
      {
        Util.debug("orderinfodone: cart not NULL");
        String billName = req.getParameter("bname");
        String billAddr1 = req.getParameter("baddr1");
        String billAddr2 = req.getParameter("baddr2");
        String billCity = req.getParameter("bcity");
        String billState = req.getParameter("bstate");
        String billZip = req.getParameter("bzip");
        String billPhone = req.getParameter("bphone");
        String shipName = req.getParameter("sname");
        String shipAddr1 = req.getParameter("saddr1");
        String shipAddr2 = req.getParameter("saddr2");
        String shipCity = req.getParameter("scity");
        String shipState = req.getParameter("sstate");
        String shipZip = req.getParameter("szip");
        String shipPhone = req.getParameter("sphone");
        int shippingMethod = Integer.parseInt(req.getParameter("shippingMethod"));
        String creditCard = req.getParameter("ccardname");
        String ccNum = req.getParameter("ccardnum");
        String ccExpireMonth = req.getParameter("ccexpiresmonth");
        String ccExpireYear = req.getParameter("ccexpiresyear");
        String cardHolder = req.getParameter("ccholdername");
        orderinfo = shoppingCart.createOrder(customerID, billName, billAddr1, billAddr2, billCity, billState, billZip, billPhone, shipName, shipAddr1, shipAddr2, shipCity, shipState, shipZip, shipPhone, creditCard, ccNum, ccExpireMonth, ccExpireYear, cardHolder, shippingMethod, shoppingCart.getItems());
        Util.debug("orderinfodone: order created");
      }
      if (orderinfo != null)
      {
        req.setAttribute(Util.ATTR_ORDERINFO, orderinfo);
        req.setAttribute(Util.ATTR_CARTITEMS, shoppingCart.getItems());
        session.setAttribute(Util.ATTR_ORDERKEY, orderinfo.getID());
        requestDispatch(getServletConfig().getServletContext(), req, resp, Util.PAGE_CHECKOUTFINAL);
      }
    }
    else if (action.equals(ACTION_COMPLETECHECKOUT))
    {
      ShoppingCart shoppingCart = null;
      HttpSession session = req.getSession(true);
      long key = (Long) session.getAttribute(Util.ATTR_ORDERKEY);
      req.setAttribute(Util.ATTR_ORDERID, key);
      long orderKey = key;
      Util.debug("completecheckout: order id ="+orderKey );
      CustomerInfo customerInfo = (CustomerInfo) session.getAttribute(Util.ATTR_CUSTOMER);
      // Check the available inventory and backorder if necessary.
      shoppingCart = (ShoppingCart) session.getAttribute(Util.ATTR_CART);
      // Make sure ShopingCart reference has not timed out.
      try
      {
        Util.debug("completecheckout: ShoppingCart timeout? check getItems() method");
        shoppingCart.getItems();
      }
      // TODO: what exception gets thrown?
      catch (RuntimeException e)
      {
        // ShoppingCart timed out, so create a new one.
        Util.debug("completecheckout: ShoppingCart ref must have timed out");
        ShoppingCartContents cartContents = (ShoppingCartContents) session.getAttribute(Util.ATTR_CART_CONTENTS);
        if (cartContents != null)
        {
          shoppingCart = (ShoppingCart) WebUtil.getSpringBean(this.getServletContext(), "shopping");
          shoppingCart.setCartContents(cartContents);
        }
        else
        {
          Util.debug("NoSuchObject Exception!!!");
          Util.debug("Major Problem!!!");
          shoppingCart = null;
        }
      }
      if (shoppingCart != null)
      {
        ShoppingCartItem si;
        Collection items = shoppingCart.getItems();
        for (Object o : items)
        {
          si = (ShoppingCartItem) o;
          shoppingCart.checkInventory(si);
          Util.debug("ShoppingCart.checkInventory() - checking Inventory quantity of item: " + si.getID());
        }
      }

     
      try
      {
        PaymentInfoPublisher pInfoPublisher = (PaymentInfoPublisher)Util.getSpringBean("paymentInfoPublisher");
       
        pInfoPublisher.publishMessage("Order placed successfully for Customer : " +customerInfo.getCustomerID()+" with Order ID : "+orderKey);
      }
      catch (Exception e)
      {
        System.out.println("Exception during Posting message to RabbitMQ :"+e);
        e.printStackTrace();
View Full Code Here

Examples of com.emc.plants.pojo.beans.CustomerInfo

  public CustomerInfo createNewUser(String customerID, String password, String firstName,
      String lastName, String addr1, String addr2,
      String addrCity, String addrState, String addrZip,
      String phone)
  {
    CustomerInfo customerInfo = null;
   
    /*
     customerHome = (CustomerHome) Util.getEJBLocalHome("java:comp/env/ejb/Customer",
     com.ibm.websphere.samples.pbwjpa.CustomerHome.class);
    
     try
     {
     // Only create new user if it doesn't already exist.
      customerHome.findByPrimaryKeyUpdate(customerID);
      }
      catch (ObjectNotFoundException onfe)
      {
      // Create customer and return true if all goes well.
       Customer customer =
       customerHome.create(new CustomerKey(customerID), password, firstName,
       lastName, addr1, addr2, addrCity, addrState,
       addrZip, phone);
      
       if (customer != null)
       customerInfo = new CustomerInfo(customer);
       }
       }
       catch (FinderException e) { e.printStackTrace(); }
       catch (CreateException e) { e.printStackTrace(); }
       */
    Customer c = new Customer(customerID, password, firstName, lastName, addr1, addr2,
        addrCity, addrState, addrZip, phone);
        EntityManager em = entityManagerFactory.createEntityManager();
        em.getTransaction().begin();
    em.persist(c);
    em.flush();
        em.getTransaction().commit();
    customerInfo = new CustomerInfo(c);
    return customerInfo;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.