Using the Generic Query Framework
The resource engine constructs a generic query object and passes it to
domain developers through the ResourceDomain3 interface method findResourceByQuery().
The developer can take one of the following approaches to convert this query
object into a meaningful domain query string.
- Walk through the query object. Note: The com.ibm.websphere.query.base.Query
class contains query components that the developer can cover to generate domain
specific query string. For detailed information on query hierarchy and components,
see the Portal Personalization API documentation.
- Use a system provided builder callback . There are nine builder callbacks:
- IBM® DB2 Universal Database™ Enterprise
Server Edition:
(com.ibm.websphere.query.callbacks.DB2SqlSelectQueryCallback)
- IBM DB2 Universal Database for z/OS®:
(com.ibm.websphere.query.callbacks.DB2390SqlSelectQueryCallback)
- IBM DB2 for i5/OS™:
(com.ibm.websphere.query.callbacks.DB2400SqlSelectQueryCallback)
- Oracle Enterprise Edition:
(com.ibm.websphere.query.callbacks.OracleSelectQueryCallback)
- LDAP: (com.ibm.websphere.query.callbacks.LdapSelectQueryCallback)Note: The
LDAP callback supports a set of function common to many LDAP repositories.
Users may subclass this callback to support more advanced vendor specific
functions.
Property resolution and query syntax conversion are handled
in the callbacks. The developer can prepare a property mapping hash table
and use it with one of the callbacks above to build the executable query string.
Here is the sample code for SQL query string generation:String s=q.buildString(new SqlSelectQueryCallback(h));
where q is a query object, and h is
a property mapping hash table.
For detailed information on these
builder callbacks, see the Personalization API
documentation.
- Develop and use a domain specific builder callback.If the system provided
builder callbacks do not satisfy resource domain requirements, a domain specific
builder callback can be created and used as long as it implements ISelectQueryCallback.
The developer can decide the mechanisms to interpret properties and derive
the proper query syntax in their own callbacks. The code would look like:
String s=q.buildString(new MySelectQueryCallback(myParameter));
where q is
a query object, and MySelectQueryCallback is the custom
builder callback that takes myParameter as parameter.
Parent topic: Generic query framework
|
|
|