Package adios.model

Examples of adios.model.Recipe


     * returns a recipe for a recipe Id
     * @param id
     * @return
     */
    public Recipe getRecipe(int id){
      Recipe r=null;
      try{
        r =  recipeDao.getRecipeForId(id);
       
      }catch(Exception ex){
        Log.info("ERROR ::: getting Recipe!!!");
View Full Code Here


      try{
        recipeDao.persist(r);
        r = recipeDao.getRecipeForUserIdAndName(r.getUserId(), r.getName());     
      }catch(Exception ex){
        Log.info("WARNING ::: recipe already in db");
        Recipe oldRecipe = recipeDao.getRecipeForUserIdAndName(r.getUserId(), r.getName());
        r.setRecipeId(oldRecipe.getRecipeId());
        recipeDao.update(r);
      }     
      return r;
    }
View Full Code Here

      @RequestMapping(value="/receta/{recipeId}.html", method = RequestMethod.GET)
      public ModelAndView getRecipe(@PathVariable int recipeId,HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          Log.info("/receta/{recipeId}.html");
         
          Recipe r=new Recipe();
          r.setRecipeId(recipeId);
         
          Ingredient4Recipe i4r = new Ingredient4Recipe();
          i4r.setRecipeId(r.getRecipeId());
         
          ArrayList<Ingredient4Recipe> i4rList =  ingredientService.getIngredientsForRecipe(i4r);
         
        ModelAndView view = new ModelAndView("html/recipePage");
        view.addObject("recipe", recipeService.getRecipe(recipeId));
View Full Code Here

          .add("Se elabora frotando tomate crudo y maduro sobre una rebanada de pan, preferiblemente de pagès (pan de payés)");
      instructions.add("Coratar los tomates por la mitad");
      instructions.add("Untar el tomate");
      instructions.add("Aliñado al gusto con sal y aceite de oliva");

      Recipe recip = new Recipe(name, desc, externalMedia,imageName, userId,
          instructions);

      recipeDao.persist(recip);

      name=name+"2";
      imageName = u.getUserId()+name.replace(" ","");
      imageName = imageName+".jpg";

      recip = new Recipe(name, desc, externalMedia,imageName, userId, instructions);
      recipeDao.persist(recip);
     
    } catch (Exception es) {
      Log.error("exception, already in database");
    }
View Full Code Here

            Set<Integer> recipesIdSet = recipesCartMap.keySet();
            Iterator<Integer> recipesIdIter = recipesIdSet.iterator();

            while(recipesIdIter.hasNext()){
              Integer i =recipesIdIter.next();
              Recipe r = recipeService.getRecipe(i.intValue());
              rList.add(r);
         
          Ingredient4Recipe i4r = new Ingredient4Recipe();
              i4r.setRecipeId(r.getRecipeId());
              ArrayList<Ingredient4Recipe> i4rList =  ingredientService.getIngredientsForRecipe(i4r);
          Iterator<Ingredient4Recipe> i4rIter = i4rList.iterator();
              while (i4rIter.hasNext()){
                i4r = i4rIter.next();
                if(ingHT.containsKey(i4r.getName())){
View Full Code Here

           if (recipesFavsMap!= null){
             Set<Integer> recipesIdSet = recipesFavsMap.keySet();
            Iterator<Integer> recipesIdIter = recipesIdSet.iterator();
            while(recipesIdIter.hasNext()){
              Integer i =recipesIdIter.next();
              Recipe r = recipeService.getRecipe(i.intValue());
              rList.add(r);
            }
           } 
        ModelAndView view = new ModelAndView("html/mainTemplate");        
        view.addObject("recipeList", rList);  
View Full Code Here

              throws ServletException, IOException {
          Log.info("/receta/editar/{recipeId}.html");

         
         
          Recipe r = recipeService.getRecipe(recipeId);
         
          Ingredient4Recipe i4r = new Ingredient4Recipe();
          i4r.setRecipeId(r.getRecipeId());
         
          ArrayList<Ingredient4Recipe> i4rList =  ingredientService.getIngredientsForRecipe(i4r);
         
        ModelAndView view = new ModelAndView("html/recipePage");
        view.addObject("recipe", recipeService.getRecipe(recipeId));
View Full Code Here

          User u = (User)request.getSession().getAttribute(loginUser);
          int userId = u.getUserId();
         
          String name = request.getParameter("name");
          String desc = request.getParameter("desc");
          Recipe r = new Recipe();
          r.setUserId(userId);
          r.setName(name);
          r.setDescription(desc);
          r = recipeService.createRecipe(r);
          request.getSession().removeAttribute("recipe");
          request.getSession().setAttribute("recipe", r);
          return String.valueOf(r.getRecipeId());
    }
View Full Code Here

      public String addStepToRecipe( HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          Log.info("user/anadirReceta/{step}.html");
          String stepsJsArray = request.getParameter("stepsJsArray");
          try{
          Recipe r = (Recipe)request.getSession().getAttribute("recipe");
         
          Gson gson = new Gson();
          String[] stepsArray = gson.fromJson("["+stepsJsArray+"]", String[].class);
          ArrayList<String> steps = new ArrayList<String>(Arrays.asList(stepsArray));

          r.setInstructions(steps);
          recipeService.updateRecipe(r);
          request.getSession().setAttribute("recipe", r);
          }catch(Exception e){
            return "false";
          }
View Full Code Here

      public String addTagToRecipe( HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          Log.info("user/anadirReceta/{step}.html");
          String tag = request.getParameter("tag");
          try{
          Recipe r = (Recipe)request.getSession().getAttribute("recipe");

         
          Tag t =new Tag();
          t.setName(tag);
          t.setRecipeId(r.getRecipeId());
          tagService.addTag(t);
          request.getSession().setAttribute("recipe", r);
          }catch(Exception e){
            return "false";
          }
View Full Code Here

TOP

Related Classes of adios.model.Recipe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.