forked from Luke-Sikina/picsure-search-refinement
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add FilterProcessor to handle filter processing logic
Introduced a new FilterProcessor component to centralize filter processing logic. Enhanced getDescription, getParentName, and getParentDisplay methods in MetadataResultSetUtil for better validation using StringUtils.
- Loading branch information
Showing
4 changed files
with
60 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/edu/harvard/dbmi/avillach/dictionary/filter/FilterProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package edu.harvard.dbmi.avillach.dictionary.filter; | ||
|
||
import edu.harvard.dbmi.avillach.dictionary.facet.Facet; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
|
||
@Component | ||
public class FilterProcessor { | ||
|
||
public Filter processsFilter(Filter filter) { | ||
List<Facet> newFacets = filter.facets(); | ||
List<String> newConsents = filter.consents(); | ||
if (filter.facets() != null) { | ||
newFacets = new ArrayList<>(filter.facets()); | ||
newFacets.sort(Comparator.comparing(Facet::name)); | ||
} | ||
if (filter.consents() != null) { | ||
newConsents = new ArrayList<>(newConsents); | ||
newConsents.sort(Comparator.comparing(Function.identity())); | ||
} | ||
filter = new Filter(newFacets, filter.search(), newConsents); | ||
|
||
if (StringUtils.hasLength(filter.search())) { | ||
filter = new Filter(filter.facets(), filter.search().replaceAll("_", "/"), filter.consents()); | ||
} | ||
return filter; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters