Class FederatedQueryBuilder

java.lang.Object
com.saperion.util.FederatedQueryBuilder

public class FederatedQueryBuilder extends Object
The FederatedQueryBuilder can be used to build QueryStrategy dependent HQL queries based on the users search term.
Author:
sts
  • Field Details

    • strategy

      protected QueryStrategy strategy
      The QueryStrategy used by this query builder.
  • Constructor Details

    • FederatedQueryBuilder

      public FederatedQueryBuilder()
  • Method Details

    • setQueryStrategy

      public void setQueryStrategy(String className)
      Sets the query strategy as classname. The given className will be used to load according class.
      Parameters:
      className - The class name to be used to dynamically load the query strategy.
    • setQueryStrategy

      public void setQueryStrategy(QueryStrategy queryStrategy)
      Sets the query strategy. The given className will be used to load according class.
      Parameters:
      queryStrategy - The QueryStrategy to be used by this query builder.
    • isSpecialQuery

      public boolean isSpecialQuery(String query) throws Exception
      Indicates if the given query is a 'special' query on basis of the configured strategy. Special queries need to be replaced by the method buildQueryReplacement before they can be invoked.
      Parameters:
      query - The query in question.
      Returns:
      true the given query is a special query.
      Throws:
      Exception - if no QueryStrategy is set.
    • buildQueryReplacement

      public String buildQueryReplacement(Properties templateProperties, String ddc, String query) throws Exception
      Builds the HQL query with the configured QueryStrategy by the given parameters. According to the QueryStrategy and properties a HQL query will be build from the given query.
      Parameters:
      templateProperties - The properties to be used.
      ddc - The DDC name to be used.
      query - The original query to be replaced.
      Returns:
      The built HQL query.
      Throws:
      Exception - if no QueryStrategy is set.