Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.ifs.search
Class ContextSearchSpecification

    java.lang.Object
      oracle.ifs.search.SearchSpecification
          oracle.ifs.search.AttributeSearchSpecification
              oracle.ifs.search.ContextSearchSpecification

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable

    public class ContextSearchSpecification

extends AttributeSearchSpecification

A ContextSearchSpecification represents a Search on both Attributes and Content. The SearchQualification (SearchTree) of a ContextSearchSpecification should have at least one ContextQualification.

The user must also specify the Class on which the ContextQualifications are to be applied.

The Text Query of each ContextQualification is applied on each Media. The result will contain entries from all the Media. The Media rows will be joined with the ContextClass, so that only the Content of objects in the ContextClass is considered. Otherwise, there is nothing special about what is returned by a Context Search. For every result row, the conditions defined by the SearchTree must hold.

>      // Usage Examples

>      // How to build a Context Search specification
>      // Process is very similar to that of building an AttributeSearchSpecification.

>      // Construct the ContextSearchSpecification.
>      ContextSearchSpecification csp = new ContextSearchSpecification();

>      // 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. Make sure the class
>      // spec includes the class that stores the content, CONTENTOBJECT
>      // in most cases.
>      csp.setSearchClassSpecification(someSearchSpec);

>      // Set the search qualification. Make sure there is
>      // at least one ContextQualification in this.
>      csp.setSearchQualification(someSearchQual);

>      // Set the sort specification. Specify context
>      // score based ordering in the sort spec if necessary.
>      csp.setSearchSortSpecification(someSortSpec);

>      // One extra step in ContextSearchSpecification is to
>      // setup the context search class.
>      csp.setContextClassname(ContentObject.CLASS_NAME);

>      // 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. Note that View itself will not have
>      // content in it.
>      ViewSpecification viewSpec = new ViewSpecification("TestView", asp);

>      // ---------------------------------------------------------------
>      // Complete example of a Search using ContextSearchSpecification
>      // ---------------------------------------------------------------

>      // Let's build a search that looks for all DOCUMENTS with a given
>      // word "FOOBAR" and are named FOO.

>      // Let's build the WHERE condition first.
>      // It will be - DOC.Contains(FOOBAR) and DOC.NAME='FOO'

>      // DOC.Contains = FOO
>      String contextClauseName = "CQ1";
>      String queryTerm = "FOOBAR";
>      ContextQualification cq1 = new ContextQualification();
>      cq1.setQuery(queryTerm);
>      cq1.setName(contextClauseName);
>      // Since content in stored in CONTENTOBJECT, the above
>      // ContextQualification is actually doing a contains on CONTENETOBJECT.
>      // Therefore, we need to join the CONTENTOBJECT with DOCUMENT.
>      // Create a JoinQualification. This sort of join is a must
>      // for all context searches.
>      // SQL generated - DOC.CO = CO.ID
>      JoinQualification jq1 = new JoinQualification();
>      jq1.setLeftAttribute(Document.CLASS_NAME, Document.CONETNTOBJECT_ATTRIBUTE);
>      jq1.setRightAttribute(ContentObject.CLASS_NAME, null);

>      // DOC.NAME= 'FOO'
>      AttributeQualification aq1 = new AttributeQualification();
>      aq1.setAttribute(PublicObject.NAME_ATTRIBUTE);
>      aq1.setOperatorType(AttributeQualification.EQUAL);
>      aq1.setValue("FOO");

>      // Put them together with an AND. With that our
>      // SearchQualification is ready.
>      // The search tree looks like - cq1 AND aq1 and jq1
>      SearchClause sc = new SearchClause(cq1, aq1, SearchClause.AND);
>      sc = new SearchClause(sc, jq1, SearchClause.AND);

>      // Let's build the SearchClassSpecification
>      SearchClassSpecification classSpec = new SearchClassSpecification();
>      classSpec.addSearchClass(Document.CLASS_NAME);
>      classSpec.addSearchClass(ContentObject.CLASS_NAME);

>      // Let's build the SearchSortSpecification

>      // Let' sort by context score. Note the use of contextClauseName
>      SearchSortSpecification sortSpec = new SearchSortSpecification();
>      sortSpec.add(Document.CLASS_NAME, ContextQualification.ORDER_PREFIX + "." + contextClauseName);

>      // Now that all 3 components are built, it is time to build
>      // AttributeSearchSpecification,nd attache the 3 components.

>      ContextSearchSpecification csp = new ContextSearchSpecification();
>      csp.setSearchClassSpecification(classSpec);
>      csp.setSearchQualification(sc);
>      csp.setSearchSortSpecification(sortSpec)

