com.ptc.windchill.cadx.search
Class DatabaseSearch

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

public class DatabaseSearch
extends Object
implements Externalizable

Utility class for processing the database search part of the integrated search.

Supported API: true

Extendable: false

See Also:
Serialized Form

Field Summary
private static String CLASSNAME
           
(package private)  Vector classnames
           
(package private)  Hashtable criteria
           
(package private)  QuerySpec customSearch
           
(package private)  Vector displayAttributes
           
private static String ESCAPE
           
private static char[] escapeChrs
           
static long EXTERNALIZATION_VERSION_UID
           
(package private)  Locale locale
           
protected static long OLD_FORMAT_VERSION_UID
           
private static char ORACLE_ANY_CHAR
           
private static char ORACLE_ANY_CHARS
           
private static String RESOURCE
           
private static char SEARCH_ANY_CHAR
           
private static char SEARCH_ANY_CHARS
           
(package private)  String searchFilter
           
(package private) static long serialVersionUID
           
(package private)  Vector sortKeys
           
private static boolean VERBOSE
           
private static char WILDCARD_ESCAPE
           
 
Constructor Summary
private DatabaseSearch(Vector classnames, Hashtable criteria, Vector displayAttributes, Vector sortKeys, String searchFilter, Locale locale)
          Create and populate an instance that can be used to build and execute the database part of the integrated search.
 
Method Summary
private  QuerySpec addConfigSpec(Class classname, QuerySpec qs, String searchFilter)
           
private  SearchCondition addOrgCriteria(Class classname, String orgAttribute, String orgAttrValue, boolean isOpposite)
           
private  QuerySpec addToWhere(QuerySpec qs, SearchCondition sc)
           
private  QuerySpec appendOidList(Class classname, int index, Vector oid_arrays)
          Append the oids list from the content search into the database search.
static Vector customDatabaseSearch(Vector classnames, Hashtable criteria, Hashtable criteriaIBA, Vector displayAttributes, Vector sortKeys, int pageOffset, int pageRange, String searchFilter, boolean isAnd, Hashtable oidList, Locale locale)
           
static PagingQueryResult databaseSearch(Vector classnames, Hashtable criteria, Vector displayAttributes, Vector sortKeys, int pageOffset, int pageRange, String searchFilter, HashMap oidList, Locale locale)
          Does the database part of the integrated search.
private  QueryResult execute(Vector query_specs)
           
private  PagingQueryResult execute(Vector query_specs, int pageOffset, int pageRange)
          After the entire set of query specs is built this method can be used to run the search.
private  SearchCondition getSearchCondition(Class classname, ClassInfo class_info, String attrib_name, String value, Locale locale)
           
static SearchCondition getWildcardEscapedCondition(SearchCondition sc, String value)
           
private  QuerySpec initQuerySpec(Class one_class)
           
private  boolean isEnumType(Class type)
           
static boolean isWildcardSearch(String value)
           
private  QuerySpec populateQuerySpec(Class classname, int i, QuerySpec qs, boolean isAnd, Vector oids, Hashtable criteriaIBA)
           
private  QuerySpec populateQuerySpec(Class classname, QuerySpec qs)
          Use all of the information that has been set on this class to populate the QuerySpec(s).
private  Vector processOids(HashMap oidList)
          Condense oids list from the content search into the correct classes for the database search.
