Class FederatedQueryBuilder


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

      Fields 
      Modifier and Type Field Description
      protected QueryStrategy strategy
      The QueryStrategy used by this query builder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String buildQueryReplacement​(java.util.Properties templateProperties, java.lang.String ddc, java.lang.String query)
      Builds the HQL query with the configured QueryStrategy by the given parameters.
      boolean isSpecialQuery​(java.lang.String query)
      Indicates if the given query is a 'special' query on basis of the configured strategy.
      void setQueryStrategy​(QueryStrategy queryStrategy)
      Sets the query strategy.
      void setQueryStrategy​(java.lang.String className)
      Sets the query strategy as classname.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • strategy

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

      • FederatedQueryBuilder

        public FederatedQueryBuilder()
    • Method Detail

      • setQueryStrategy

        public void setQueryStrategy​(java.lang.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​(java.lang.String query)
                               throws java.lang.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:
        java.lang.Exception - if no QueryStrategy is set.
      • buildQueryReplacement

        public java.lang.String buildQueryReplacement​(java.util.Properties templateProperties,
                                                      java.lang.String ddc,
                                                      java.lang.String query)
                                               throws java.lang.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:
        java.lang.Exception - if no QueryStrategy is set.