Collaboration API Documentation

com.filenet.bso.api.util
Class BsoSearch

java.lang.Object
  |
  +--com.filenet.bso.api.util.BsoSearch

public class BsoSearch
extends java.lang.Object

This class encapsulates ad hoc Content Engine queries and returns the results as raw XML or Document Object Model (DOM) for the search. The class also provides a method to query for Content Object IDs and return thos as a String[]. The class also provides a convenience method that returns the namespaces used in the XML for working with the DOM.

The following example illustrates the use of this class. Consider a Financial Center application that has a requirement to find all of the opportunities for all subordinates of a particular supervisor, Sue. The results are to be returned as XML, ordered by company name, deal, and opportunity. The code example below returns XML with <row> elements that have Company, DealName, DealId, CaseOwner, CaseName, CaseId, DollarValue, and ClosingDate attributes.

 	String select = "SELECT d.Company, d.FolderName AS DealName, d.Id AS DealId, " +
 		        "o.CaseOwner, o.FolderName AS CaseName, o.Id AS CaseId, " +
 			"DollarValue, ClosingDate" +
 			"FROM DealFolder d INNER JOIN DealOpportunity o " +
 			"ON d.this = o.Parent" +
 			"WHERE o.CaseSupervisor = 'sue' " +
 			"ORDER BY d.Company, d.FolderName, o.FolderName";

 	String xmlResult = BsoSearch(objectStore, select, 0);
 
Example of how to use the query for object ids method:
       StringBuffer queryString = new StringBuffer();

       queryString.append("SELECT ");
       queryString.append(Property.ID);
       queryString.append(" FROM ");
       queryString.append(CASEWORK_SYMNAME);
       queryString.append(" WHERE ");
       queryString.append(CASEFILEID_SYMNAME);
       queryString.append(" = ");
       queryString.append(caseFileFolderID);

       String[] queryResults = BsoSearch.queryForObjectIDS(store, queryString.toString());
 
The queryResults String array variable contains all Content Engine object GUIDs that match the query.

See Also:
java.lang.MessageFormat#format()

Field Summary
static java.lang.String XPATH_DATA_SELECTOR
          An XPath selector that can be used to find the data rows
 
Method Summary
static void addSelectProperties(java.lang.StringBuffer sb, java.lang.String[] requestedProps, java.lang.String[] manditoryProps)
          Adds a group of properties to a select statement.
static void addSelectProperties(java.lang.StringBuffer sb, java.lang.String[] requestedProps, java.lang.String[] manditoryProps, java.lang.String classAlias, java.lang.String columnAliasPrefix, boolean bContinue)
          Adds a group of properties to a select statement.
static int convertSearchResultDataType(java.lang.String resultDataType)
          Converts a data type as represented in the search results XML to a Content Engine data type.
static org.w3c.dom.Document getDOM(com.filenet.wcm.api.ObjectStore obs, java.lang.String select, int maxrecs)
          Queries an object store and returns the results in a DOM document.
static org.w3c.dom.Node getNamespace(org.w3c.dom.Document dom)
          Returns the XML namespace for the search.
static java.lang.String getRawXML(com.filenet.wcm.api.ObjectStore obs, java.lang.String select, int maxrecs)
          Queries an object store and returns the results in raw, ADO XML format.
static java.lang.String getRawXML(com.filenet.wcm.api.ObjectStore obs, java.lang.String select, int maxrecs, boolean objectAsId)
          Queries an object store and returns the results in raw, ADO XML format.
static java.lang.String[] queryForObjectIDs(com.filenet.wcm.api.ObjectStore store, java.lang.String selectStmt)
          Perform a search operation based on the given select statement and return a string array of IDs for Content Engine objects that satisfy the query.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XPATH_DATA_SELECTOR

public static final java.lang.String XPATH_DATA_SELECTOR
An XPath selector that can be used to find the data rows
Method Detail

getRawXML

public static java.lang.String getRawXML(com.filenet.wcm.api.ObjectStore obs,
                                         java.lang.String select,
                                         int maxrecs)
Queries an object store and returns the results in raw, ADO XML format. The same as calling getRawXML(obs, select, maxrecs, false).

getRawXML

