re-activated category suggestions

This commit is contained in:
Tim Holloway 2021-12-31 09:28:09 -05:00
parent 3b0342429f
commit c051751e10
3 changed files with 38 additions and 41 deletions

View File

@ -31,13 +31,4 @@ public interface RecipeRepository
@Query(name = "Recipe.findCusines", nativeQuery = true)
List<String> 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<String> findDistinctCategoryNative();
}

View File

@ -41,7 +41,8 @@ public class RecipeService implements Serializable {
}
public List<Recipe> findByTitle(String searchText) {
return recipeRepository.findByTitleContaining(searchText);
return recipeRepository
.findByTitleContaining(searchText);
}
public Recipe findByPrimaryKey(Long recipeId) {
@ -52,12 +53,11 @@ public class RecipeService implements Serializable {
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
*/
@ -65,7 +65,6 @@ public class RecipeService implements Serializable {
return recipeRepository.FindCuisinesNative();
}
public void save(Recipe recipe) {
// TODO Auto-generated method stub
@ -81,16 +80,15 @@ public class RecipeService implements Serializable {
return null;
}
public List<String> findCategories() {
// TODO Auto-generated method stub
return null;
}
@Inject
CategoryRepository categoryRepository;
// /**
// *
// * @return All Category names that are not null/blank, sorted.
// */
// public List<String> findCategoryNames() {
// return categoryRepository.findDistinctCategoryNative();
// }
/**
*
* @return All Category names that are not null/blank,
* sorted.
*/
public List<String> findCategories() {
return categoryRepository.findDistinctCategoryNative();
}
}

View File

@ -53,13 +53,15 @@
label="Category"
value="#{recipeDetailBean.category}"
tip="One or more categories, separated by commas (ex: Entree, Soup)"
/>
<p:commandButton
value="&lt;- Suggest"
>
<f:ajax execute="rcategory"
<f:ajax execute="rcategory bxCat"
listener="#{recipeDetailBean.ajaxSuggestCategory}"
render="rcategory"
/>
</p:inputText>
<p:button value="&lt;- Suggest">
</p:button>
</p:commandButton>
<p:selectOneMenu id="bxCat"
value="#{recipeDetailBean.catToAdd}"
tip="Recipe category suggestions, based on previous selections"
@ -200,7 +202,8 @@
<p:column label="Amt"
style="width: 4em"
>
<p:inputText id="ingAmt" size="5"
<p:inputText id="ingAmt"
size="5"
value="#{item.displayAmount}"
style="text-align: right"
rendered="#{not item.ingGroup}"
@ -211,13 +214,17 @@
style="width: 7em"
>
<p:inputText id="ingUnit"
value="#{item.unit}" size="10"
value="#{item.unit}"
size="10"
rendered="#{not item.ingGroup}"
>
</p:inputText>
</p:column>
<p:column label="Item" style="width: 22em">
<p:inputText id="ingItem" size="35"
<p:column label="Item"
style="width: 22em"
>
<p:inputText id="ingItem"
size="35"
value="#{item.item}"
>
</p:inputText>
@ -234,7 +241,8 @@
</p:column>
<p:column label="Key">
<p:inputText id="ingKey"
value="#{item.ingkey}" size="20"
value="#{item.ingkey}"
size="20"
rendered="#{not item.ingGroup}"
/>
</p:column>