diff --git a/src/main/java/com/mousetech/gourmetj/persistence/dao/RecipeRepository.java b/src/main/java/com/mousetech/gourmetj/persistence/dao/RecipeRepository.java index 37bc10c..058382e 100644 --- a/src/main/java/com/mousetech/gourmetj/persistence/dao/RecipeRepository.java +++ b/src/main/java/com/mousetech/gourmetj/persistence/dao/RecipeRepository.java @@ -31,13 +31,4 @@ public interface RecipeRepository @Query(name = "Recipe.findCusines", nativeQuery = true) List FindCuisinesNative(); - - -// final static String SQL_FIND_CATEGORIES = -// "SELECT DISTINCT category from categories" -// + " where category is not null and category <> ''" -// + " ORDER BY category ASC"; -// -// @Query(value = SQL_FIND_CATEGORIES, nativeQuery = true) -// public List findDistinctCategoryNative(); } diff --git a/src/main/java/com/mousetech/gourmetj/persistence/service/RecipeService.java b/src/main/java/com/mousetech/gourmetj/persistence/service/RecipeService.java index db32a16..0cda6d2 100644 --- a/src/main/java/com/mousetech/gourmetj/persistence/service/RecipeService.java +++ b/src/main/java/com/mousetech/gourmetj/persistence/service/RecipeService.java @@ -35,13 +35,14 @@ public class RecipeService implements Serializable { @Inject private RecipeRepository recipeRepository; - + public List findAll() { return recipeRepository.findAll(); } public List findByTitle(String searchText) { - return recipeRepository.findByTitleContaining(searchText); + return recipeRepository + .findByTitleContaining(searchText); } public Recipe findByPrimaryKey(Long recipeId) { @@ -50,30 +51,28 @@ public class RecipeService implements Serializable { public Recipe findDetails(Long recipeId) { return recipeRepository.findDetailsById(recipeId); - } + } - - /** - * final String sql = "SELECT DISTINCT cuisine from recipe" - + " where cuisine is not null and cuisine <> ''" - + " ORDER BY cuisine ASC"; + * final String sql = "SELECT DISTINCT cuisine from recipe" + + * " where cuisine is not null and cuisine <> ''" + " ORDER + * BY cuisine ASC"; + * * @return */ - + public List findCuisines() { return recipeRepository.FindCuisinesNative(); } - public void save(Recipe recipe) { // TODO Auto-generated method stub - + } public void delete(Recipe recipe) { // TODO Auto-generated method stub - + } public List findShoppingCategories() { @@ -81,16 +80,15 @@ public class RecipeService implements Serializable { return null; } + @Inject + CategoryRepository categoryRepository; + + /** + * + * @return All Category names that are not null/blank, + * sorted. + */ public List findCategories() { - // TODO Auto-generated method stub - return null; + return categoryRepository.findDistinctCategoryNative(); } - -// /** -// * -// * @return All Category names that are not null/blank, sorted. -// */ -// public List findCategoryNames() { -// return categoryRepository.findDistinctCategoryNative(); -// } } diff --git a/src/main/resources/META-INF/resources/detailEdit.xhtml b/src/main/resources/META-INF/resources/detailEdit.xhtml index a0ef9dc..b5f55cc 100644 --- a/src/main/resources/META-INF/resources/detailEdit.xhtml +++ b/src/main/resources/META-INF/resources/detailEdit.xhtml @@ -53,13 +53,15 @@ label="Category" value="#{recipeDetailBean.category}" tip="One or more categories, separated by commas (ex: Entree, Soup)" + /> + - - - - + - - - + @@ -234,7 +241,8 @@