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"; } }
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"; } }