private  Vector processOids(Hashtable oidList)
           
 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(DatabaseSearch thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
private  SearchCondition setOppositeCondition(SearchCondition sc)
           
 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

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

classnames

Vector classnames

criteria

Hashtable criteria

displayAttributes

Vector displayAttributes

sortKeys

Vector sortKeys

searchFilter

String searchFilter

locale

Locale locale

customSearch

QuerySpec customSearch

SEARCH_ANY_CHARS

private static final char SEARCH_ANY_CHARS
See Also:
Constant Field Values

ORACLE_ANY_CHARS

private static final char ORACLE_ANY_CHARS
See Also:
Constant Field Values

SEARCH_ANY_CHAR

private static final char SEARCH_ANY_CHAR
See Also:
Constant Field Values

ORACLE_ANY_CHAR

private static final char ORACLE_ANY_CHAR
See Also:
Constant Field Values

ESCAPE

private static final String ESCAPE
See Also:
Constant Field Values

escapeChrs

private static char[] escapeChrs

VERBOSE

private static final boolean VERBOSE

WILDCARD_ESCAPE

private static char WILDCARD_ESCAPE
Constructor Detail

DatabaseSearch

private DatabaseSearch(Vector classnames,
                       Hashtable criteria,
                       Vector displayAttributes,
                       Vector sortKeys,
                       String searchFilter,
                       Locale locale)
Create and populate an instance that can be used to build and execute the database part of the integrated search.

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.
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.
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.
locale - Locale of the client that is executed this method.
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(DatabaseSearch 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

databaseSearch

public static PagingQueryResult databaseSearch(Vector classnames,
                                               Hashtable criteria,
                                               Vector displayAttributes,
                                               Vector sortKeys,
                                               int pageOffset,
                                               int pageRange,
                                               String searchFilter,
                                               HashMap oidList,
                                               Locale locale)
                                        throws WTException
Does the database part of the integrated search. Uses the oid list to retrict the search to what was found by the content search. If the oid list is null then this search will do just the database 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.
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.
oidList -
locale - Locale of the client that is executed this method.
Returns:
PagingQueryResult
Throws:
WTException

processOids

private Vector processOids(HashMap oidList)
                    throws WTException
Condense oids list from the content search into the correct classes for the database search.

Parameters:
oidList - Structure of oids returned from the content search engine.
Throws:
WTException

appendOidList

private QuerySpec appendOidList(Class classname,
                                int index,
                                Vector oid_arrays)
                         throws WTException
Append the oids list from the content search into the database search.

Throws:
WTException

execute

private PagingQueryResult execute(Vector query_specs,
                                  int pageOffset,
                                  int pageRange)
                           throws WTException
After the entire set of query specs is built this method can be used to run the search.

Parameters:
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.
Returns:
PagingQueryResult
Throws:
WTException

populateQuerySpec

private QuerySpec populateQuerySpec(Class classname,
                                    QuerySpec qs)
                             throws WTException
Use all of the information that has been set on this class to populate the QuerySpec(s).

Throws:
WTException

initQuerySpec

private QuerySpec initQuerySpec(Class one_class)
                         throws WTException
Throws:
WTException

addToWhere

private QuerySpec addToWhere(QuerySpec qs,
                             SearchCondition sc)
                      throws QueryException
Throws:
QueryException

addConfigSpec

private QuerySpec addConfigSpec(Class classname,
                                QuerySpec qs,
                                String searchFilter)
                         throws WTException
Throws:
WTException

isEnumType

private boolean isEnumType(Class type)

getSearchCondition

private SearchCondition getSearchCondition(Class classname,
                                           ClassInfo class_info,
                                           String attrib_name,
                                           String value,
                                           Locale locale)
                                    throws WTException
Throws:
WTException

customDatabaseSearch

public static Vector customDatabaseSearch(Vector classnames,
                                          Hashtable criteria,
                                          Hashtable criteriaIBA,
                                          Vector displayAttributes,
                                          Vector sortKeys,
                                          int pageOffset,
                                          int pageRange,
                                          String searchFilter,
                                          boolean isAnd,
                                          Hashtable oidList,
                                          Locale locale)
                                   throws WTException
Throws:
WTException

processOids

private Vector processOids(Hashtable oidList)
                    throws WTException
Throws:
WTException

populateQuerySpec

private QuerySpec populateQuerySpec(Class classname,
                                    int i,
                                    QuerySpec qs,
                                    boolean isAnd,
                                    Vector oids,
                                    Hashtable criteriaIBA)
                             throws WTException
Throws:
WTException

addOrgCriteria

private SearchCondition addOrgCriteria(Class classname,
                                       String orgAttribute,
                                       String orgAttrValue,
                                       boolean isOpposite)
                                throws WTException
Throws:
WTException

setOppositeCondition

private SearchCondition setOppositeCondition(SearchCondition sc)
                                      throws WTException
Throws:
WTException

execute

private QueryResult execute(Vector query_specs)
                     throws WTException
Throws:
WTException

isWildcardSearch

public static boolean isWildcardSearch(String value)

getWildcardEscapedCondition

public static SearchCondition getWildcardEscapedCondition(SearchCondition sc,
                                                          String value)
                                                   throws WTException
Throws:
WTException