Package com.saperion.util
Class FederatedQueryBuilder
- java.lang.Object
-
- com.saperion.util.FederatedQueryBuilder
-
public class FederatedQueryBuilder extends java.lang.ObjectThe 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 QueryStrategystrategyThe QueryStrategy used by this query builder.
-
Constructor Summary
Constructors Constructor Description FederatedQueryBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringbuildQueryReplacement(java.util.Properties templateProperties, java.lang.String ddc, java.lang.String query)Builds the HQL query with the configured QueryStrategy by the given parameters.booleanisSpecialQuery(java.lang.String query)Indicates if the given query is a 'special' query on basis of the configured strategy.voidsetQueryStrategy(QueryStrategy queryStrategy)Sets the query strategy.voidsetQueryStrategy(java.lang.String className)Sets the query strategy as classname.
-
-
-
Field Detail
-
strategy
protected QueryStrategy strategy
The QueryStrategy used by this query builder.
-
-
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.ExceptionIndicates if the given query is a 'special' query on basis of the configured strategy. Special queries need to be replaced by the methodbuildQueryReplacementbefore 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.ExceptionBuilds 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.
-
-