>      // Remember to set the context class name
>      csp.setContextClassname(ContentObject.CLASS_NAME);

>      // 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, csp);

>      // 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();

See Also:
  Serialized Form
(Published)

Field Summary
`protected java.util.Hashtable` | `m_ContentClasses` In a future release, there will be support for ContextQualifications on multiple classes.
`protected java.lang.Long` | `m_ContextClassId` ClassId of Context Search Class
`protected java.lang.String` | `m_ContextClassName` Name of Class on which Context Qualifications will be appllied.
`protected boolean` | `m_ContextConditionUnderOrOperator` Indicates that the context condition is under a a 'OR' operator.
`protected boolean` | `m_HasContextQualifier` True if Specification contains, a COntextQualification.

Fields inherited from class oracle.ifs.search.AttributeSearchSpecification
`m_ClassSpecification, m_Qual, m_SortSpec`

Fields inherited from class oracle.ifs.search.SearchSpecification
`CLEAR_PLAN_TABLE_PARAMETER, m_SecurityBindingInPlace, PLAN_NAME_PARAMETER, PLAN_TABLE_PARAMETER, SEARCH_ID_PARAMETER, SEARCH_SPEC_PARAMETER`

Constructor Summary
`ContextSearchSpecification()` Constructs a ContextSearchSpecification.

Method Summary
`protected void` | `addContentClass(java.lang.String clss)` Adds the specified class to the list of classes for which the readContent check must be performed.
`java.lang.Object` | `clone()` Returns a clone of this ContextSearchSpecification.
`java.lang.String[]` | `contentClasses()` Returns list of classes for read content check must be performed.
`protected void` | `copy(ContextSearchSpecification src)` Copies the elements from the src ContextSearchSpecification into this object.
`java.lang.Long` | `getContextClassId()` Returns id of Context Search Class
`java.lang.String` | `getContextClassname()` Returns the name of the class used for Text queries.
`java.util.Hashtable` | `getContextScoreMap()` Returns a mapping from SCORE expression numbers to ContextQualifier names.
`boolean` | `getFastResponseType()` Returns true if the search qualifies for rewrite as fast response context search.
`protected boolean` | `getHasContextQualifier()` Returns whether SearchTree contains any ContextQualifications.
`protected java.lang.String` | `getQueryTerm()` Returns the query term used by the fast response search.
`protected java.util.Enumeration` | `getSQL(java.lang.String prefix, S_Search srchObj, S_LibrarySession sess, java.util.Vector avs, boolean searchCountOnly)` Returns an Enumeration of PreparedStatements.
`java.lang.String` | `getSQLString(java.lang.String prefix, S_LibrarySession session, boolean searchCountOnly)` Returns the SQL string for this SearchSpecification.
`protected java.lang.String` | `getViewStatement(ViewSpecification vsp, S_LibrarySession sess)` Generates a View creation statement, based on the ViewSpecification.
`protected boolean` | `isContextConditionUnderOrOperator()` Returns true if the context serach condition is under an OR operator in the search tree; False otherwise.
`void` | `setContextClassname(java.lang.String cn)` Set the Class to be used for Text Queries.
`void` | `setContextConditionUnderOrOperatorFlag(boolean value)` Used to indicate that the context condition is under an 'OR' operator in the search tree.
`protected void` | `setFastResponseType(boolean type)` Sets the search to a fast response search.
`protected void` | `setHasContextQualifier(boolean hasQual)` Sets whether SearchTree has ContextQualifications.
`protected void` | `setQueryTerm(java.lang.String term)` Sets the query term that is speficied in the search tree.
`void` | `validate(LibrarySession sess)` Constructs or finds a SearchValidator for the specified session.

Methods inherited from class oracle.ifs.search.AttributeSearchSpecification
`addOptimizerHint, bindValuesInPlace, copy, getEffectiveOptimizerHint, getMaxItemCount, getOptimizerHints, getResultClasses, getSearchClassSpecification, getSearchQualification, getSearchSortSpecification, replaceFirstOptimizerHint, setMaxItemCount, setResultClass, setSearchClassSpecification, setSearchQualification, setSearchSortSpecification, setSecurityParameters`

Methods inherited from class oracle.ifs.search.SearchSpecification
`createView, explainPlan, getBoundSpecification, getSQL, getSQL`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### m_ContextClassId

    protected java.lang.Long m_ContextClassId

  Description copied from class: `ContextSearchSpecification`
  ClassId of Context Search Class

  (Unpublished)

