Пример #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;
  }