Made searches case-insensitive

This commit is contained in:
tim holloway 2024-02-16 20:13:58 -05:00
parent 77121f9a79
commit a4e70a0739
5 changed files with 18 additions and 12 deletions

View File

@ -7,7 +7,7 @@
<groupId>com.mousetech.gourmet</groupId>
<artifactId>gourmetj</artifactId>
<version>0.2.4</version>
<version>0.2.5</version>
<packaging>jar</packaging>
<name>GourmetJ</name>

View File

@ -7,7 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.mousetech.gourmetj.persistence.model.Category;
import com.mousetech.gourmetj.persistence.model.Recipe;
/**
@ -24,7 +23,7 @@ import com.mousetech.gourmetj.persistence.model.Recipe;
public interface RecipeRepository
extends JpaRepository<Recipe, Long> {
List<Recipe> findByTitleContaining(String searchText);
List<Recipe> findByTitleContainingIgnoreCase(String searchText);
@EntityGraph(value="Recipe.findWorkingSet")
public Recipe findDetailsById(Long recipeId);
@ -32,11 +31,11 @@ public interface RecipeRepository
@Query(name = "Recipe.findCusines", nativeQuery = true)
List<String> FindCuisinesNative();
List<Recipe> findByCategories_CategoryContains(String searchText);
List<Recipe> findByCategories_CategoryContainsIgnoreCase(String searchText);
List<Recipe> findByCuisineContains(String searchText);
List<Recipe> findByCuisineContainsIgnoreCase(String searchText);
List<Recipe> findDistinctByIngredientHash_ItemContains(
List<Recipe> findDistinctByIngredientHash_ItemContainsIgnoreCase(
String searchText);
}

View File

@ -50,7 +50,7 @@ public class RecipeService implements Serializable {
public List<Recipe> findByTitle(String searchText) {
return recipeRepository
.findByTitleContaining(searchText);
.findByTitleContainingIgnoreCase(searchText);
}
public Recipe findByPrimaryKey(Long recipeId) {
@ -120,14 +120,19 @@ public class RecipeService implements Serializable {
}
public List<Recipe> findByCategoryLike(String searchText) {
return recipeRepository.findByCategories_CategoryContains(searchText);
return recipeRepository
.findByCategories_CategoryContainsIgnoreCase(
searchText);
}
public List<Recipe> findByCuisineLike(String searchText) {
return recipeRepository.findByCuisineContains(searchText);
return recipeRepository
.findByCuisineContainsIgnoreCase(searchText);
}
public List<Recipe> findByIngredientLike(String searchText) {
return recipeRepository.findDistinctByIngredientHash_ItemContains(searchText);
return recipeRepository
.findDistinctByIngredientHash_ItemContainsIgnoreCase(
searchText);
}
}

View File

@ -62,9 +62,9 @@
<p:outputLabel for="@next"
value="Title"
/>
<p:focus/>
<p:inputText id="rtitle"
size="45" required="true"
focus="true"
placeholder="A recipe title is required."
value="#{recipeDetailBean.recipe.title}"
>
@ -372,6 +372,7 @@
>
<p:panel header="Instructions">
<div id="insection">
<p:focus/>
<h:inputTextarea
id="ctlInstructions"
rows="30" cols="120"
@ -383,6 +384,7 @@
</p:tab>
<p:tab id="notesTab" title="Notes">
<p:panel header="Notes">
<p:focus/>
<h:inputTextarea id="ctlNotes"
rows="30" cols="120"
escape="false"