public String deleteMenu() {
    if (resources.removeMenu(this.menuId)) return "delSuccess";

    FacesContext.getCurrentInstance()
        .addMessage(
            null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error Deleting Entry", null));
    return "delFail";
  }
  public String uploadFile() {
    Menu menu = resources.getMenu(menuId);
    if (file == null) return "failure";

    String basePath = Util.getBasePath();
    String filePath = Paths.get(basePath, Util.getFileName(file.getSubmittedFileName())).toString();

    File saveFile = new File(filePath);
    if (!saveFile.exists()) {
      try {
        saveFile.createNewFile();
        FileOutputStream os = new FileOutputStream(saveFile);
        ByteStreams.copy(file.getInputStream(), os);
        os.close();
      } catch (Exception e) {
        e.printStackTrace();
        return "failure";
      }
    }
    menu.setImgPath(Paths.get("img", Util.getFileName(file.getSubmittedFileName())).toString());
    resources.updateMenu(menu);
    return "success";
  }
 public String createNewMenu() {
   Menu menu = new Menu();
   menu.setMenuName(menuName);
   if (!resources.persistMenu(menu)) {
     FacesContext.getCurrentInstance()
         .addMessage(
             null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "An error occurred!", null));
     return "createFail";
   }
   FacesContext.getCurrentInstance()
       .addMessage(
           null,
           new FacesMessage(
               FacesMessage.SEVERITY_INFO,
               "New Menu Item \"" + menu.getMenuName() + "\" created!",
               null));
   return "createSuccess";
 }
  public List<Food> getFoodsNotOnCurrentMenu() {
    List<Food> list = resources.getFoods();
    List<Food> result = new ArrayList<Food>();
    List<Food> myFoods = this.getAdminSession().getWorkingMenu().getFoods();

    for (Food food : list) {
      boolean addToRes = true;
      for (Food myFood : myFoods) {
        if (myFood.getFoodid() == food.getFoodid()) {
          addToRes = false;
          break;
        }
      }
      if (addToRes) result.add(food);
    }

    return result;
  }
 public List<Menu> getMenus() {
   return resources.getMenus();
 }
 public String setDescFor(Menu menu) {
   menu.setDescription(getEditText());
   setEditText("");
   resources.updateMenu(menu);
   return "success";
 }
 public String editMenu() {
   adminSession.setWorkingMenu(resources.getMenu(this.getMenuId()));
   return "goToEditPage";
 }