QueryHelper Class

com.beasys.commerce.ebusiness.catalog.service.query
QueryHelper Class

public class QueryHelper

    extends Object

Helper class for performing Product Catalog queries.


Hierarchy
Object
  QueryHelper

Field Summary

public static final String
DEFAULT_ENTITY_ID_TABLE_NAME
The default entity identifier table
public static final String
DEFAULT_PROPERTY_BOOLEAN_COLUMN_NAME
The default boolean property table
public static final String
DEFAULT_PROPERTY_DATETIME_COLUMN_NAME
The default date/time property table
public static final String
DEFAULT_PROPERTY_FLOAT_COLUMN_NAME
The default float property table
public static final String
DEFAULT_PROPERTY_ID_TABLE_NAME
The default property identifier table
public static final String
DEFAULT_PROPERTY_INTEGER_COLUMN_NAME
The default integer property table
public static final String
DEFAULT_PROPERTY_TEXT_COLUMN_NAME
The default text property table
public static final String
DEFAULT_PROPERTY_VALUE_TABLE
The default property table
public static final String
DEFAULT_TABLE_PREFIX
The default table prefix
 

Constructor Summary

QueryHelper(JdbcCatalogFactory jdbcCatFac, Boolean supportsLikeEscapeClause)

 

Method Summary

public static List
fixKeywords(String[] keywords)
Fix up an array of keywords by removing nulls and duplicates.
protected StringBuffer
getSearchSQL(boolean showAll, List params, boolean isCategory)
Get the SQL where clause for the showAll parameter.
protected StringBuffer
getSearchSQL(String lang, List params, boolean isCategory)
Get the SQL where clause for the lang parameter.
protected StringBuffer
getSearchSQL(List keywords, String logical, List params)
Get the SQL where clause for the keywords.
protected StringBuffer
getSearchSQL(Expression expr, String prefix, boolean supportsLikeEscapeClause, List params, boolean isCategory)
Get the SQL where clause for an expression.
protected void
getSearchSQL(StringBuffer buf, Expression expr, String prefix, boolean supportsLikeEscapeClause, List params, boolean isCategory)
Get the SQL where clause for an expression.
protected void
getSearchSQL(StringBuffer buf, Criteria c, String prefix, boolean supportsLikeEscapeClause, List params, boolean isCategory)
Get the SQL where clause for a Criteria.
protected void
getSearchSQL(StringBuffer buf, String prefix, boolean supportsLikeEscapeClause, String column, String scope, String name, String op, Object val, List params, boolean isCategory)
Get the SQL for searching for an implicit property in a certain WLCS_PROP_* table.
protected void
getSearchSQL(StringBuffer buf, Logical l, String prefix, boolean supportsLikeEscapeClause, List params, boolean isCategory)
Get the SQL where clause for a Criteria.
public static String
getSQLOperator(String c)
Return the corresponding SQL operator for the given comparator.
public static boolean
isLegalSingleValueComparator(String c)
Determine if a comparator is legal, single-value attribute comparator.
public static void
main(String[] args)
Quick unit test of keyword search.
public List
search(Connection con, boolean showAll, String lang, String logical, Expression expr, String tablePrefix, int maxSearchResults)
Perform a search
public List
search(Connection con, boolean showAll, String lang, List keywords, String logical, Expression expr, String tablePrefix, int maxSearchResults)
Perform a search
public List
search(Connection con, boolean showAll, String lang, List keywords, String logical)
Perform a keyword search.
public List
search(Connection con, boolean showAll, String lang, List keywords)
Perform an AND'ed keyword search.
public List
search(Connection con, boolean showAll, String lang, Expression expr, String tablePrefix)
Perform an expression search.
public static String
toSQLLike(String like, boolean supportsLikeEscapeClause)
Convert a query LIKE value to a SQL LIKE value.
public static Object
toSQLLike(Object obj, boolean supportsLikeEscapeClause)
Convert an object, which might be a string, to a SQL like string.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   

Field Detail

DEFAULT_ENTITY_ID_TABLE_NAME

public static final String DEFAULT_ENTITY_ID_TABLE_NAME
The default entity identifier table


DEFAULT_PROPERTY_BOOLEAN_COLUMN_NAME

public static final String DEFAULT_PROPERTY_BOOLEAN_COLUMN_NAME
The default boolean property table


DEFAULT_PROPERTY_DATETIME_COLUMN_NAME

public static final String DEFAULT_PROPERTY_DATETIME_COLUMN_NAME
The default date/time property table


DEFAULT_PROPERTY_FLOAT_COLUMN_NAME

public static final String DEFAULT_PROPERTY_FLOAT_COLUMN_NAME
The default float property table


DEFAULT_PROPERTY_ID_TABLE_NAME

public static final String DEFAULT_PROPERTY_ID_TABLE_NAME
The default property identifier table


DEFAULT_PROPERTY_INTEGER_COLUMN_NAME

public static final String DEFAULT_PROPERTY_INTEGER_COLUMN_NAME
The default integer property table


DEFAULT_PROPERTY_TEXT_COLUMN_NAME

public static final String DEFAULT_PROPERTY_TEXT_COLUMN_NAME
The default text property table


DEFAULT_PROPERTY_VALUE_TABLE

public static final String DEFAULT_PROPERTY_VALUE_TABLE
The default property table


DEFAULT_TABLE_PREFIX

public static final String DEFAULT_TABLE_PREFIX
The default table prefix

 

Constructor Detail

QueryHelper

public QueryHelper(JdbcCatalogFactory jdbcCatFac, 
                   Boolean supportsLikeEscapeClause)
 

Method Detail

fixKeywords(String[]) Method

public static List fixKeywords(String[] keywords)
Fix up an array of keywords by removing nulls and duplicates.

Parameters

keywords
the array of keywords.

Returns

the cleaned-up list of keywords.

getSearchSQL(boolean, List, boolean) Method

protected StringBuffer getSearchSQL(boolean showAll, 
                                    List params, 
                                    boolean isCategory)
Get the SQL where clause for the showAll parameter.

Parameters

showAll
whether to show invisible items (true), or not (false).
params
the list of prepared statement params to add to.

Returns

the SQL where clause, or null if there shouldn't be one.

getSearchSQL(String, List, boolean) Method

protected StringBuffer getSearchSQL(String lang, 
                                    List params, 
                                    boolean isCategory)
Get the SQL where clause for the lang parameter.

Parameters

lang
the lang (null for none).
params
the list of prepared statement params to add to.

Returns

the SQL where clause, or null if there shouldn't be one.

getSearchSQL(List, String, List) Method

protected StringBuffer getSearchSQL(List keywords, 
                                    String logical, 
                                    List params)
Get the SQL where clause for the keywords.

Parameters

keywords
the list of keywords (no nulls, no duplicates, null for none).
logical
TypesHelper.AND or TypesHelper.OR (for keywords).
params
the list of prepared statement params to add to.

Returns

the SQL where clause, or null if there shouldn't be one.

getSearchSQL(Expression, String, boolean, List, boolean) Method

protected StringBuffer getSearchSQL(Expression expr, 
                                    String prefix, 
                                    boolean supportsLikeEscapeClause, 
                                    List params, 
                                    boolean isCategory)
throws CatalogException
Get the SQL where clause for an expression.

Parameters

expr
the expression (already normalized, null for none).
prefix
the table prefix for the ConfigurableEntity tables for implicit properties.
supportsLikeEscapeClause
tells if the SQL statement can use the LIKE ESCAPE clause.
params
the list of prepared statement params to add to.

Returns

the SQL where clause, or null if there shouldn't be one.

Exceptions

CatalogException

getSearchSQL(StringBuffer, Expression, String, boolean, List, boolean) Method

protected void getSearchSQL(StringBuffer buf, 
                            Expression expr, 
                            String prefix, 
                            boolean supportsLikeEscapeClause, 
                            List params, 
                            boolean isCategory)
throws CatalogException
Get the SQL where clause for an expression.

Parameters

buf
the buffer to write into.
expr
the expression (already normalized, null for none).
prefix
the table prefix for the ConfigurableEntity tables for implicit properties.
supportsLikeEscapeClause
tells if the SQL statement can use the LIKE ESCAPE clause.
params
the list of prepared statement params to add to.

Exceptions

CatalogException

getSearchSQL(StringBuffer, Criteria, String, boolean, List, boolean) Method

protected void getSearchSQL(StringBuffer buf, 
                            Criteria c, 
                            String prefix, 
                            boolean supportsLikeEscapeClause, 
                            List params, 
                            boolean isCategory)
throws CatalogException
Get the SQL where clause for a Criteria.

Parameters

buf
the buffer to write into.
c
the Criteria.
prefix
the table prefix for the ConfigurableEntity tables for implicit properties.
supportsLikeEscapeClause
tells if the SQL statement can use the LIKE ESCAPE clause.
params
the list of prepared statement params to add to.

Exceptions

CatalogException

getSearchSQL(StringBuffer, String, boolean, String, String, String, String, Object, List, boolean) Method

protected void getSearchSQL(StringBuffer buf, 
                            String prefix, 
                            boolean supportsLikeEscapeClause, 
                            String column, 
                            String scope, 
                            String name, 
                            String op, 
                            Object val, 
                            List params, 
                            boolean isCategory)
Get the SQL for searching for an implicit property in a certain WLCS_PROP_* table.

Parameters

buf
the buffer to write into.
prefix
the table prefix.
supportsLikeEscapeClause
tells if the SQL statement can use the LIKE ESCAPE clause.
column
the WLCS_PROP_* table name (e.g. WLCS_PROP_TEXT).
scope
the property scope name (null for any scope).
name
the property name.
op
the operator.
val
the value to match
params
the list of prepared statement params to add to.

getSearchSQL(StringBuffer, Logical, String, boolean, List, boolean) Method

protected void getSearchSQL(StringBuffer buf, 
                            Logical l, 
                            String prefix, 
                            boolean supportsLikeEscapeClause, 
                            List params, 
                            boolean isCategory)
throws CatalogException
Get the SQL where clause for a Criteria.

Parameters

buf
the buffer to write into.
l
the Logical.
prefix
the table prefix for the ConfigurableEntity tables for implicit properties.
supportsLikeEscapeClause
tells if the SQL statement can use the LIKE ESCAPE clause.
params
the list of prepared statement params to add to.

Exceptions

CatalogException

getSQLOperator(String) Method

public static String getSQLOperator(String c)
Return the corresponding SQL operator for the given comparator.

Parameters

c
the comparator (one from TypesHelper).

isLegalSingleValueComparator(String) Method

public static boolean isLegalSingleValueComparator(String c)
Determine if a comparator is legal, single-value attribute comparator.


main(String[]) Method

public static void main(String[] args)
throws Exception
Quick unit test of keyword search.

Exceptions

Exception

search(Connection, boolean, String, String, Expression, String, int) Method

public List search(Connection con, 
                   boolean showAll, 
                   String lang, 
                   String logical, 
                   Expression expr, 
                   String tablePrefix, 
                   int maxSearchResults)
throws CatalogException
Perform a search

Parameters

con
the database connection to use.
showAll
true to show invisible items, false to not.
lang
the language to match on (null for any).
logical
the list of keywords (no nulls, no duplicates, null for none).
expr
TypesHelper.AND or TypesHelper.OR (for keywords).
tablePrefix
the query expression to use (already normalized, null for none).
maxSearchResults
the table prefix for the ConfigurableEntity tables for implicit properties.

Returns

the list of ProductItemKeys of the items that match.

Exceptions

CatalogException

Related Topics

TypesHelper


search(Connection, boolean, String, List, String, Expression, String, int) Method

public List search(Connection con, 
                   boolean showAll, 
                   String lang, 
                   List keywords, 
                   String logical, 
                   Expression expr, 
                   String tablePrefix, 
                   int maxSearchResults)
throws CatalogException
Perform a search

Parameters

con
the database connection to use.
showAll
true to show invisible items, false to not.
lang
the language to match on (null for any).
keywords
the list of keywords (no nulls, no duplicates, null for none).
logical
TypesHelper.AND or TypesHelper.OR (for keywords).
expr
the query expression to use (already normalized, null for none).
tablePrefix
the table prefix for the ConfigurableEntity tables for implicit properties.

Returns

the list of ProductItemKeys of the items that match.

Exceptions

CatalogException

Related Topics

TypesHelper


search(Connection, boolean, String, List, String) Method

public List search(Connection con, 
                   boolean showAll, 
                   String lang, 
                   List keywords, 
                   String logical)
throws CatalogException
Perform a keyword search.

Parameters

con
the database connection to use.
showAll
true to show invisible items, false to not.
lang
the language to match on (null for any).
keywords
the list of keywords (no nulls, no duplicates).
logical
TypesHelper.AND or TypesHelper.OR.

Returns

the list of ProductItemKeys of the items that match.

Exceptions

CatalogException

search(Connection, boolean, String, List) Method

public List search(Connection con, 
                   boolean showAll, 
                   String lang, 
                   List keywords)
throws CatalogException
Perform an AND'ed keyword search.

Parameters

con
the database connection to use.
showAll
true to show invisible items, false to not.
lang
the language to match on (null for any).
keywords
the list of keywords (no nulls, no duplicates).

Returns

the list of ProductItemKeys of the items that match.

Exceptions

CatalogException

search(Connection, boolean, String, Expression, String) Method

public List search(Connection con, 
                   boolean showAll, 
                   String lang, 
                   Expression expr, 
                   String tablePrefix)
throws CatalogException
Perform an expression search.

Parameters

con
the database connection to use.
showAll
true to show invisible items, false to not.
lang
the language to match on (null for any).
expr
the normalized expression to use.
tablePrefix
the table prefix for the ConfigurableEntity tables for implicit properties.

Returns

the list of ProductItemKeys of the items that match.

Exceptions

CatalogException

toSQLLike(String, boolean) Method

public static String toSQLLike(String like, 
                               boolean supportsLikeEscapeClause)
Convert a query LIKE value to a SQL LIKE value.


toSQLLike(Object, boolean) Method

public static Object toSQLLike(Object obj, 
                               boolean supportsLikeEscapeClause)
Convert an object, which might be a string, to a SQL like string.