Using the Generic Query Framework

The resource engine constructs a generic query object and passes it to domain developers via ResourceDomain2 interface method findResourceByQuery(). The developer can take one of the following approaches to convert this query object into a meaningful domain query string.

  1. Walk through the query object

    The com.ibm.websphere.query.base.Query class contains query components that the developer can traverse through to generate domain specific query string. For detailed information on query hierarchy and components, see the Personalization API doc.

  2. Use a system provided builder callback

    There are nine builder callbacks:

    1. SQL (com.ibm.websphere.query.callbacks.SqlSelectQueryCallback)

      Although the generic SQL callback can be used for most SQL databases, there are minor differences in SQL syntax and availability of functions which require specific subclasses for some databases.

    2. DB2 (com.ibm.websphere.query.callbacks.DB2SqlSelectQueryCallback)
    3. DB2 on z/OS (com.ibm.websphere.query.callbacks.DB2390SqlSelectQueryCallback)
    4. DB2 on iSeries (com.ibm.websphere.query.callbacks.DB2400SqlSelectQueryCallback)
    5. Cloudscape (com.ibm.websphere.query.callbacks.CloudscapeSqlSelectQueryCallback)
    6. Oracle (com.ibm.websphere.query.callbacks.OracleSelectQueryCallback)
    7. DB2 Content Manager (com.ibm.websphere.query.callbacks.CmQueryCallback)

      The DB2 Content Manager callback can be used to form XPATH queries for the DB2 Content Manager included with WebSphere Portal.

    8. LDAP (com.ibm.websphere.query.callbacks.LdapSelectQueryCallback)

      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.

    9. EIP (com.ibm.websphere.query.callbacks.EipSelectQueryCallback) (deprecated)

      The EIP callback supports EIP 7.1

    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.

  3. 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


Home |

 

WebSphere is a trademark of the IBM Corporation in the United States, other countries, or both.

 

IBM is a trademark of the IBM Corporation in the United States, other countries, or both.