Package io.jmix.rest.impl.service.filter
Class RestFilterParser
java.lang.Object
io.jmix.rest.impl.service.filter.RestFilterParser
Class for REST API search filter JSON parsing
-
Field Summary
Modifier and TypeFieldDescriptionprotected Metadata
protected MetadataTools
protected RestFilterOpManager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
collectQueryParameters
(RestFilterCondition condition, Map<String, Object> queryParameters) protected RestFilterOp
findOperator
(String stringOp) protected String
Parses the JSON with entities filter and returns an object with JPQL query string and query parameters.protected RestFilterCondition
parseConditionObject
(com.google.gson.JsonObject jsonConditionObject, MetaClass metaClass) protected RestFilterGroupCondition
parseGroupCondition
(com.google.gson.JsonObject conditionJsonObject, MetaClass metaClass) protected RestFilterPropertyCondition
parsePropertyCondition
(com.google.gson.JsonObject conditionJsonObject, MetaClass metaClass) protected Object
parseValue
(MetaProperty metaProperty, String stringValue) protected boolean
shouldAddPkNameToPropertyPath
(MetaProperty metaProperty, RestFilterOp op) protected Object
transformValue
(Object value, RestFilterOp operator)
-
Field Details
-
metadata
-
metadataTools
-
restFilterOpManager
-
-
Constructor Details
-
RestFilterParser
public RestFilterParser()
-
-
Method Details
-
parse
public RestFilterParseResult parse(String filterJson, MetaClass metaClass) throws RestFilterParseException Parses the JSON with entities filter and returns an object with JPQL query string and query parameters. The method expects a JSON object like this:{ "conditions": [ { "group": "OR", "conditions": [ { "property": "stringField", "operator": "<>", "value": "stringValue" }, { "property": "intField", "operator": ">", "value": 100 } ] }, { "property": "booleanField", "operator": "=", "value": true } ] }
Conditions here may be of two types: property condition and group condition (AND and OR) . Root conditions are automatically placed to the group condition of type AND.
- Throws:
RestFilterParseException
-
collectQueryParameters
protected void collectQueryParameters(RestFilterCondition condition, Map<String, Object> queryParameters) -
parseConditionObject
protected RestFilterCondition parseConditionObject(com.google.gson.JsonObject jsonConditionObject, MetaClass metaClass) throws RestFilterParseException - Throws:
RestFilterParseException
-
parseGroupCondition
protected RestFilterGroupCondition parseGroupCondition(com.google.gson.JsonObject conditionJsonObject, MetaClass metaClass) throws RestFilterParseException - Throws:
RestFilterParseException
-
parsePropertyCondition
protected RestFilterPropertyCondition parsePropertyCondition(com.google.gson.JsonObject conditionJsonObject, MetaClass metaClass) throws RestFilterParseException - Throws:
RestFilterParseException
-
shouldAddPkNameToPropertyPath
-
parseValue
protected Object parseValue(MetaProperty metaProperty, String stringValue) throws RestFilterParseException - Throws:
RestFilterParseException
-
findOperator
- Throws:
RestFilterParseException
-
transformValue
-
generateQueryParamName
-