Class AdvancedQueryBuilder

  • public class AdvancedQueryBuilder
    extends Object
    Translates an advanced criteria/filter object into a HQL query. Also takes into account session and other parameters.
    • Constructor Detail

      • AdvancedQueryBuilder

        public AdvancedQueryBuilder()
    • Method Detail

      • getEntity

        public Entity getEntity()
      • setEntity

        public void setEntity​(String entityName)
      • setEntity

        public void setEntity​(Entity entity)
      • getWhereClause

        public String getWhereClause()
        Translates the filter criteria (addFilterParameter(String, String)) to a valid HQL where clause (without the 'where' keyword). After calling this method the method getNamedParameters() can be called. Note that currently only filtering on string and boolean properties is supported. Also filtering on the identifier of a referenced business object is supported.
        a valid where clause or an empty string if not set.
      • getHqlOperator

        public static String getHqlOperator​(String operator)
      • getJoinClause

        public String getJoinClause()
        an empty String if there is no join clause, in other cases a String like the following is returned " as e left join as alias_1"
      • getOrderByClause

        public String getOrderByClause()
        Converts the value of the sortBy member into a valid order by clause in a HQL query. The method handles special cases as sorting by the identifier properties and descending which is controlled with a minus sign before the property name.
        a valid order by clause (or an empty string if no sorting)
      • getOrderByClausePart

        protected String getOrderByClausePart​(String orderByParam)
      • hasOrganizationParameter

        public boolean hasOrganizationParameter()
        true if one of the filter parameters is the JsonConstants.ORG_PARAMETER.
      • addFilterParameter

        public void addFilterParameter​(String key,
                                       String value)
        Add a filter parameter, the method getWhereClause() will try to convert the String value to a typed parameter.
        key - the filter key, can be direct property or a referenced property.
        value - the value as a String
      • getNamedParameters

        public Map<String,​Object> getNamedParameters()
        Gets the named parameters of the query to build
        a map whose keys are the parameter names and the values the parameter values
      • addNamedParameter

        public String addNamedParameter​(Object value)
        Adds a named parameter for the query to be built
        value - the value for the query parameter
        the parameter name as it is used in the query
      • setDoOr

        public void setDoOr​(boolean doOr)
      • getMainAlias

        public String getMainAlias()
      • setMainAlias

        public void setMainAlias​(String mainAlias)
      • getOrderBy

        public String getOrderBy()
      • setOrderBy

        public void setOrderBy​(String orderBy)
      • getCriteria

        public org.codehaus.jettison.json.JSONObject getCriteria()
      • setCriteria

        public void setCriteria​(org.codehaus.jettison.json.JSONObject criteria)
      • isJoinAssociatedEntities

        public boolean isJoinAssociatedEntities()
      • setJoinAssociatedEntities

        public void setJoinAssociatedEntities​(boolean joinAssociatedEntities)
      • getAdditionalProperties

        public List<String> getAdditionalProperties()
      • clearCachedValues

        public void clearCachedValues()
      • addSelectFunctionPart

        public void addSelectFunctionPart​(String function,
                                          String field)
      • addSelectClausePart

        public void addSelectClausePart​(String selectClausePart)
      • getSelectClause

        public String getSelectClause()
      • setAdditionalProperties

        public void setAdditionalProperties​(List<String> additionalProperties)
      • setSubEntityName

        public void setSubEntityName​(String subEntityName)
      • setSubDataEntityQueryService

        public void setSubDataEntityQueryService​(DataEntityQueryService dataEntityQueryService)
      • setDistinctProperty

        public void setDistinctProperty​(Property distinctProperty)
      • preventCreatingJoinsInWhereClause

        public void preventCreatingJoinsInWhereClause​(boolean preventedCreatingJoinsInWhereClause)
        Allows preventing the creation of new join alias when the where clause is built. This is useful when the AdvancedQueryBuilder is used to obtain the WHERE clause, but when the FROM clause built is not used (i.e. en HQLDataSourceService)
        preventedCreatingJoinsInWhereClause - If true, the creation of new join alias is prevented when the where clause is built