Example #1
0
  public String saveConfigure() throws Exception {
    try {

      List<Item> allItems = new ArrayList<Item>();
      allItems.add(milk);
      allItems.add(eggs);
      allItems.add(juice);
      allItems.add(veggies);
      itemService.saveAllItems(allItems);
      return "reloadMinMax";
    } catch (Exception e) {
      return "error";
    }
  }
Example #2
0
  public String execute() throws Exception {

    try {
      if (configureValue.equals("minmax")
          || configureValue.equals("additems")
          || configureValue.equals("consumeitems")
          || configureValue.equals("shoppinglist")
          || configureValue.equals("statusitems")) {
        List<Item> allItems = itemService.getAllItems();
        for (Item item : allItems) {
          if (item.getItemName().equals("Milk")) {
            milk = new Milk(item);
          }
          if (item.getItemName().equals("Eggs")) {
            eggs = new Eggs(item);
          }
          if (item.getItemName().equals("Juice")) {
            juice = new Juice(item);
          }
          if (item.getItemName().equals("Vegetables")) {
            veggies = new Vegetables(item);
          }
        }

        if (configureValue.equals("shoppinglist")) {
          milk.setNewQuantity(milk.getMaxQuant() - milk.getQuantity());
          eggs.setNewQuantity(eggs.getMaxQuant() - eggs.getQuantity());
          juice.setNewQuantity(juice.getMaxQuant() - juice.getQuantity());
          veggies.setNewQuantity(veggies.getMaxQuant() - veggies.getQuantity());
        }

        if (configureValue.equals("statusitems")) {
          setItemStatusColor(milk);
          setItemStatusColor(eggs);
          setItemStatusColor(juice);
          setItemStatusColor(veggies);
        }

      } else if (configureValue.equals("resetpassword")) {
        oldPassword = loginValidate.getPassword();
      } else if (configureValue.equals("configuremail")) {
        oldEmailAddress = loginValidate.getEmailAddress();
      }
      return configureValue;
    } catch (Exception e) {
      return "error";
    }
  }
Example #3
0
 public String sendShoppingList() throws Exception {
   try {
     List<Item> allItems = new ArrayList<Item>();
     allItems.add(milk);
     allItems.add(eggs);
     allItems.add(juice);
     allItems.add(veggies);
     itemService.sendShoppingList(allItems);
     if (orderType.equals("Print")) {
       return "reloadPrintShopList";
     } else {
       return "reloadOrderShopList";
     }
   } catch (Exception e) {
     return "error";
   }
 }
Example #4
0
 public String saveConsumeItems() throws Exception {
   try {
     List<Item> allItems = new ArrayList<Item>();
     milk.setQuantity(milk.getQuantity() - milk.getNewQuantity());
     eggs.setQuantity(eggs.getQuantity() - eggs.getNewQuantity());
     juice.setQuantity(juice.getQuantity() - juice.getNewQuantity());
     veggies.setQuantity(veggies.getQuantity() - veggies.getNewQuantity());
     allItems.add(milk);
     allItems.add(eggs);
     allItems.add(juice);
     allItems.add(veggies);
     itemService.saveAllItems(allItems);
     return "reloadAddItems";
   } catch (Exception e) {
     return "error";
   }
 }