Package org.springframework.samples.jpetstore.domain

Examples of org.springframework.samples.jpetstore.domain.Order


   public Message insertOrder(Message message) throws Exception
   {
      Body msgBody = message.getBody();
      XStream xstream = new XStream(new DomDriver());
      xstream.alias("order", Order.class);
      Order order = (Order) xstream.fromXML((String) msgBody.get());

      PetStoreFacade petStore = (PetStoreFacade) getBeanFactory()
            .getBean("petStore");
      petStore.insertOrder(order);
View Full Code Here


  }

  public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    UserSession userSession = (UserSession) WebUtils.getRequiredSessionAttribute(request, "userSession");
    int orderId = Integer.parseInt(request.getParameter("orderId"));
    Order order = this.petStore.getOrder(orderId);
    if (userSession.getAccount().getUsername().equals(order.getUsername())) {
      return new ModelAndView("ViewOrder", "order", order);
    }
    else {
      return new ModelAndView("Error", "message", "You may only view your own orders.");
    }
View Full Code Here

    }
    else if (!orderForm.isConfirmed()) {
      return mapping.findForward("confirm");
    }
    else if (orderForm.getOrder() != null) {
      Order order = orderForm.getOrder();
      getPetStore().insertOrder(order);
      request.getSession().removeAttribute("workingOrderForm");
      request.getSession().removeAttribute("cartForm");
      request.setAttribute("order", order);
      request.setAttribute("message", "Thank you, your order has been submitted.");
View Full Code Here

public class ViewOrderAction extends SecureBaseAction {

  protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    AccountActionForm acctForm = (AccountActionForm) form;
    int orderId = Integer.parseInt(request.getParameter("orderId"));
    Order order = getPetStore().getOrder(orderId);
    if (acctForm.getAccount().getUsername().equals(order.getUsername())) {
      request.setAttribute("order", order);
      return mapping.findForward("success");
    }
    else {
      request.setAttribute("message", "You may only view your own orders.");
View Full Code Here

  }

  /* Constructors */

  public OrderActionForm() {
    this.order = new Order();
    this.shippingAddressRequired = false;
    this.cardTypeList = CARD_TYPE_LIST;
    this.confirmed = false;
  }
View Full Code Here

    for (Iterator it = orderServices.keySet().iterator(); it.hasNext();) {
      String beanName = (String) it.next();
      OrderService orderService = (OrderService) orderServices.get(beanName);
      System.out.println("Calling OrderService '" + beanName + "' with order ID " + orderId);
      stopWatch.start(beanName);
      Order order = null;
      for (int i = 0; i < nrOfCalls; i++) {
        order = orderService.getOrder(orderId);
      }
      stopWatch.stop();
      if (order != null) {
View Full Code Here

      throw new IllegalStateException("mailSender is required");
    }
  }

  public void afterReturning(Object returnValue, Method m, Object[] args, Object target) throws Throwable {
    Order order = (Order) args[0];
    Account account = ((PetStoreFacade) target).getAccount(order.getUsername());

    // don't do anything if email address is not set
    if (account.getEmail() == null || account.getEmail().length() == 0) {
      return;
    }

    StringBuffer text = new StringBuffer();
    text.append("Dear ").append(account.getFirstName()).append(' ').append(account.getLastName());
    text.append(", thank your for your order from JPetStore. Please note that your order number is ");
    text.append(order.getOrderId());

    SimpleMailMessage mailMessage = new SimpleMailMessage();
    mailMessage.setTo(account.getEmail());
    mailMessage.setFrom(this.mailFrom);
    mailMessage.setSubject(this.subject);
View Full Code Here

    return getSqlMapClientTemplate().queryForList("getOrdersByUsername", username);
  }

  public Order getOrder(int orderId) throws DataAccessException {
    Object parameterObject = new Integer(orderId);
    Order order = (Order) getSqlMapClientTemplate().queryForObject("getOrder", parameterObject);
    if (order != null) {
      order.setLineItems(getSqlMapClientTemplate().queryForList("getLineItemsByOrderId", new Integer(order.getOrderId())));
    }
    return order;
  }
View Full Code Here

TOP

Related Classes of org.springframework.samples.jpetstore.domain.Order

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.