Ejemplo n.º 1
0
  @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 int getQuantity() {
   return item.getQuantity();
 }
 public void setQuantity(int quantity) {
   item.setQuantity(quantity);
 }
 public String getName() {
   return item.getName();
 }
 public void setName(String name) {
   item.setName(name);
 }
 public String getItemId() {
   return item.getItemId();
 }
 public void setItemId(String itemId) {
   item.setItemId(itemId);
 }
 @Override
 public void createItem(Item item) {
   _inventory.put(item.getItemId(), item);
 }
 public InventoryServiceBean() {
   Item butter = new Item().setItemId("BUTTER").setName("Not Parkay").setQuantity(1000);
   _inventory.put(butter.getItemId(), butter);
 }