com.ptc.windchill.cadx.search
Class IntegratedSearchTask

java.lang.Object
  extended bycom.ptc.windchill.cadx.search.IntegratedSearchTask
All Implemented Interfaces:
Externalizable, Serializable

public class IntegratedSearchTask
extends Object
implements Externalizable

Provides a search API for the client to use to get paged, sorted, and integrated database and content searches. The session id is used to get back the next page of a search that has already been executed. If the session isn't accessed in a while the session id will be timed out and the search results will not be available. After a search session id is no longer needed then the closeSession method should be used to close the session. The session id should be retrieved by using getSessionID after a successful call to search. The session id should be saved and then used to retrieve the next page if the IntegratedSearchTask instance that initiated the search can not be saved. Calling search and specifying a pageOffset will retrieve that page. The first page is offset of 0. This class is being implemented to support the increased functionality of the HTML Search for release 6. This class will be superseded in release 7 and will probably be deprecated in that release or shortly after.

Supported API: true

Extendable: false

See Also:
Serialized Form

Field Summary
static String ALL_ITERATIONS
          

Supported API: true
static String ALL_VERSIONS
          

Supported API: true
private static String CLASSNAME
           
static long EXTERNALIZATION_VERSION_UID
           
private static long NO_SESSION
           
private static int NO_TOTALSIZE
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
private  QuerySpec searchQuerySpec
           
(package private) static long serialVersionUID
           
private static String SERVER_ID
           
private  long sessionID
           
private  int totalSize
           
private static boolean VERBOSE
           
 
Constructor Summary
IntegratedSearchTask()
          Get a new instance of IntegratedSearchTask to use for new searches.
IntegratedSearchTask(long a_sessionID)
          Get a new instance of IntegratedSearchTask to use with a previous paging session.
 
Method Summary
 void clearSession()
          Closes an older session and clears the session id and total size attributes in preparation for a new search.
 void closeSession()
          Used to close a database paging session.
 QueryResult customSearch(Vector classnames, Hashtable criteria, Hashtable criteriaIBA, Vector criteriaKeyword, boolean isAnd, Vector displayAttributes, Vector sortKeys, int pageOffset, int pageRange, String searchFilter, Vector contentLibrary, Locale locale)
           
