public class AttributeSearchSpecification extends SearchSpecification
// Usage Examples // How to build a Attribute Search specification // Construct the AttributeSearchSpecification. AttributeSearchSpecification asp = new AttributeSearchSpecification(); // Let's assume we have the 3 parts needed. // They are SearchClassSpecification - SELECT list and FROM list // SearchQualification - WHERE condition // SearchSortSpecification - ORDER BY clause SearchClassSpecification someSearchSpec = ...; SearchSortSpecification someSortSpec = ... ; SearchQualification someSearchQual = ...; LibrarySession sess = ...; // Set the search class spec asp.setSearchClassSpecification(someSearchSpec); // Set the search qualification asp.setSearchQualification(someSearchQual); // Set the sort specification asp.setSearchSortSpecification(someSortSpec); // Now we are ready to build a Search or create a View. // Building a search Search someSearch = new Search(sess, asp); // Or creating a view ViewSpecification viewSpec = new ViewSpecification("TestView", asp); // --------------------------------------------------------------- // Complete example of a Search using AttributeSearchSpecification // --------------------------------------------------------------- // Let's build a search that looks for all DOCUMENTS with a given // ACL and are named FOO. // Let's build the WHERE condition first. // It will be - DOC.ACL = GIVEN-ACL and DOC.NAME='FOO' // DOC.ACL = GIVEN-ACL AttributeQualification aq1 = new AttributeQualification(); aq1.setAttribute(PublicObject.ACL_ATTRIBUTE); aq1.setOperatorType(AttributeQualification.EQUAL); aq1.setValue(AttributeValue.newAttributeValue(acl)); // DOC.NAME= 'FOO' AttributeQualification aq2 = new AttributeQualification(); aq2.setAttribute(PublicObject.NAME_ATTRIBUTE); aq2.setOperatorType(AttributeQualification.EQUAL); aq2.setValue("FOO"); // Put them together with an AND. With that our // SearchQualification is ready. SearchClause sc = new SearchClause(aq1, aq2, SearchClause.AND); // Let's build the SearchClassSpecification SearchClassSpecification classSpec = new SearchClassSpecification(); classSpec.addSearchClass(Document.CLASS_NAME); // Let's build the SearchSortSpecification // Let' sort by create date SearchSortSpecification sortSpec = new SearchSortSpecification(); sortSpec.add(PublicObject.CREATEDATE_ATTRIBUTE, true); // Now that all 3 components are built, it is time to build // AttributeSearchSpecification,nd attache the 3 components. AttributeSearchSpecification sp = new AttributeSearchSpecification(); sp.setSearchClassSpecification(classSpec); sp.setSearchQualification(sc); sp.setSearchSortSpecification(sortSpec) // Now we are ready to construct the search object. // You can even build a view at this point using ViewSpecification. Search s = new Search(m_Session, sp); // Open the search. This runs the query. s.open(); // At this point you can do next() on the Search and get the SearchResultObject // for each row in searcn result. After processing the results, remember to close // the search. // close s.close();
SearchClassSpecification
,
SearchSortSpecification
,
SearchQualification
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected SearchClassSpecification |
m_ClassSpecification
The SearchClassSpecification, that specifies the search & result classes.
|
protected SearchQualification |
m_Qual
The SearchTree.
|
protected SearchSortSpecification |
m_SortSpec
The SearchSortSpecification, that describes the sort order for the
Search Results.
|
CLEAR_PLAN_TABLE_PARAMETER, m_SecurityBindingInPlace, PLAN_NAME_PARAMETER, PLAN_TABLE_PARAMETER, SEARCH_ID_PARAMETER, SEARCH_SPEC_PARAMETER
Constructor and Description |
---|
AttributeSearchSpecification() |
Modifier and Type | Method and Description |
---|---|
void |
addOptimizerHint(String sqlHint)
Add an optimizer hint.
|
protected void |
bindValuesInPlace(oracle.ifs.search.BindValuesInSpecVisitor vis)
bindValuesInPlace- sets the bind Values in the SearchTree.
|
Object |
clone()
Returns a clone of this AttributeSearchSpecification.
|
protected void |
copy(AttributeSearchSpecification src)
Copies the elements from the src AttributeSearchSpecification into this
object.
|
String |
getEffectiveOptimizerHint()
Get a string representing all the supplied hints.
|
int |
getMaxItemCount()
Gets the maximum number of items that the search will return.
|
Vector |
getOptimizerHints()
Get all hints.
|
String[] |
getResultClasses()
Returns the result classes of the Search.
|
SearchClassSpecification |
getSearchClassSpecification()
Gets SearchClassSpecification of this search.
|
SearchQualification |
getSearchQualification()
Returns the SearchQualification of this search.
|
SearchSortSpecification |
getSearchSortSpecification()
Gets the SearchSortSpecification for this object.
|
protected Enumeration |
getSQL(String prefix,
S_Search srchObj,
S_LibrarySession sess,
Vector avs,
boolean searchCountOnly)
Returns an Enumeration of PreparedStatements.
|
String |
getSQLString(String prefix,
S_LibrarySession session,
boolean searchCountOnly)
Returns the SQL string for this SearchSpecification.
|
protected String |
getViewStatement(ViewSpecification vsp,
S_LibrarySession sess)
Generates a View creation statement, based on the ViewSpecification.
|
protected void |
replaceFirstOptimizerHint(String sqlHint)
Replaces the first SQL hint in the hint vector.
|
void |
setMaxItemCount(int maxCount)
Sets the max number of items that should to be returned from
the search.
|
void |
setResultClass(String clss)
If Class Specification is not set, initializes the SearchClassSpecification,
and adds clss as a result class; else this is a noop.
|
void |
setSearchClassSpecification(SearchClassSpecification scp)
Sets the SearchClassSpecification for this Search.
|
void |
setSearchQualification(SearchQualification s)
Sets the SearchQualification.
|
void |
setSearchSortSpecification(SearchSortSpecification sortSpec)
Sets the SearchSortSpecification.
|
protected int |
setSecurityParameters(S_LibrarySession sess,
PreparedStatement stmt,
S_Search srch,
int startIdx)
Sets the userid in the security clause, returns the bind offset,
which is passed to the bindVisitor.
|
void |
validate(LibrarySession sess)
Constructs or finds a SearchValidator for the specified session.
|
contentClasses, createView, explainPlan, getBoundSpecification, getContextScoreMap, getSQL, getSQL
protected SearchClassSpecification m_ClassSpecification
protected SearchQualification m_Qual
protected SearchSortSpecification m_SortSpec
public void setSearchClassSpecification(SearchClassSpecification scp) throws IfsException
scp
- SearchClassSpecificationIfsException
- if the operation failspublic void setMaxItemCount(int maxCount) throws IfsException
The maxItemCount value affects regular searches only. It does not affect the results of getItemCount(). It also does not alter the SQL, if used to create a view using ViewSpecification.
The SQL is constructed in a way so that the ORDER BY clause and rownum condition can co-exist.
maxCount
- max number of items that should be
returned from this searchIfsException
- if the operation failspublic int getMaxItemCount() throws IfsException
IfsException
- if the operation failspublic void addOptimizerHint(String sqlHint)
The SELECT statmenet used for this search will specify the hint in a comment block right after the SELECT keyword. By using hints, one can alter the query execution plan of the database optimizer. Therefore, users have to be careful in choosing hints appropriately.
sqlHint
- add a SQL-hint. This will be added to the
SELECT statement.protected void replaceFirstOptimizerHint(String sqlHint)
public Vector getOptimizerHints() throws IfsException
IfsException
- if the operation failspublic String getEffectiveOptimizerHint() throws IfsException
IfsException
- if the operation failspublic void setSearchQualification(SearchQualification s) throws IfsException
s
- SearchQualification representing SearchTreeIfsException
- if the operation failspublic SearchQualification getSearchQualification()
public void setSearchSortSpecification(SearchSortSpecification sortSpec) throws IfsException
sortSpec
- SearchSortSpecification describing Sort behavior.IfsException
- if the operation failspublic SearchSortSpecification getSearchSortSpecification() throws IfsException
IfsException
public void setResultClass(String clss) throws IfsException
clss
- single search class, which is also the result classIfsException
public String[] getResultClasses() throws IfsException
getResultClasses
in class SearchSpecification
IfsException
public SearchClassSpecification getSearchClassSpecification() throws IfsException
getSearchClassSpecification
in class SearchSpecification
IfsException
- if the operation failspublic void validate(LibrarySession sess) throws IfsException
validate
in class SearchSpecification
sess
- LibrarySession in which validation is performed.IfsException
- if validation failsSearchValidator
protected Enumeration getSQL(String prefix, S_Search srchObj, S_LibrarySession sess, Vector avs, boolean searchCountOnly) throws IfsException
The security parameters are bound by calling setSecurityParameters. Finally the BindValuesVisitor traverse the searchTree, binding any late bound Qualification values.
getSQL
in class SearchSpecification
prefix
- the generated SQL is prefixed with this String, this is used for
explain plan.srchObj
- server side Search object in which Search is being executed.sess
- server side session in which Search is being executed.avs
- list of bind valuesIfsException
- if sql generation failsSearchSpecification.getSQL(String, S_Search, S_LibrarySession, Vector, boolean)
public String getSQLString(String prefix, S_LibrarySession session, boolean searchCountOnly) throws IfsException
getSQLString
in class SearchSpecification
prefix
- sql generated is prefixed with this String. Used during explain plan.session
- server-side sessionsearchCountOnly
- if true, it generates a count(*) in select.IfsException
- if the operation fails.protected String getViewStatement(ViewSpecification vsp, S_LibrarySession sess) throws IfsException
getViewStatement
in class SearchSpecification
vsp
- details about the View for which the creation statement is to be
generated.sess
- server-side session.IfsException
- if operation fails.protected void bindValuesInPlace(oracle.ifs.search.BindValuesInSpecVisitor vis) throws IfsException
bindValuesInPlace
in class SearchSpecification
vis
- BindValues VisitorIfsException
- if operation fails.protected int setSecurityParameters(S_LibrarySession sess, PreparedStatement stmt, S_Search srch, int startIdx) throws IfsException
sess
- server-side session in which Search is being executed.stmt
- PreparedStatement for the Search, Security Values are bound into
this statement.srch
- Server side Search object in which Search is being executed.startIdx
- Bind offset in PreparedStatement.IfsException
- if operation fails.public Object clone()
clone
in class SearchSpecification
protected void copy(AttributeSearchSpecification src) throws IfsException
src
- Source AttributeSearchSpecificationIfsException
Copyright © 2023. All rights reserved.