### m_ContextClassName

    protected java.lang.String m_ContextClassName

  Description copied from class: `ContextSearchSpecification`
  Name of Class on which Context Qualifications will be appllied. Must be a subclass of Document.

  (Unpublished)

### m_HasContextQualifier

    protected boolean m_HasContextQualifier

  Description copied from class: `ContextSearchSpecification`
  True if Specification contains, a COntextQualification. If this is false, this can behave as an AttributeSearchSpecification.

  (Unpublished)

### m_ContentClasses

    protected java.util.Hashtable m_ContentClasses

  Description copied from class: `ContextSearchSpecification`
  In a future release, there will be support for ContextQualifications on multiple classes. ReadAccessCheck functions already work on this assumption. List of classes for which a ctx qualifier is specified. Among other things this list will be used when deciding which classes to apply readAccessCheck on.

  (Unpublished)

### m_ContextConditionUnderOrOperator

    protected boolean m_ContextConditionUnderOrOperator

  Description copied from class: `ContextSearchSpecification`
  Indicates that the context condition is under a a 'OR' operator. This is used to indicate that context condition satisfaction is not a must have.

Constructor Detail

### ContextSearchSpecification

    public ContextSearchSpecification()

  Constructs a ContextSearchSpecification.

  (Published)

Method Detail

### setHasContextQualifier

    protected void setHasContextQualifier(boolean hasQual)

  Description copied from class: `ContextSearchSpecification`
  Sets whether SearchTree has ContextQualifications. Called from the ValidationVisitor.

  Parameters:
    `hasQual` - specify whether this has a ContextQualification.
  (Unpublished)

### getHasContextQualifier

    protected boolean getHasContextQualifier()

  Description copied from class: `ContextSearchSpecification`
  Returns whether SearchTree contains any ContextQualifications.

  Returns:
    true if there are CQs, false otherwise.
  (Unpublished)

### setQueryTerm

    protected void setQueryTerm(java.lang.String term)
                         throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Sets the query term that is speficied in the search tree. Used by the FastResponseContextSearchHelper to during validation.

  Throws:
    `IfsException`
  (Unpublished)

### getQueryTerm

    protected java.lang.String getQueryTerm()
                                     throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Returns the query term used by the fast response search. Used internally by FastResponseContextSearchHelper during SQL generation.

  Throws:
    `IfsException`
  (Unpublished)

### setContextClassname

    public void setContextClassname(java.lang.String cn)
                             throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Set the Class to be used for Text Queries. The class should be a subClass of ContentObject or ContentObject itself.

  Parameters:
    `cn` - Text Queries in ContextQualifications are applied on the content of objects of this class.
  Throws:
    `IfsException` - if the operation fails
  (Published)

### getContextClassname

    public java.lang.String getContextClassname()
                                         throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Returns the name of the class used for Text queries.

  Returns:
    Context Search Class.
  Throws:
    `IfsException` - if the operation fails
  (Published)

### getContextClassId

    public java.lang.Long getContextClassId()

  Description copied from class: `ContextSearchSpecification`
  Returns id of Context Search Class

  Returns:
    id of Context Search Class
  (Unpublished)

### validate

    public void validate(LibrarySession sess)
                  throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Constructs or finds a SearchValidator for the specified session. Calls on it to do the actual Validation.

  Overrides:
    `validate` in class `AttributeSearchSpecification`
  Parameters:
    `sess` - LibrarySession in which validation is performed.
  Throws:
    `IfsException` - if validation fails
  See Also:
    `SearchValidator`
  (Unpublished)

### setFastResponseType

    protected void setFastResponseType(boolean type)
                                throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Sets the search to a fast response search. Used by the FastResponseContextSearchHelper class.

  Throws:
    `IfsException`
  (Unpublished)

### getFastResponseType

    public boolean getFastResponseType()
                                throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Returns true if the search qualifies for rewrite as fast response context search. Currently following requirements need to be met prior to rewriting a search as fast response type. 1. Search should not have any SearchSortSpecification set. 2. Search tree should have only AND operators Return value of this method is only valid after the search has been opened or getSQL() method has been called.

  Returns:
    true, if the search is fast response type; false otherwise
  Throws:
    `IfsException` - if the operation fails
  (Published)

### getViewStatement

    protected java.lang.String getViewStatement(ViewSpecification vsp,
                                                S_LibrarySession sess)
                                         throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Generates a View creation statement, based on the ViewSpecification.

  Overrides:
    `getViewStatement` in class `AttributeSearchSpecification`
  Parameters:
    `vsp` - details about the View for which the creation statement is to be generated.
    `sess` - server-side session.
  Returns:
    String containing SQL to create the view
  Throws:
    `IfsException` - if operation fails.
  (Unpublished)

