Package com.almis.awe.model.util.data
Class QueryUtil
java.lang.Object
com.almis.awe.config.ServiceConfig
com.almis.awe.model.util.data.QueryUtil
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
Abstract query builder
-
Constructor Summary
ConstructorDescriptionQueryUtil
(BaseConfigProperties baseConfigProperties, DatabaseConfigProperties databaseConfigProperties, com.fasterxml.jackson.databind.ObjectMapper mapper) QueryUtil constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataListToRequestParameters
(DataList dataList, com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previouslyvoid
addToVariableMap
(Map<String, QueryParameter> variableMap, Query query, com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previouslygetDatabaseAlias
(Map<String, QueryParameter> parameters) Retrieve database aliasgetDefaultVariableMap
(com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previouslygetFullSQL
(String sql, List<Object> parameters) Retrieve full sql statement as stringcom.fasterxml.jackson.databind.JsonNode
getParameter
(Variable variable, com.fasterxml.jackson.databind.node.ObjectNode parameters) Retrieve parametercom.fasterxml.jackson.databind.JsonNode
getParameter
(String stringValue, com.fasterxml.jackson.databind.JsonNode parameter, ParameterType type, String variableId) Retrieve parameter as Jsoncom.fasterxml.jackson.databind.node.ObjectNode
Prepare query variables if not defined previouslycom.fasterxml.jackson.databind.node.ObjectNode
getParameters
(@NonNull com.fasterxml.jackson.databind.node.ObjectNode parameters, String alias, String page, String max) Prepare query variables if not defined previouslycom.fasterxml.jackson.databind.node.ObjectNode
getParameters
(com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previouslycom.fasterxml.jackson.databind.node.ObjectNode
getParameters
(String alias) Prepare query variables if not defined previouslycom.fasterxml.jackson.databind.node.ObjectNode
getParameters
(String alias, String page, String max) Prepare query variables if not defined previously<T> com.fasterxml.jackson.databind.node.ObjectNode
getParameters
(T parametersBean) Prepare query variables if not defined previouslycom.fasterxml.jackson.databind.JsonNode
getRequestParameter
(String name) Retrieve parameter from requestcom.fasterxml.jackson.databind.JsonNode
getRequestParameter
(String name, com.fasterxml.jackson.databind.node.ObjectNode parameters) Retrieve parameter from requestgetSortList
(com.fasterxml.jackson.databind.node.ArrayNode sortArrayNode) Generate sort listgetVariableMap
(MaintainQuery query, com.fasterxml.jackson.databind.node.ObjectNode parameters) Get variable map for a single index without listsgetVariableMap
(Query query, com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previouslygetVariableMap
(Query query, String page, String max) Prepare query variables if not defined previouslygetVariableMap
(String page, String max) Prepare query variables if not defined previouslygetVariableMap
(List<Variable> variables, com.fasterxml.jackson.databind.node.ObjectNode parameters, Integer index) Prepare query variables if not defined previouslyboolean
isEmptyParameter
(QueryParameter parameter) Check if a parameter variable is empty or notboolean
isEmptyString
(String value) Check if a string variable is empty or notboolean
isEmptyVariable
(com.fasterxml.jackson.databind.JsonNode variable) Check if a json node variable is empty or notboolean
isNullString
(String value) Check if a string variable is null or notboolean
isNullVariable
(com.fasterxml.jackson.databind.JsonNode variable) Check if a json node variable is null or notboolean
variableIsList
(@NonNull Variable variable, com.fasterxml.jackson.databind.node.ObjectNode parameters) Finds out if a variable value is a listMethods inherited from class com.almis.awe.config.ServiceConfig
containsBean, getApplicationContext, getBean, getBean, getElements, getLocale, getLocale, getProperty, getProperty, getRequest, getSession, setApplicationContext
-
Constructor Details
-
QueryUtil
public QueryUtil(BaseConfigProperties baseConfigProperties, DatabaseConfigProperties databaseConfigProperties, com.fasterxml.jackson.databind.ObjectMapper mapper) QueryUtil constructor- Parameters:
baseConfigProperties
- Base config propertiesdatabaseConfigProperties
- Database config propertiesmapper
- Object mapper
-
-
Method Details
-
getSortList
Generate sort list- Parameters:
sortArrayNode
- Sort parameter- Returns:
- Query parameter map
-
getDefaultVariableMap
public Map<String,QueryParameter> getDefaultVariableMap(com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previously- Parameters:
parameters
- Parameter list- Returns:
- Query parameter map
-
getVariableMap
public Map<String,QueryParameter> getVariableMap(List<Variable> variables, com.fasterxml.jackson.databind.node.ObjectNode parameters, Integer index) throws AWException Prepare query variables if not defined previously- Parameters:
variables
- Variable mapparameters
- Parameter listindex
- Index- Returns:
- Query parameter map
- Throws:
AWException
- Error generating variables
-
getVariableMap
public Map<String,QueryParameter> getVariableMap(Query query, com.fasterxml.jackson.databind.node.ObjectNode parameters) throws AWException Prepare query variables if not defined previously- Parameters:
query
- Queryparameters
- Parameter list- Returns:
- Query parameter map
- Throws:
AWException
- Error generating variables
-
addToVariableMap
public void addToVariableMap(Map<String, QueryParameter> variableMap, Query query, com.fasterxml.jackson.databind.node.ObjectNode parameters) throws AWExceptionPrepare query variables if not defined previously- Parameters:
variableMap
- Variable mapquery
- Query- Throws:
AWException
- Error generating variables
-
addDataListToRequestParameters
public void addDataListToRequestParameters(DataList dataList, com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previously- Parameters:
dataList
- DataList
-
getVariableMap
public Map<String,QueryParameter> getVariableMap(MaintainQuery query, com.fasterxml.jackson.databind.node.ObjectNode parameters) throws AWException Get variable map for a single index without lists- Parameters:
query
- Queryparameters
- Parameter map- Returns:
- Query parameter map
- Throws:
AWException
- Error generating variables
-
getVariableMap
public Map<String,QueryParameter> getVariableMap(Query query, String page, String max) throws AWException Prepare query variables if not defined previously- Parameters:
query
- Querypage
- Page numbermax
- Max elements per page- Returns:
- Query parameter map
- Throws:
AWException
- Error generating variables
-
getParameters
public com.fasterxml.jackson.databind.node.ObjectNode getParameters()Prepare query variables if not defined previously- Returns:
- Query parameter map
-
getParameters
public com.fasterxml.jackson.databind.node.ObjectNode getParameters(com.fasterxml.jackson.databind.node.ObjectNode parameters) Prepare query variables if not defined previously- Parameters:
parameters
- Parameters- Returns:
- Query parameter map
-
getParameters
public <T> com.fasterxml.jackson.databind.node.ObjectNode getParameters(T parametersBean) Prepare query variables if not defined previously- Parameters:
parametersBean
- Parameters bean- Returns:
- Query parameter map
-
getParameters
public com.fasterxml.jackson.databind.node.ObjectNode getParameters(String alias, String page, String max) Prepare query variables if not defined previously- Parameters:
alias
- Database aliaspage
- Page numbermax
- Max elements per page- Returns:
- Query parameter map
-
getParameters
Prepare query variables if not defined previously- Parameters:
alias
- Database alias- Returns:
- Query parameter map
-
getParameters
public com.fasterxml.jackson.databind.node.ObjectNode getParameters(@NonNull @NonNull com.fasterxml.jackson.databind.node.ObjectNode parameters, String alias, String page, String max) Prepare query variables if not defined previously- Parameters:
parameters
- Parametersalias
- Query aliaspage
- Page numbermax
- Max elements per page- Returns:
- Query parameter map
-
getVariableMap
Prepare query variables if not defined previously- Parameters:
page
- Page numbermax
- Max elements per page- Returns:
- Query parameter map
- Throws:
AWException
- Error generating variables
-
getParameter
public com.fasterxml.jackson.databind.JsonNode getParameter(Variable variable, com.fasterxml.jackson.databind.node.ObjectNode parameters) throws AWException Retrieve parameter- Parameters:
variable
- Variableparameters
- Parameters- Returns:
- Parameter
- Throws:
AWException
- Error retrieving variable value
-
getParameter
public com.fasterxml.jackson.databind.JsonNode getParameter(String stringValue, com.fasterxml.jackson.databind.JsonNode parameter, ParameterType type, String variableId) throws AWException Retrieve parameter as Json- Parameters:
stringValue
- String valueparameter
- Parametertype
- TypevariableId
- Variable id- Returns:
- Parameter as JSON
- Throws:
AWException
- Error retrieving variable value
-
getRequestParameter
public com.fasterxml.jackson.databind.JsonNode getRequestParameter(String name, com.fasterxml.jackson.databind.node.ObjectNode parameters) Retrieve parameter from request- Parameters:
name
- Parameter nameparameters
- Parameters list- Returns:
- Parameter
-
getRequestParameter
Retrieve parameter from request- Parameters:
name
- Parameter name- Returns:
- Parameter
-
variableIsList
public boolean variableIsList(@NonNull @NonNull Variable variable, com.fasterxml.jackson.databind.node.ObjectNode parameters) throws AWException Finds out if a variable value is a list- Parameters:
variable
- Variableparameters
- Parameters- Returns:
- isList
- Throws:
AWException
- AWE exception
-
isEmptyString
Check if a string variable is empty or not- Parameters:
value
- String value- Returns:
- String is null or empty
-
isNullString
Check if a string variable is null or not- Parameters:
value
- String value- Returns:
- String is null or empty
-
isEmptyVariable
public boolean isEmptyVariable(com.fasterxml.jackson.databind.JsonNode variable) Check if a json node variable is empty or not- Parameters:
variable
- Variable as json- Returns:
- Variable is empty
-
isNullVariable
public boolean isNullVariable(com.fasterxml.jackson.databind.JsonNode variable) Check if a json node variable is null or not- Parameters:
variable
- Variable as json- Returns:
- Variable is null
-
isEmptyParameter
Check if a parameter variable is empty or not- Parameters:
parameter
- Variable as json- Returns:
- Variable is empty
-
getDatabaseAlias
Retrieve database alias- Parameters:
parameters
- Query parameters- Returns:
- Database alias
-
getFullSQL
Retrieve full sql statement as string- Parameters:
sql
- SQL Statementparameters
- Parameter list- Returns:
- SQL statement
-