|
|
|
@ -6,7 +6,6 @@ import javax.annotation.PostConstruct; |
|
|
|
|
import javax.faces.event.AjaxBehaviorEvent; |
|
|
|
|
import javax.faces.model.DataModel; |
|
|
|
|
import javax.faces.model.ListDataModel; |
|
|
|
|
import javax.faces.model.SelectItem; |
|
|
|
|
import javax.faces.view.ViewScoped; |
|
|
|
|
import javax.inject.Inject; |
|
|
|
|
import javax.inject.Named; |
|
|
|
@ -14,11 +13,8 @@ import javax.inject.Named; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import com.mousetech.gourmetj.UserSession; |
|
|
|
|
import com.mousetech.gourmetj.persistence.model.Category; |
|
|
|
|
import com.mousetech.gourmetj.persistence.model.Recipe; |
|
|
|
|
import com.mousetech.gourmetj.persistence.service.RecipeService; |
|
|
|
|
|
|
|
|
@ -158,21 +154,25 @@ public class AdminMainBean implements Serializable { |
|
|
|
|
public String doFind() { |
|
|
|
|
List<Recipe> recipes = null; |
|
|
|
|
|
|
|
|
|
switch (this.getSearchType()) { |
|
|
|
|
switch (this.getUserSession().getSearchType()) { |
|
|
|
|
case rst_BY_NAME: |
|
|
|
|
recipes = recipeService.findByTitle(searchText); |
|
|
|
|
break; |
|
|
|
|
case rst_BY_CATEGORY: |
|
|
|
|
recipes = recipeService.findByCategoryLike(searchText); |
|
|
|
|
recipes = |
|
|
|
|
recipeService.findByCategoryLike(searchText); |
|
|
|
|
break; |
|
|
|
|
case rst_BY_CUISINE: |
|
|
|
|
recipes = recipeService.findByCuisineLike(searchText); |
|
|
|
|
recipes = |
|
|
|
|
recipeService.findByCuisineLike(searchText); |
|
|
|
|
break; |
|
|
|
|
case rst_BY_INGREDIENT: |
|
|
|
|
recipes = recipeService.findByIngredientLike(searchText); |
|
|
|
|
recipes = recipeService |
|
|
|
|
.findByIngredientLike(searchText); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
log.error("Invalid recipe search type: " + this.getSearchType()); |
|
|
|
|
log.error("Invalid recipe search type: " |
|
|
|
|
+ this.getUserSession().getSearchType()); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -233,49 +233,4 @@ public class AdminMainBean implements Serializable { |
|
|
|
|
} |
|
|
|
|
return sb.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ***
|
|
|
|
|
|
|
|
|
|
private RecipeSearchType searchType = |
|
|
|
|
RecipeSearchType.rst_BY_NAME; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the searchType |
|
|
|
|
*/ |
|
|
|
|
public RecipeSearchType getSearchType() { |
|
|
|
|
return searchType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param searchType the searchType to set |
|
|
|
|
*/ |
|
|
|
|
public void setSearchType(RecipeSearchType searchType) { |
|
|
|
|
this.searchType = searchType; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<SelectItem> searchTypeList; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @return the searchTypeList |
|
|
|
|
*/ |
|
|
|
|
public List<SelectItem> getSearchTypeList() { |
|
|
|
|
if (searchTypeList == null) { |
|
|
|
|
searchTypeList = loadSearchTypeList(); |
|
|
|
|
} |
|
|
|
|
return searchTypeList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<SelectItem> loadSearchTypeList() { |
|
|
|
|
List<SelectItem> list = new ArrayList<SelectItem>(5); |
|
|
|
|
list.add(new SelectItem(RecipeSearchType.rst_BY_NAME, |
|
|
|
|
"Title")); |
|
|
|
|
list.add(new SelectItem(RecipeSearchType.rst_BY_CATEGORY, |
|
|
|
|
"Category")); |
|
|
|
|
list.add(new SelectItem(RecipeSearchType.rst_BY_CUISINE, |
|
|
|
|
"Cuisine")); |
|
|
|
|
list.add( |
|
|
|
|
new SelectItem(RecipeSearchType.rst_BY_INGREDIENT, |
|
|
|
|
"Ingredient")); |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|