### getSQL

    protected java.util.Enumeration getSQL(java.lang.String prefix,
                                           S_Search srchObj,
                                           S_LibrarySession sess,
                                           java.util.Vector avs,
                                           boolean searchCountOnly)
                                    throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Returns an Enumeration of PreparedStatements. For an ContextSearchSpecification Enumeration contains only one statement. Finds or constructs a SQLGenerator object for the session, and calls on it generate the SQL statement. The srchObj creates the PreparedStatement from the sqlStr.

  There are one or more Media table over which the Search is performed. THe ContextBridge returns the list of Media Tables based on the list of Searched Media. The generated SQL is a union of selects, with each select apllied on a media table. The number of Media Tables is not dependent on the number of Searched Media, but depends on how the Media are implemented. Each Media Table can contain multiple Content columns.

  For each MediaTable (select within the union) the security parameters are bound by calling setSecurityParameters. The BindValuesVisitor traverse the searchTree, binding any late bound Qualification values.

  Overrides:
    `getSQL` in class `AttributeSearchSpecification`
  Parameters:
    `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 values
  Returns:
    list of PreparedStatements
  Throws:
    `IfsException` - if sql generation fails
  See Also:
    `SearchSpecification.getSQL(String, S_Search, S_LibrarySession, Vector, boolean)`
  (Unpublished)

### getSQLString

    public java.lang.String getSQLString(java.lang.String prefix,
                                         S_LibrarySession session,
                                         boolean searchCountOnly)
                                  throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Returns the SQL string for this SearchSpecification.

  Overrides:
    `getSQLString` in class `AttributeSearchSpecification`
  Parameters:
    `prefix` - sql generated is prefixed with this String. Used during explain plan.
    `session` - server-side session
    `searchCountOnly` - if true, it generates a count(*) in select.
  Returns:
    the SQL generated for this specification.
  Throws:
    `IfsException` - if the operation fails.
  (Unpublished)

### getContextScoreMap

    public java.util.Hashtable getContextScoreMap()
                                           throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Returns a mapping from SCORE expression numbers to ContextQualifier names. Calls on a ContextScoreVisitor to traverse the SearchTree and generate this mapping.

  Overrides:
    `getContextScoreMap` in class `SearchSpecification`
  Returns:
    mapping as a Hashtable.
  Throws:
    `IfsException` - if operation fails.
  (Unpublished)

### clone

    public java.lang.Object clone()

  Description copied from class: `ContextSearchSpecification`
  Returns a clone of this ContextSearchSpecification. Does a deep copy, by cloning the individual elements.

  Overrides:
    `clone` in class `AttributeSearchSpecification`
  Returns:
    Return a clone of this ContextSearchSpecification.
  (Unpublished)

### copy

    protected void copy(ContextSearchSpecification src)
                 throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Copies the elements from the src ContextSearchSpecification into this object. The copies are created by cloning.

  Parameters:
    `src` - Source ContextSearchSpecification
  Throws:
    `IfsException`
  (Unpublished)

### addContentClass

    protected void addContentClass(java.lang.String clss)
                            throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Adds the specified class to the list of classes for which the readContent check must be performed.

  Parameters:
    `clss` - Class for which readContent Check must be performed.
  Throws:
    `IfsException`
  (Unpublished)

### contentClasses

    public java.lang.String[] contentClasses()
                                      throws IfsException

  Description copied from class: `ContextSearchSpecification`
  Returns list of classes for read content check must be performed. The readContent check is performed on the objects in a result row.

  Overrides:
    `contentClasses` in class `SearchSpecification`
  Returns:
    classes on which readContent check must be performed.
  Throws:
    `IfsException` - if operation fails.
  (Unpublished)

### setContextConditionUnderOrOperatorFlag

    public void setContextConditionUnderOrOperatorFlag(boolean value)

  Description copied from class: `ContextSearchSpecification`
  Used to indicate that the context condition is under an 'OR' operator in the search tree.

  Parameters:
    `value` - true or false
  (Unpublished)

### isContextConditionUnderOrOperator

    protected boolean isContextConditionUnderOrOperator()

  Description copied from class: `ContextSearchSpecification`
  Returns true if the context serach condition is under an OR operator in the search tree; False otherwise. The returned value is not calculated. It is based on what the API user has previously set.

  Returns:
    true or false
  (Unpublished)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD