<%-- * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. --%> <%@page import="openbook.server.OpenBookService"%> <%@page import="openbook.domain.Book"%> <%@page import="openbook.domain.Customer"%> <%@page import="openbook.domain.ShoppingCart"%> <%@page import="openbook.domain.PurchaseOrder"%> <%@page import="openbook.domain.LineItem"%> <%@page import="openbook.util.JSPUtility"%> <%@page import="java.util.Map"%> <%@page import="java.util.List"%> <%@include file="header.jsp"%>
<% OpenBookService service = (OpenBookService)session.getAttribute(KEY_SERVICE); if (service == null) { %> <% } if (ACTION_DELIVER.equals(request.getParameter(KEY_ACTION))) { String oid = request.getParameter(KEY_OID); PurchaseOrder order = (PurchaseOrder)session.getAttribute(oid); service.deliver(order); } Customer customer = (Customer)session.getAttribute(KEY_USER); List orders = service.getOrders(null, customer); %> All <%= orders.size() %> Purchase Order placed by <%= customer.getName() %> is shown. The Deliver button will deliver the pending order. Delivery of a pending order
  1. decrements inventory of all associated LineItems
  2. changes status to ORDERED and finally
  3. nullifies the association between Purchase Order and Line Items. Nullifying the association has the important side-effect of deleting the line items from the database because Purchase Order and Line Items relation is annotated as orphan delete.

<% int i = 0; for (PurchaseOrder order : orders) { session.setAttribute(""+order.getId(), order); %> <% if (order.getStatus().equals(PurchaseOrder.Status.PENDING)) { %> <% } else { %> <% } %> <% } %>
<%= customer.getName() %> placed <%= orders.size() %> orders
ID Total Placed On Status Delivered On
Continue Shopping
<%= order.getId() %> <%= order.getTotal() %> <%= JSPUtility.format(order.getPlacedOn()) %> <%= order.getStatus() %> Deliver <%= JSPUtility.format(order.getDeliveredOn()) %>
<% if (ACTION_DETAILS.equals(request.getParameter(KEY_ACTION))) { String oid = request.getParameter(KEY_OID); PurchaseOrder order = (PurchaseOrder)session.getAttribute(oid); List items = order.getItems(); if (items != null && order.getStatus().equals(PurchaseOrder.Status.PENDING)) { %> <% int j = 0; for (LineItem item : items) { %> <% } %>
<%= items.size() %> line items of Order <%= order.getId() %>
Title Price Quantity Cost
<%= item.getBook().getTitle() %> <%= JSPUtility.format(item.getBook().getPrice()) %> <%= item.getQuantity() %> <%= JSPUtility.format(item.getBook().getPrice() * item.getQuantity()) %>
Total<%= JSPUtility.format(order.getTotal()) %>
<% } } %>
<%@include file="footer.jsp"%>