private static void processUpdate(String type, String id, String att, String value) {
   if (type == null || type.trim().length() == 0) return;
   if ("Order".equals(type)) {
     PurchaseOrder order = PurchaseOrder.findById(new Long(id));
     if ("paid".equals(att)) {
       Boolean oldValue = order.paid;
       if (oldValue == null) oldValue = Boolean.FALSE;
       order.paid = !oldValue;
       if (oldValue) setCurrentUseCaseName("Order unpaid");
       else setCurrentUseCaseName("Order paid");
     } else if ("customer".equals(att)) {
       if (value == null
           || value.startsWith(
               "- ")) // Do nothing if somehow the "- select a customer -" item was selected
       return;
       Customer customer = Customer.findById(new Long(value));
       order.customer = customer;
       Flash.current().success("The order has been reassigned to customer " + customer.name);
       setCurrentUseCaseName("Order reassigned");
     } else if ("notes".equals(att)) {
       order.notes = value;
       setCurrentUseCaseName("Order notes updated");
     }
     order.save();
   } else if ("Customer".equals(type)) {
     Customer customer = Customer.findById(new Long(id));
     if ("creditLimit".equals(att)) {
       BigDecimal val = NumberFormat.parseMoney(value);
       customer.creditLimit = val;
       setCurrentUseCaseName("Customer credit limit updated");
     }
     customer.save();
   } else if ("LineItem".equals(type)) {
     LineItem lineitem = LineItem.findById(new Long(id));
     if ("quantity".equals(att)) {
       Integer val = NumberFormat.parseNumber(value);
       lineitem.qtyOrdered = val;
       setCurrentUseCaseName("Line Item quantity updated");
     } else if ("unitPrice".equals(att)) {
       BigDecimal val = NumberFormat.parseMoney(value);
       lineitem.productPrice = val;
       setCurrentUseCaseName("Line Item unit price updated");
     } else if ("product".equals(att)) {
       Product product = Product.findById(new Long(value));
       lineitem.product = product;
       setCurrentUseCaseName("Line Item product changed");
     }
     lineitem.save();
   }
 }
 private static void processInsert(
     String custId, String type, String id, String att, String value) {
   if (type == null || type.trim().length() == 0) return;
   if ("LineItem".equals(type)) {
     PurchaseOrder order = PurchaseOrder.findById(new Long(id));
     Product product = Product.findById(new Long(1));
     LineItem newItem = new LineItem();
     newItem.purchaseOrder = order;
     order.lineItems.add(newItem);
     newItem.product = product;
     product.lineItems.add(newItem);
     newItem.qtyOrdered = 1;
     setCurrentUseCaseName("New Line Item created");
     newItem.save();
   } else if ("Order".equals(type)) {
     Customer customer = Customer.findById(new Long(custId));
     PurchaseOrder newOrder = new PurchaseOrder();
     newOrder.customer = customer;
     newOrder.paid = Boolean.FALSE;
     newOrder.notes = "";
     setCurrentUseCaseName("New Order created");
     newOrder.save();
   }
 }