예제 #1
0
  /**
   * Saves an ingredient. Before that, it's attached to a recipe.
   *
   * @param recipe
   * @param ingredient
   */
  public static Ingredient saveToRecipe(Long recipe, Ingredient ingredient) {

    Recipe r = Recipe.findById(recipe);
    if (r == null) {
      throw new RuokalistaException("Recipe not found.");
    }

    ingredient.recipe = r;
    save(ingredient);
    return ingredient;
  }
예제 #2
0
 /**
  * Saves given ingredient.
  *
  * @param ingredient
  */
 public static void save(Ingredient ingredient) {
   ingredient.save();
 }