public class PreparedSelector extends Object
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_ALIAS
The default search alias.
|
Constructor and Description |
---|
PreparedSelector(LibrarySession session)
Constructs a PreparedSelector.
|
Modifier and Type | Method and Description |
---|---|
protected void |
applySortSpecificationDefaults()
Applies the primary search target settings as the default class/alias for
the current sort specification.
|
static AttributeValue |
createSearchTarget(String classAndAlias)
Create a search target specification, from a single space-delimited String
that has the ClassObject name and alias.
|
static AttributeValue |
createSearchTarget(String className,
String alias)
Create a search target specification, from a ClassObject name and alias.
|
static AttributeValue |
createSearchTarget(String className,
String alias,
String viewName)
Create a search target specification, from an optional ClassObject name,
an alias, and an explicit table or view name.
|
String |
deriveViewFromTarget(AttributeValue target)
Derives the view name from the specified search target.
|
static String |
getAliasFromTarget(AttributeValue target)
Returns the alias name from the specified search target.
|
static String |
getAliasFromTarget(LibrarySessionInterface session,
AttributeValue target)
Deprecated.
9.3.3.0 use variant without a session context
|
AttributeValue[] |
getAuxiliarySearchTargets()
Returns the auxiliary search targets.
|
AttributeValue[] |
getBindValues()
Gets the bind values to use in the select statement.
|
String[] |
getBypassSecurityAliases()
Returns the bypass security aliases that were
set using setBypassSecurityAliases().
|
protected String |
getClassFromTarget(AttributeValue target)
Deprecated.
9.3.3.0 use
getClassNameFromTarget |
static String |
getClassNameFromTarget(AttributeValue target)
Returns the class name from the specified search target.
|
ColumnDescriptor[] |
getColumnDescriptors()
Gets the column descriptors to use in the select statement.
|
String |
getCompleteSqlStatement()
Gets the complete SQL statement that will be used.
|
String |
getCompleteSqlStatement(String delim)
Gets the complete SQL statement that will be used.
|
static String |
getExistsSecurityClause(String alias,
String attrName)
Return a condition that can be used to restrict results based
on the user's ability to discover the object referred to by an attribute.
|
String |
getHint()
Gets the SQL hint to use for the main select.
|
int |
getItemCount()
Returns the search result count.
|
LibraryObject[] |
getItems()
Returns the entire search results as an array.
|
String |
getJoinCondition()
Returns the join condition that was set using setJoinCondition().
|
int |
getMaxItemCount()
Returns the maximum number of items that will be returned by
getItems . |
String |
getPrimarySearchAlias()
Returns the alias used for the primary search class.
|
String |
getPrimarySearchClass()
Returns the search class that was previously set.
|
AttributeValue |
getPrimarySearchTarget()
Returns the primary search target.
|
String |
getSearchLanguage()
Returns the search language in effect.
|
AttributeValueTable[] |
getSearchResults()
Returns the search results as an array of AttributeValueTable, with each
AttributeValueTable representing a row from the underlying ResultSet.
|
String |
getSearchSelection()
Returns the search selection that was set using setSearchSelection()
|
LibrarySession |
getSession()
Returns the session being used by this Selector.
|
SortSpecification |
getSortSpecification()
Returns the Sort Specification.
|
String[] |
getSqlStatement()
Gets the SQL statement that will be used.
|
int |
getStartingRowNumber()
Returns the starting row number.
|
String |
getStatementKey()
Returns the statement key.
|
static String |
getViewFromTarget(AttributeValue target)
Returns the overridden view name from the specified search target.
|
static String |
getViewFromTarget(LibrarySessionInterface session,
AttributeValue target)
Deprecated.
9.3.3.0 use variant without a session context
|
boolean |
isAlwaysCacheSelectedData()
Gets whether to force caching of selected data.
|
boolean |
isDistinct()
Returns true if distinct searching is enabled with respect to classes.
|
boolean |
isRecursiveSearch()
Returns true if recursive searching is enabled with respect to classes.
|
void |
setAlwaysCacheSelectedData(boolean value)
Sets whether to force caching of selected data.
|
void |
setAuxiliarySearchTargets(AttributeValue[] targets)
Sets the auxiliary search targets.
|
void |
setBindValues(AttributeValue[] bindValues)
Sets the bind values to use in the select statement.
|
void |
setBypassSecurityAliases(String[] bypassSecAliases)
Sets the aliases that indicates which PO classes should not have
the security clause applied.
|
void |
setColumnDescriptors(ColumnDescriptor[] colDescs)
Sets the column descriptors to use in the select statement.
|
void |
setDistinct(boolean distinct)
Sets the indication as to whether a "select distinct" will be
used.
|
void |
setHint(String hint)
Sets the SQL hint to use for the main select.
|
void |
setJoinCondition(String joinCondition)
Sets the join condition.
|
void |
setMaxItemCount(int maxItemCount)
Sets the maximum number of items that will be returned by
getItems . |
void |
setPrimarySearchClass(String className)
Sets the primary search target, specifying the class name only.
|
void |
setPrimarySearchTarget(AttributeValue target)
Sets the primary search target.
|
void |
setRecursiveSearch(boolean recursive)
Enables/disables recursive searching with respect to classes.
|
void |
setSearchClassname(String searchClass)
Deprecated.
11.1.1.1 use
setPrimarySearchClass |
void |
setSearchLanguage(String language)
Sets the search language.
|
void |
setSearchSelection(String searchSelection)
Sets the search selection.
|
void |
setSortSpecification(SortSpecification sort)
Sets the Sort Specification.
|
void |
setSortSpecification(String sortCondition)
Sets the Sort Specification for the specified string.
|
void |
setStartingRowNumber(int rowNumber)
Sets the starting row number.
|
void |
setStatementKey(String key)
Sets the statement key.
|
protected LibrarySession |
verifyConnected()
Return the current LibrarySession if
the session is connected; otherwise raise
a "not connected" exception.
|
public static final String DEFAULT_ALIAS
public PreparedSelector(LibrarySession session) throws IfsException
session
- the current session.IfsException
- if the operation fails.public LibrarySession getSession() throws IfsException
IfsException
- if the operation fails.public String getStatementKey() throws IfsException
IfsException
- if the operation fails.public SortSpecification getSortSpecification() throws IfsException
IfsException
- if the operation fails.public AttributeValue getPrimarySearchTarget() throws IfsException
The AttributeValue returned encapulates the class name (as the AttributeValue's name) and the alias (as the AttributeValue's value).
IfsException
- if operation fails.public AttributeValue[] getAuxiliarySearchTargets() throws IfsException
The AttributeValues returned encapulate the class name (as the AttributeValue's name) and the alias (as the AttributeValue's value).
IfsException
- if operation fails.public String getPrimarySearchClass() throws IfsException
IfsException
- if operation fails.public String getPrimarySearchAlias() throws IfsException
IfsException
- if operation fails.protected String getClassFromTarget(AttributeValue target) throws IfsException
getClassNameFromTarget
target
- the search target specification.IfsException
- if operation fails.public ColumnDescriptor[] getColumnDescriptors() throws IfsException
IfsException
- if the operation fails.public String[] getBypassSecurityAliases() throws IfsException
IfsException
- if operation fails.public String getJoinCondition() throws IfsException
IfsException
- if operation fails.public String getSearchSelection() throws IfsException
IfsException
- if operation fails.public boolean isDistinct() throws IfsException
IfsException
- if the operation fails.public boolean isAlwaysCacheSelectedData() throws IfsException
IfsException
- if the operation failspublic boolean isRecursiveSearch() throws IfsException
IfsException
- if the operation fails.public String getSearchLanguage() throws IfsException
A value of null indicates that the default language should be used.
IfsException
- if operation fails.public int getMaxItemCount() throws IfsException
getItems
.
A value of zero indicates that there is no limit on the desired number of items.
IfsException
- if the operation fails.public int getStartingRowNumber() throws IfsException
The value is 1-based, meaning that if the value is set to 101, the first 100 rows will be skipped. A value of zero or less is treated the same same as a setting of 1, indicating that no rows are skipped.
IfsException
- if the operation fails.public String getHint() throws IfsException
IfsException
- if the operation fails.public AttributeValue[] getBindValues() throws IfsException
IfsException
- if the operation fails.public String getCompleteSqlStatement() throws IfsException
A single space is used as the delimitter between the SQL fragments.
IfsException
- if the operation fails.public String getCompleteSqlStatement(String delim) throws IfsException
Returns a concatenation of the SQL fragments (select, from, where, sort) that will be emitted for the query. Each of the fragments is seperated by the specified delimitter, typically a newline or space.
delim
- the delimitter to use between sections of the SQLIfsException
- if the operation fails.public String[] getSqlStatement() throws IfsException
The SQL is returned as an array of strings, that when concatenated with space delimiters is the SQL emited for this selector. The elements of the array contain the following elements:
IfsException
- if the operation fails.public void setStatementKey(String key) throws IfsException
key
- the statement key.IfsException
- if operation fails.public void setDistinct(boolean distinct) throws IfsException
distinct
- true if distinct is used; false otherwise.IfsException
- if operation fails.public void setAlwaysCacheSelectedData(boolean value) throws IfsException
value
- true if selected data should be cached;
false otherwiseIfsException
- if the operation failspublic void setPrimarySearchTarget(AttributeValue target) throws IfsException
target
- the primary search target.IfsException
- if operation fails.public void setPrimarySearchClass(String className) throws IfsException
className
- the search class.IfsException
- if operation fails.public void setSearchClassname(String searchClass) throws IfsException
setPrimarySearchClass
searchClass
- the primary search class.IfsException
- if operation fails.public void setAuxiliarySearchTargets(AttributeValue[] targets) throws IfsException
targets
- the auxiliary search targets.IfsException
- if operation fails.public void setSortSpecification(String sortCondition) throws IfsException
sortCondition
- the sort conditionIfsException
- if the operation fails.public void setSortSpecification(SortSpecification sort) throws IfsException
sort
- the sort specificaion.IfsException
- if the operation fails.protected void applySortSpecificationDefaults() throws IfsException
IfsException
- if the operation fails.public void setColumnDescriptors(ColumnDescriptor[] colDescs) throws IfsException
colDescs
- the column descriptorsIfsException
- if the operation fails.public void setBypassSecurityAliases(String[] bypassSecAliases) throws IfsException
bypassSecAliases
- the bypass security aliasesIfsException
- if operation fails.public void setJoinCondition(String joinCondition) throws IfsException
joinCondition
- the join conditionIfsException
- if operation fails.public void setSearchSelection(String searchSelection) throws IfsException
searchSelection
- the search selection.IfsException
- if operation fails.public void setRecursiveSearch(boolean recursive) throws IfsException
recursive
- true for enabled.IfsException
- if the operation fails.public void setSearchLanguage(String language) throws IfsException
A value of null indicates that the default language should be used.
language
- the search languageIfsException
- if operation fails.public void setMaxItemCount(int maxItemCount) throws IfsException
getItems
.
A value of zero indicates that there is no limit on the desired number of items.
maxItemCount
- maximum number of items that will be returnedIfsException
- if the operation fails.public void setStartingRowNumber(int rowNumber) throws IfsException
The value is 1-based, meaning that if the value is set to 101, the first 100 rows will be skipped. A value of zero or less is treated the same same as a setting of 1, indicating that no rows are skipped.
rowNumber
- the starting row numberIfsException
- if the operation fails.public void setHint(String hint) throws IfsException
hint
- the SQL hintIfsException
- if the operation fails.public void setBindValues(AttributeValue[] bindValues) throws IfsException
bindValues
- the bind valuesIfsException
- if the operation fails.public LibraryObject[] getItems() throws IfsException
IfsException
- if operation fails.public AttributeValueTable[] getSearchResults() throws IfsException
IfsException
- if operation fails.public int getItemCount() throws IfsException
IfsException
- if operation fails.protected LibrarySession verifyConnected() throws IfsException
IfsException
- 21000: if not connectedpublic static AttributeValue createSearchTarget(String classAndAlias) throws IfsException
Format of the string is
classAndAlias
- the string token representing the search target (class and alias)IfsException
- if the operation failspublic static AttributeValue createSearchTarget(String className, String alias) throws IfsException
className
- the class namealias
- the aliasIfsException
- if the operation failspublic static AttributeValue createSearchTarget(String className, String alias, String viewName) throws IfsException
className
- the class name (can be null)alias
- the aliasviewName
- the literal view or table nameIfsException
- if the operation failspublic static String getClassNameFromTarget(AttributeValue target) throws IfsException
target
- the search target specification.IfsException
- if operation fails.public static String getAliasFromTarget(LibrarySessionInterface session, AttributeValue target) throws IfsException
session
- the session contexttarget
- the search target specification.IfsException
- if operation fails.public static String getAliasFromTarget(AttributeValue target) throws IfsException
target
- the search target specification.IfsException
- if operation fails.public static String getViewFromTarget(LibrarySessionInterface session, AttributeValue target) throws IfsException
session
- the session contexttarget
- the search target specification.IfsException
- if operation fails.public static String getViewFromTarget(AttributeValue target) throws IfsException
target
- the search target specification.IfsException
- if operation fails.public String deriveViewFromTarget(AttributeValue target) throws IfsException
target
- the search target specification.IfsException
- if operation fails.public static String getExistsSecurityClause(String alias, String attrName)
Returns a SQL-style "exists" clause that will exclude all rows except for the ones where the value of the specified PublicObject attribute can be discovered by the current user.
The caller must ensure that the specified attribute is of type PublicObject.
This condition contains one bind value indicator (?) that corresponds to the requesting user ID. The current User's ID should be specified as a bind value on the PreparedSelector if this condition is included in the search selection criteria.
alias
- the table alias; defaults to "x" if nullattrName
- the attribute for which discoverability
will be checkedCopyright © 2023. All rights reserved.