public static java.lang.String getRawXML(com.filenet.wcm.api.ObjectStore obs,
                                         java.lang.String select,
                                         int maxrecs,
                                         boolean objectAsId)
Queries an object store and returns the results in raw, ADO XML format.

Parameters:
obs - The object store against which this query runs.

select - A String containing a Content Engine SELECT statement, which differs from a standard SQL SELECT (see Content Engine documentation). Note: be careful of column names that are the same as SQL reserved words; if in doubt, surround the name with escape characters ([ ]).

maxrecs - The maximum number of records to return; specify 0 to return all records found.

objectAsId - If true, returns object valued properties as ID values. If your select statement includes object valued properties this argument must be specified to turn on that feature of the search. Otherwise an error will be returned because the property values cannot be returned as XML.

Returns:
A String that contains XML representing the search results in raw, ADO XML format.

addSelectProperties

public static void addSelectProperties(java.lang.StringBuffer sb,
                                       java.lang.String[] requestedProps,
                                       java.lang.String[] manditoryProps)
Adds a group of properties to a select statement. This variation of the method is suitable for adding properties when only returning properties from one class.
Parameters:
sb - String buffer accumulating the query statement.
requestedProps - Required, the property symbolic names to add to the select statement.
manditoryProps - Optional, another array of property symbolic names for properties that must be in the select statement. You could use this second array to indicate properties that your implementation requires and the first array are properties a user or other caller requests.

addSelectProperties

public static void addSelectProperties(java.lang.StringBuffer sb,
                                       java.lang.String[] requestedProps,
                                       java.lang.String[] manditoryProps,
                                       java.lang.String classAlias,
                                       java.lang.String columnAliasPrefix,
                                       boolean bContinue)
Adds a group of properties to a select statement. This variation of the method can be used to add properties from multiple classes when the query involves one or more joins.
Parameters:
sb - String buffer accumulating the query statement.
requestedProps - Required, the property symbolic names to add to the select statement.
manditoryProps - Optional, another array of property symbolic names for properties that must be in the select statement. You could use this second array to indicate properties that your implementation requires and the first array are properties a user or other caller requests.
classAlias - If non-null, the property names will be prefixed with this alias followed by a dot ("."). For example, d.DocumentTitle
columnAliasPrefix - If non-null, the property names will be given an alias in brackets ([]) as the property name prefixed by this alias. For example if the the alias prefix is "d_", a column alias in brackets will be something like [d_DocumentTitle].
bContinue - If true, indicates these properties are a continuation from previous properties. An initial "," will be added to the properties.

convertSearchResultDataType

public static int convertSearchResultDataType(java.lang.String resultDataType)
Converts a data type as represented in the search results XML to a Content Engine data type.

getDOM

public static org.w3c.dom.Document getDOM(com.filenet.wcm.api.ObjectStore obs,
                                          java.lang.String select,
                                          int maxrecs)
Queries an object store and returns the results in a DOM document.
Parameters:
obs - The object store.
select - A String containing a Content Engine SELECT statement, which differs from a standard SQL SELECT (see Content Engine documentation). Note: be careful of column names that are the same as SQL reserved words; if in doubt, surround the name with escape characters ([ ]).

maxrecs - The maximum number of records to return; specify 0 to return all records found.

Returns:
A DOM Document object representing the search results.

getNamespace

public static org.w3c.dom.Node getNamespace(org.w3c.dom.Document dom)
Returns the XML namespace for the search. As a side effect, this method also creates a node for the namespace in the DOM.

Parameters:
dom - The DOM to use, preferably one returned by an earlier getDOM call.

Returns:
A DOM namespace node.

queryForObjectIDs

public static java.lang.String[] queryForObjectIDs(com.filenet.wcm.api.ObjectStore store,
                                                   java.lang.String selectStmt)
Perform a search operation based on the given select statement and return a string array of IDs for Content Engine objects that satisfy the query.

The select statement must include ID as a select item.

Parameters:
store - The object store.
selectStmt - A String containing a Content Engine SELECT statement, which differs from a standard SQL SELECT (see Content Engine documentation). Note: be careful of column names that are the same as SQL reserved words; if in doubt, surround the name with escape characters ([ ]).

Returns:
A String array of Content Engine IDs.

Collaboration API Documentation

Copyright © 2002 - 2004 FileNet Corporation. All rights reserved.