private  Vector getClassList(Vector classnames)
           
 QuerySpec getCustomSearchQuerySpec()
           
 QueryResult getPage(int offset, int range, Vector displayAttributes)
          Get the specified page from an existing search results.
 long getSessionID()
          Return the session id of this paging session.
 int getTotalSize()
          Return the total number of objects in the search results.
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(IntegratedSearchTask thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
 QueryResult search(Vector classnames, Hashtable criteria, String keyword, Vector displayAttributes, Vector sortKeys, int pageOffset, int pageRange, String searchFilter, Vector contentLibrary, Locale locale)
          Will execute a search against the content search engine and the database search using all of the parameters.
 QueryResult search(Vector classnames, Hashtable criteria, String keyword, Vector displayAttributes, Vector sortKeys, int pageRange, String searchFilter, Vector contentLibrary, Locale locale)
          Will execute a search against the content search engine and the database search using all of the parameters.
private  void setSessionID(long a_sessionID)
           
private  void setTotalSize(int a_totalSize)
           
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

sessionID

private long sessionID

totalSize

private int totalSize

searchQuerySpec

private QuerySpec searchQuerySpec

ALL_VERSIONS

public static final String ALL_VERSIONS


Supported API: true

See Also:
Constant Field Values

ALL_ITERATIONS

public static final String ALL_ITERATIONS


Supported API: true

See Also:
Constant Field Values

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

NO_SESSION

private static final long NO_SESSION
See Also:
Constant Field Values

NO_TOTALSIZE

private static final int NO_TOTALSIZE
See Also:
Constant Field Values

VERBOSE

private static final boolean VERBOSE

SERVER_ID

private static final String SERVER_ID
Constructor Detail

IntegratedSearchTask

public IntegratedSearchTask()
Get a new instance of IntegratedSearchTask to use for new searches.

Supported API: true


IntegratedSearchTask

public IntegratedSearchTask(long a_sessionID)
Get a new instance of IntegratedSearchTask to use with a previous paging session. The total size of the query results will be set to -1 until a successful retrieval of a page from the database.

Supported API: true

Parameters:
a_sessionID - Session id for an existing paging session. Retrieved from a previous search of IntegratedSearchTask. Session ids will automatically time out if not used for a period of time. Paging sessions that are no longer needed should be closed.
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(IntegratedSearchTask thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

clearSession

public void clearSession()
Closes an older session and clears the session id and total size attributes in preparation for a new search.

Supported API: true


closeSession

public void closeSession()
                  throws WTException
Used to close a database paging session.

Supported API: true

Throws:
WTException

search

public QueryResult search(Vector classnames,
                          Hashtable criteria,
                          String keyword,
                          Vector displayAttributes,
                          Vector sortKeys,
                          int pageRange,
                          String searchFilter,
                          Vector contentLibrary,
                          Locale locale)
                   throws WTException
Will execute a search against the content search engine and the database search using all of the parameters. Will do a fresh search and reset the session id for the paging session. Returns the first page of the search.

Supported API: true

Parameters:
classnames - A list of the classes (of type Class not String) that this search will use in a compound search. All of the criteria attributes and the sorting attributes must be the same for each of the classes in the list. The sorting must be in the same order and the types of the attributes must be the same.
criteria - A series of name value pairs of type String that specify the search criteria. The "keyword" name with a value for the string specifies the keyword used in the content search.
keyword - String used to search against the content search engine. If this string is null no content search will be run. Set this string to null if there is no content search engine installed on the system.
displayAttributes - List of attributes that are used to inflate the attribute values after a search.
sortKeys - List of sort key strings that the results should be sorted in. The keys are ordered with the first sort key being the first in the list. The string is of the format: : Where attribute name is the name of the column to be sorted on and descending is a boolean that specifies true for descending and false for ascending order. False is the default if no value is specified.
pageRange - For the database paging of the search results this sets the size of a page.
searchFilter - Can be set to either ALL_VERSIONS or ALL_ITERATIONS. The ALL_VERSIONS will return the latest iteration of each of the versions for the iterated object. ALL_ITERATIONS will return all iterations of all versions of the iterated object.
contentLibrary - A list of the content libraries which the content search should be executed against.
locale - Locale of the client that is executed this method.
Returns:
QueryResult
Throws:
WTException

search

public QueryResult search(Vector classnames,
                          Hashtable criteria,
                          String keyword,
                          Vector displayAttributes,
                          Vector sortKeys,
                          int pageOffset,
                          int pageRange,
                          String searchFilter,
                          Vector contentLibrary,
                          Locale locale)
                   throws WTException
Will execute a search against the content search engine and the database search using all of the parameters. If there already is a session id set on this class then this method will first attempt to retrieve the page specified by the pageOffset parameter. If the attempt to retrieve the page fails due to the session having already been timed out this method will reexecute the search using the specified criteria. This class does not save the criteria for the session so if the criteria is changed and the session id is valid it will not execute the new criteria. If a new search is desired then the session id should be cleared with clearSession method and then call this method or the other search method should be used.

Supported API: true

Parameters:
classnames - A list of the classes (of type Class not String) that this search will use in a compound search. All of the criteria attributes and the sorting attributes must be the same for each of the classes in the list. The sorting must be in the same order and the types of the attributes must be the same.
criteria - A series of name value pairs of type String that specify the search criteria. The "keyword" name with a value for the string specifies the keyword used in the content search.
keyword - String used to search against the content search engine. If this string is null no content search will be run. Set this string to null if there is no content search engine installed on the system.
displayAttributes - List of attributes that are used to inflate the attribute values after a search or retrieval of a page.
sortKeys - List of sort key strings that the results should be sorted in. The keys are ordered with the first sort key being the first in the list. The string is of the format: : Where attribute name is the name of the column to be sorted on and descending is a boolean that specifies true for descending and false for ascending order. False is the default if no value is specified.
pageOffset - For the database paging of the search results this is the page offset into the results that is being requested. If the session id has been set to a valid session then a new query is not done but the offset is used to return a specific page of the query results. The first page is 0.
pageRange - For the database paging of the search results this sets the size of a page.
searchFilter - Can be set to either ALL_VERSIONS or ALL_ITERATIONS. The ALL_VERSIONS will return the latest iteration of each of the versions for the iterated object. ALL_ITERATIONS will return all iterations of all versions of the iterated object.
contentLibrary - A list of the content libraries which the content search should be executed against.
locale - Locale of the client that is executed this method.
Returns:
QueryResult
Throws:
WTException

getPage

public QueryResult getPage(int offset,
                           int range,
                           Vector displayAttributes)
                    throws WTException
Get the specified page from an existing search results. Returns an exception if the session has timed out. Do a the search again and specify the page of the search if the session times out.

Supported API: true

Parameters:
offset - For the database paging of the search results this is the page offset into the results that is being requested. The first page is 0, the second is 1, ....
range - For the database paging of the search results this sets the size of a page.
displayAttributes - List of attributes that are used to inflate the attribute values after a search or retrieval of a page.
Returns:
QueryResult
Throws:
WTException

getSessionID

public long getSessionID()
Return the session id of this paging session. A valid session id can only be retrieved after search has been called to do a database search or a session id has been set from a previous IntegratedSearchTask instance. The session id should be saved if the IntegratedSearchTask instance that generated the search is not kept. Use the IntegratedSearchTask(sessionID) constructor to recapture the old session. Paging sessions are automatically timed out by the database so a new search may be necessary if too much time has elapsed between requests for pages. Use closeSession to close a paging session after it is no longer needed.

Supported API: true

Returns:
long

getTotalSize

public int getTotalSize()
Return the total number of objects in the search results. This method will return -1 if this instance of IntegratedSearchTask was just created and no connection to the search results has been attempted. Either of the search methods or the getPage method will set the totalSize attribute and then a call to this method will return the number of objects in the full search results.

Supported API: true

Returns:
int

setTotalSize

private void setTotalSize(int a_totalSize)

setSessionID

private void setSessionID(long a_sessionID)

getClassList

private Vector getClassList(Vector classnames)
                     throws WTException
Throws:
WTException

customSearch

public QueryResult customSearch(Vector classnames,
                                Hashtable criteria,
                                Hashtable criteriaIBA,
                                Vector criteriaKeyword,
                                boolean isAnd,
                                Vector displayAttributes,
                                Vector sortKeys,
                                int pageOffset,
                                int pageRange,
                                String searchFilter,
                                Vector contentLibrary,
                                Locale locale)
                         throws WTException
Throws:
WTException

getCustomSearchQuerySpec

public QuerySpec getCustomSearchQuerySpec()