|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.flexive.shared.search.query.SqlQueryBuilder
public class SqlQueryBuilder
Query Builder for flexive SQL queries. Supports incremental adding of conditions, filter and order by columns.
| Field Summary | |
|---|---|
static int |
COL_USERPROPS
Start column for user defined properties |
(package private) static long |
serialVersionUID
|
| Constructor Summary | |
|---|---|
SqlQueryBuilder()
Instantiates an empty query builder. |
|
SqlQueryBuilder(ResultLocation location,
ResultViewType viewType)
Instantiates an empty query builder for the specified result location and view type. |
|
SqlQueryBuilder(SqlQueryBuilder other)
Copy constructor. |
|
| Method Summary | |
|---|---|
protected void |
addSelectColumns(java.lang.String... columns)
|
SqlQueryBuilder |
allRows()
Remove row limitations on the search result and fetch all rows. |
SqlQueryBuilder |
andSub()
Shorthand for #enterSub(Operator) with QueryOperatorNode.Operator.AND as the operator. |
void |
clearOrderBy()
Clears the current order by settings. |
SqlQueryBuilder |
closeSub()
Close a scope. |
SqlQueryBuilder |
condition(FxAssignment assignment,
PropertyValueComparator comparator,
FxValue<?,?> value)
Render a condition for a common FxAssignment query. |
SqlQueryBuilder |
condition(FxProperty property,
PropertyValueComparator comparator,
FxValue<?,?> value)
Render a condition for a common FxProperty query. |
SqlQueryBuilder |
condition(java.lang.String propertyName,
PropertyValueComparator comparator,
FxValue<?,?> value)
Render a condition for a FxProperty query. |
SqlQueryBuilder |
condition(java.lang.String propertyName,
PropertyValueComparator comparator,
java.lang.Object value)
Render a condition for a FxProperty query. |
SqlQueryBuilder |
copy()
Returns a new instance of this query builder. |
SqlQueryBuilder |
enterSub(QueryOperatorNode.Operator operator)
Create a new subquery scope with the given operator. |
SqlQueryBuilder |
fetchRows(int fetchRows)
Set the maximum number of rows to be returned to the caller when using getResult(). |
SqlQueryBuilder |
filterBriefcase(long briefcaseId)
Return only objects of the given briefcase. |
SqlQueryBuilder |
filterType(long typeId)
Uses a content type filter for the given content type. |
SqlQueryBuilder |
filterType(java.lang.String name)
Uses a content type filter for the given content type name. |
SqlQueryBuilder |
filterVersion(VersionFilter filter)
Filter the result set using the given version filter mode (live, max, auto or all). |
SqlQueryBuilder |
fulltext(java.lang.String value)
Performs a fulltext query over all indexed properties against the given text. |
java.util.List<java.lang.String> |
getColumnNames()
Return the selected column names. |
java.lang.String |
getConditions()
Return the conditional ("WHERE") statement(s) contained in this query. |
int |
getFetchRows()
|
java.lang.String |
getFilters()
Return the filters defined for this query (if any). |
ResultLocation |
getLocation()
Return the result location used in this query builder. |
int |
getMaxRows()
|
java.lang.String |
getOrderBy()
Return the order by columns defined for this query. |
FxSQLSearchParams |
getParams()
|
java.lang.String |
getQuery()
Returns the complete query generated by the builder. |
FxResultSet |
getResult()
Convenience method for executing a search query using this query builder. |
int |
getStartRow()
|
ResultViewType |
getViewType()
Return the result view type used in this query builder. |
SqlQueryBuilder |
isChild(long nodeId)
Limits the (sub-)query to children of the given node. |
SqlQueryBuilder |
isChild(java.lang.String path)
Limits the (sub-)query to children of the given node. |
SqlQueryBuilder |
isDirectChild(long nodeId)
Limits the (sub-)query to the direct children of the given node. |
SqlQueryBuilder |
isDirectChild(java.lang.String path)
Limits the (sub-)query to the direct children of the given node. |
boolean |
isFrozen()
Return true if this query builder is frozen and cannot be further modified. |
boolean |
isIncludeBasicSelects()
Returns true if the predefined columns are selected by the condition. |
SqlQueryBuilder |
maxRows(int maxRows)
Set the maximum number of rows that the query should return. |
SqlQueryBuilder |
noResultInfo()
Don't fetch result set metadata such as the total number of rows, found content types, or XPaths of the selected values. |
SqlQueryBuilder |
orderBy(int columnIndex,
SortDirection direction)
Order the results by the given column (1-based). |
SqlQueryBuilder |
orderBy(java.lang.String column,
SortDirection direction)
Order the results by the given column. |
SqlQueryBuilder |
orderByColumns(java.util.List<Pair<java.lang.String,SortDirection>> columns)
Order the results by the given column names. |
SqlQueryBuilder |
orderByColumns(Pair<java.lang.String,SortDirection>... columns)
Order the results by the given column names. |
SqlQueryBuilder |
orderByIndices(java.util.List<Pair<java.lang.Integer,SortDirection>> columns)
Order the results by the given column indices (1-based). |
SqlQueryBuilder |
orderByIndices(Pair<java.lang.Integer,SortDirection>... columns)
Order the results by the given column indices (1-based). |
SqlQueryBuilder |
orSub()
Shorthand for #enterSub(Operator) with QueryOperatorNode.Operator.OR as the operator. |
SqlQueryBuilder |
saveInBriefcase(java.lang.String name)
Saves the result of this query in a briefcase (if the result is obtained via # getResult()). |
SqlQueryBuilder |
saveInBriefcase(java.lang.String name,
java.lang.String description,
long aclId)
Saves the result of this query in a briefcase (if the result is obtained via # getResult()). |
SqlQueryBuilder |
searchLanguages(java.util.Collection<FxLanguage> languages)
Limit the language(s) in which queries are performed (applied to multilingual properties only). |
SqlQueryBuilder |
select(java.util.Collection<java.lang.String> columns)
Select one or more columns. |
SqlQueryBuilder |
select(java.lang.String... columns)
Select one or more columns. |
SqlQueryBuilder |
setIncludeBasicSelects(boolean includeBasicSelects)
Enables or disables the default select columns. |
SqlQueryBuilder |
startRow(int startRow)
|
SqlQueryBuilder |
timeout(int seconds)
Sets the query timeout in seconds. |
SqlQueryBuilder |
type(long typeId)
Adds a condition that selects only objects of the given type. |
SqlQueryBuilder |
type(long typeId,
boolean includeSubTypes)
Adds a condition that selects only objects of the given type. |
SqlQueryBuilder |
type(java.lang.String typeName)
Adds a condition that selects only objects of the given type. |
SqlQueryBuilder |
type(java.lang.String typeName,
boolean includeSubTypes)
Adds a condition that selects only objects of the given type. |
SqlQueryBuilder |
viewType(ResultViewType viewType)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final long serialVersionUID
public static final int COL_USERPROPS
| Constructor Detail |
|---|
public SqlQueryBuilder()
public SqlQueryBuilder(ResultLocation location,
ResultViewType viewType)
location - the result locationviewType - the view typepublic SqlQueryBuilder(SqlQueryBuilder other)
other
other - the query builder to be copied| Method Detail |
|---|
public SqlQueryBuilder copy()
public java.lang.String getQuery()
public java.lang.String getFilters()
public java.lang.String getOrderBy()
public SqlQueryBuilder condition(FxAssignment assignment,
PropertyValueComparator comparator,
FxValue<?,?> value)
assignment - the assignmentcomparator - the comparator to be usedvalue - the value to be compared against
public SqlQueryBuilder condition(FxProperty property,
PropertyValueComparator comparator,
FxValue<?,?> value)
property - the propertycomparator - the comparator to be usedvalue - the value to be compared against
public SqlQueryBuilder condition(java.lang.String propertyName,
PropertyValueComparator comparator,
FxValue<?,?> value)
propertyName - the property namecomparator - the comparator to be usedvalue - the value to be compared against
public SqlQueryBuilder condition(java.lang.String propertyName,
PropertyValueComparator comparator,
java.lang.Object value)
propertyName - the property namecomparator - the comparator to be usedvalue - the value to be compared against
public SqlQueryBuilder fulltext(java.lang.String value)
value - the fulltext query
public SqlQueryBuilder type(java.lang.String typeName)
filterType(String), since filtering is applied on the result that also may contain
other types, but this is a standard search condition that restrains the search result.
typeName - the type name to be selected
public SqlQueryBuilder type(java.lang.String typeName,
boolean includeSubTypes)
filterType(String), since filtering is applied on the result that also may contain
other types, but this is a standard search condition that restrains the search result.
typeName - the type name to be selectedincludeSubTypes - if subtypes should be included
public SqlQueryBuilder type(long typeId)
filterType(long), since filtering is applied on the result that also may contain
other types, but this is a standard search condition that restrains the search result.
typeId - the type id to be selected
public SqlQueryBuilder type(long typeId,
boolean includeSubTypes)
filterType(long), since filtering is applied on the result that also may contain
other types, but this is a standard search condition that restrains the search result.
typeId - the type id to be selectedincludeSubTypes - if subtypes should be included
public SqlQueryBuilder isChild(long nodeId)
nodeId - the root node for the (sub-)query
public SqlQueryBuilder isChild(java.lang.String path)
path - the tree path of the node
public SqlQueryBuilder isDirectChild(long nodeId)
nodeId - the root node for the (sub-)query
public SqlQueryBuilder isDirectChild(java.lang.String path)
path - the tree path of the node
public java.lang.String getConditions()
public java.util.List<java.lang.String> getColumnNames()
public SqlQueryBuilder select(java.lang.String... columns)
columns - columns to be selected
protected void addSelectColumns(java.lang.String... columns)
public SqlQueryBuilder select(java.util.Collection<java.lang.String> columns)
columns - columns to be selected
public SqlQueryBuilder filterBriefcase(long briefcaseId)
briefcaseId - the briefcase ID
public SqlQueryBuilder filterType(java.lang.String name)
name - the content type name
public SqlQueryBuilder filterType(long typeId)
typeId - the content type ID, or -1 to disable the content type filter
public SqlQueryBuilder filterVersion(VersionFilter filter)
filter - the version filter to be applied
public SqlQueryBuilder searchLanguages(java.util.Collection<FxLanguage> languages)
languages - the language(s)
public SqlQueryBuilder orderBy(java.lang.String column,
SortDirection direction)
column - the column to be sorteddirection - the sort direction
public SqlQueryBuilder orderBy(int columnIndex,
SortDirection direction)
columnIndex - the 1-based index of the column to be sorteddirection - the sort direction
public SqlQueryBuilder orderByIndices(Pair<java.lang.Integer,SortDirection>... columns)
columns - the order by columns
public SqlQueryBuilder orderByIndices(java.util.List<Pair<java.lang.Integer,SortDirection>> columns)
columns - the order by columns
public SqlQueryBuilder orderByColumns(Pair<java.lang.String,SortDirection>... columns)
columns - the order by columns
public SqlQueryBuilder orderByColumns(java.util.List<Pair<java.lang.String,SortDirection>> columns)
columns - the order by columns
public void clearOrderBy()
public boolean isIncludeBasicSelects()
public SqlQueryBuilder setIncludeBasicSelects(boolean includeBasicSelects)
select(String...).
includeBasicSelects - true if the pre-defined selects should be included
public SqlQueryBuilder enterSub(QueryOperatorNode.Operator operator)
operator - the operator to be used inside the new scope
public SqlQueryBuilder andSub()
#enterSub(Operator) with QueryOperatorNode.Operator.AND as the operator.
public SqlQueryBuilder orSub()
#enterSub(Operator) with QueryOperatorNode.Operator.OR as the operator.
public SqlQueryBuilder closeSub()
public boolean isFrozen()
getQuery() and getConditions() methods.
A frozen query builder does not guarantee, however, that the query itself is valid.
public ResultLocation getLocation()
public ResultViewType getViewType()
public SqlQueryBuilder viewType(ResultViewType viewType)
public int getStartRow()
public SqlQueryBuilder startRow(int startRow)
public int getMaxRows()
public SqlQueryBuilder maxRows(int maxRows)
startRow(int) and fetchRows(int) to return a subset of the search result.
This value defaults to SearchEngine.DEFAULT_MAX_ROWS.
Note: Be aware that restricting the result size with
this parameter can lead to random results, especially in combination
with ORDER BY. This is because first the result set is built using
at most maxRows rows, which are then sorted and
returned to the client. In general you might want to increase this
value to guarantee precise results for large datasets and
unspecific queries.
maxRows - the maximum number of rows in the query result
public int getFetchRows()
public SqlQueryBuilder fetchRows(int fetchRows)
getResult().
Unless specified, all rows will be returned.
fetchRows - the number of rows to be returned
public SqlQueryBuilder allRows()
public SqlQueryBuilder noResultInfo()
public SqlQueryBuilder saveInBriefcase(java.lang.String name,
java.lang.String description,
long aclId)
getResult()).
name - the briefcase name (required)description - the briefcase description (optional)aclId - the briefcase ACL (if -1, the briefcase will be private for the calling user)
public SqlQueryBuilder timeout(int seconds)
getResult().
seconds - the query timeout in seconds (default: 120 seconds)
public SqlQueryBuilder saveInBriefcase(java.lang.String name)
getResult()).
name - the briefcase name (required)
public FxResultSet getResult()
throws FxApplicationException
FxApplicationException - if the search failedpublic FxSQLSearchParams getParams()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||