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) @Query(name = "Recipe.findCusines", nativeQuery = true)
List<String> FindCuisinesNative(); 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

@ -35,13 +35,14 @@ public class RecipeService implements Serializable {
@Inject @Inject
private RecipeRepository recipeRepository; private RecipeRepository recipeRepository;
public List<Recipe> findAll() { public List<Recipe> findAll() {
return recipeRepository.findAll(); return recipeRepository.findAll();
} }
public List<Recipe> findByTitle(String searchText) { public List<Recipe> findByTitle(String searchText) {
return recipeRepository.findByTitleContaining(searchText); return recipeRepository
.findByTitleContaining(searchText);
} }
public Recipe findByPrimaryKey(Long recipeId) { public Recipe findByPrimaryKey(Long recipeId) {
@ -50,30 +51,28 @@ public class RecipeService implements Serializable {
public Recipe findDetails(Long recipeId) { public Recipe findDetails(Long recipeId) {
return recipeRepository.findDetailsById(recipeId); return recipeRepository.findDetailsById(recipeId);
} }
/** /**
* final String sql = "SELECT DISTINCT cuisine from recipe" * final String sql = "SELECT DISTINCT cuisine from recipe" +
+ " where cuisine is not null and cuisine <> ''" * " where cuisine is not null and cuisine <> ''" + " ORDER
+ " ORDER BY cuisine ASC"; * BY cuisine ASC";
*
* @return * @return
*/ */
public List<String> findCuisines() { public List<String> findCuisines() {
return recipeRepository.FindCuisinesNative(); return recipeRepository.FindCuisinesNative();
} }
public void save(Recipe recipe) { public void save(Recipe recipe) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public void delete(Recipe recipe) { public void delete(Recipe recipe) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
public List<String> findShoppingCategories() { public List<String> findShoppingCategories() {
@ -81,16 +80,15 @@ public class RecipeService implements Serializable {
return null; return null;
} }
public List<String> findCategories() { @Inject
// TODO Auto-generated method stub CategoryRepository categoryRepository;
return null;
}
// /** /**
// * *
// * @return All Category names that are not null/blank, sorted. * @return All Category names that are not null/blank,
// */ * sorted.
// public List<String> findCategoryNames() { */
// return categoryRepository.findDistinctCategoryNative(); public List<String> findCategories() {
// } return categoryRepository.findDistinctCategoryNative();
}
} }

View File

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