Package org.ametys.cms.search.advanced
Class TreeMaker
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.search.advanced.TreeMaker
- All Implemented Interfaces:
LogEnabled
,Component
Creates a
AbstractTreeNode
from a JSON object, typically got from client-side AdvancedSearchFormPanel.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A wrapper of a client-side criterion -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> AbstractTreeNode<T>
Creates aAbstractTreeNode
from JSON valuesprotected static String
escapeQueryCharsForLikeQuery
(String string, Map<String, Object> contextualParameters) Escape special Solr query characters of the user input, before building the query in order to append '*' character(s)<V extends WrappedValue>
QuerytoQuery
(V value, String stringOperator, BiFunction<V, Query.Operator, Query> toQuery, String language, Map<String, Object> contextualParameters) Gets the query given the parameters.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role.
-
-
Constructor Details
-
TreeMaker
public TreeMaker()
-
-
Method Details
-
create
public <T> AbstractTreeNode<T> create(Map<String, Object> values, Function<TreeMaker.ClientSideCriterionWrapper, T> leafValueMaker) Creates aAbstractTreeNode
from JSON values- Type Parameters:
T
- the type of the values of the leaves of the tree to create- Parameters:
values
- the JSON valuesleafValueMaker
- The function to create the value of aTreeLeaf
- Returns:
- the created
AbstractTreeNode
from JSON values
-
toQuery
public <V extends WrappedValue> Query toQuery(V value, String stringOperator, BiFunction<V, Query.Operator, Query> toQuery, String language, Map<String, Object> contextualParameters) Gets the query given the parameters.
If the provided operator as string represents a real server-sideQuery.Operator
, then it is just the providedBiFunction
which is applied.
Otherwise, the operator is a client-side one, and it will be transformed by modifying the value (by adding wildcards for instance), and deducting the server-sideQuery.Operator
. Then, theBiFunction
is applied with the transformed value and the deductedQuery.Operator
.- Type Parameters:
V
- The type ofWrappedValue
- Parameters:
value
- The valuestringOperator
- The operator as stringtoQuery
- A function applied to a transformed value (not necessarily the one given by the method, as it can be transformed by adding wildcard chars, escaping...) and a realQuery.Operator
(deducted from the given client-side string operator)language
- The languagecontextualParameters
- The contextual parameters- Returns:
- The result query
-
escapeQueryCharsForLikeQuery
protected static String escapeQueryCharsForLikeQuery(String string, Map<String, Object> contextualParameters) Escape special Solr query characters of the user input, before building the query in order to append '*' character(s)- Parameters:
string
- The string to escape.contextualParameters
- the search contextual parameters.- Returns:
- The escaped string.
-