@Override public OrderAck submitOrder(Order order) { System.out.println("--- OrderServiceBean received submitOrder for: " + order); // Create an order ack OrderAck orderAck = new OrderAck().setOrderId(order.getOrderId()); // Check the inventory try { Item orderItem = _inventory.lookupItem(order.getItemId()); // Check quantity on hand and generate the ack if (orderItem.getQuantity() >= order.getQuantity()) { orderAck.setAccepted(true).setStatus("Order Accepted"); } else { orderAck.setAccepted(false).setStatus("Insufficient Quantity"); } } catch (ItemNotFoundException infEx) { orderAck.setAccepted(false).setStatus("Item Not Available"); } System.out.println(orderAck.toString()); return orderAck; }
public void create() { inventory.createItem(item); FacesContext.getCurrentInstance() .addMessage(null, new FacesMessage("Item " + getItemId() + " has been added.")); }