Enterprise Information Portal APIs

com.ibm.mm.sdk.server
Class DKDatastoreIC

java.lang.Object
  |
  +--com.ibm.mm.sdk.server.dkAbstractDatastore
        |
        +--com.ibm.mm.sdk.server.DKDatastoreIC
All Implemented Interfaces:
DKConstant, DKConstantIC, dkDatastore, dkDatastoreIntIC, DKMessageId, DKMessageIdIC, dkQueryEvaluator, dkQueryManager

public class DKDatastoreIC
extends dkAbstractDatastore
implements dkDatastoreIntIC, DKConstantIC, DKMessageIdIC

The DKDatastoreIC class is the IC implementation of the abstract class dkDatastore. The datastore provides facilities to query and retrieve data from the DataGuide tables

See Also:
change history -------------------------------------- 2002-01-29 huicao change listDataSources()--don't use *.ini file, but access db2Datastore.listDataSources()

Fields inherited from interface com.ibm.mm.sdk.common.DKConstantIC
DK_CM_PARM_LINKS, DK_IC_DSTYPE
 
Fields inherited from interface com.ibm.mm.sdk.common.DKConstant
    For details, see the class or interface
 
Fields inherited from interface com.ibm.mm.sdk.common.DKMessageIdIC
DK_IC_MSG_MSGID_NOT_FOUND
 
Fields inherited from interface com.ibm.mm.sdk.common.DKMessageId
    For details, see the class or interface
 
Constructor Summary
DKDatastoreIC()
           
DKDatastoreIC(java.lang.String configuration)
          Constructs the datastore and initializes the datastore.
 
Method Summary
 void addExtension(java.lang.String extensionName, dkExtension extensionObj)
          Adds a new extension object.
 void connect(java.lang.String datastore_name, java.lang.String user_name, java.lang.String authentication, java.lang.String connect_string)
          Connects to a datastore.
 DKHandle connection()
          Gets the connection handle for a datastore
 DKDDO createDDO(java.lang.String objectType, int flags)
          Creates a new DDO with object type, properties and attributes set for a given backend server.
 dkQuery createQuery(java.lang.String command, short commandLangType, DKNVPair[] params)
          Creates a query object from a query command.
 dkDatastoreDef datastoreDef()
          Get datastore definition
 java.lang.String datastoreName()
          Returns the name of the datastore
 java.lang.String datastoreType()
          Returns the type of the datastore
 java.lang.String db2AttrToIC(java.lang.String schema, java.lang.String table, java.lang.String column)
          Transforms a DB2 column name into a IC attribute name
 DKDDO db2ToICDDO(DKDDO db2DDO, DKQExpr qe)
          Converts a DB2 DDO into the appropriate IC DDO format.
 void disconnect()
          Disconnects to a datastore.
 java.lang.Object evaluate(DKCQExpr qe)
          Evaluates the query and returns a collection of all objects returned.
 java.lang.Object evaluate(dkQuery query)
          Evaluates the query and returns a collection of all objects returned.
 java.lang.Object evaluate(java.lang.String command, short commandLangType, DKNVPair[] params)
          Evaluates the query and returns a collection of all objects returned.
 dkResultSetCursor execute(DKCQExpr cqe)
          Executes the query and returns a result set cursor to access the data.
 dkResultSetCursor execute(dkQuery query)
          Executes the query and returns a result set cursor to access the data.
 dkResultSetCursor execute(java.lang.String command, short commandLangType, DKNVPair[] params)
          Executes the query and returns a result set cursor to access the data.
 dkResultSetCursor executeDB2(java.lang.String command, short commandLangType, DKNVPair[] params)
          Uses the internal DB2 datastore to execute the command query directly.
 void executeWithCallback(DKCQExpr qe, dkCallback callbackObj)
          execute the query with callback function.
 void executeWithCallback(dkQuery query, dkCallback callbackObj)
          execute the query with callback function.
 void executeWithCallback(java.lang.String command, short commandLangType, DKNVPair[] params, dkCallback callbackObj)
          execute the query with callback function.
 dkExtension getExtension(java.lang.String extensionName)
          Gets the extension object from a given extenstion name.
 dkSchemaMapping getMapping(java.lang.String mappingName)
          Gets a mapping information from this datastore.
 java.lang.Object getOption(int option)
          Gets a datastore option.
 java.lang.String icAttrToDB2(java.lang.String entityName, java.lang.String attrName)
          Transforms an IC attribute identifier into a DB2 column name
 java.lang.String icEntityToDB2(java.lang.String entityName)
          Transforms an IC entity identifier into a DB2 table name
 DKQExpr ICQueryToDB2(DKQExpr dkq)
          Transforms a parametric query to use DB2 identifiers
 boolean isConnected()
          Checks to see if the datastore is connected.
 java.lang.String[] listDataSourceNames()
          List the available datastore source names that can be used to connect with.
 dkCollection listDataSources()
          List the available datastore sources that can be used to connect with.
 dkCollection listEntities()
          Gets a list of entities from persistent datastore
 java.lang.String[] listEntityAttrNames(java.lang.String entityName)
          Gets a list of attribute names for a given entity name.
 dkCollection listEntityAttrs(java.lang.String entityName)
          Gets a list of attributes for a given entity name.
 java.lang.String[] listEntityNames()
          Gets a list of entity names from persistent datastore
 java.lang.String[] listMappingNames()
          Gets the list of the registered mappings from this datastore.
static DKQExpr parseParametricQuery(java.lang.String command)
          Creates a DKQExpr from a parametric query in text form.
 java.lang.String registerMapping(DKNVPair sourceMap)
          Registers a mapping definition to this datastore.
 void retrieveObject(dkDataObject dkdo)
          Retrieves this ddo from this datastore.
 void setDataSourceFile(java.lang.String s)
          Set the name of the data file to load the data source list from.
 void setOption(int option, java.lang.Object value)
          Sets a datastore option.
 void unRegisterMapping(java.lang.String mappingName)
          Unregisters mapping information from this datastore.
 java.lang.String userName()
          Returns the name of the user for the database connection.
 
Methods inherited from class com.ibm.mm.sdk.server.dkAbstractDatastore
addObject, addObject, addObject, addObjects, addObjects, addObjects, changePassword, clearCache, clearCache, commit, createQuery, deleteObject, deleteObject, deleteObject, deleteObjects, deleteObjects, deleteObjects, destroy, evaluate, execute, executeWithCallback, handle, listAvailableServices, listExtensionNames, listSchema, listSchemaAttributes, listSearchableEntities, listSearchableEntityNames, listSearchTemplateNames, listSearchTemplates, listServers, removeExtension, retrieveObject, retrieveObject, retrieveObjects, retrieveObjects, retrieveObjects, rollback, serviceMgr, startTransaction, updateObject, updateObject, updateObject, updateObjects, updateObjects, updateObjects
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.mm.sdk.common.dkDatastore
addObject, addObject, addObject, addObjects, addObjects, addObjects, changePassword, clearCache, clearCache, commit, createQuery, deleteObject, deleteObject, deleteObject, deleteObjects, deleteObjects, deleteObjects, destroy, evaluate, execute, executeWithCallback, handle, listAvailableServices, listExtensionNames, listSchema, listSchemaAttributes, listSearchableEntities, listSearchableEntityNames, listSearchTemplateNames, listSearchTemplates, listServers, removeExtension, retrieveObject, retrieveObject, retrieveObjects, retrieveObjects, retrieveObjects, rollback, serviceMgr, startTransaction, updateObject, updateObject, updateObject, updateObjects, updateObjects, updateObjects
 

Constructor Detail

DKDatastoreIC

public DKDatastoreIC()
              throws DKException,
                     java.lang.Exception

DKDatastoreIC

public DKDatastoreIC(java.lang.String configuration)
              throws DKException,
                     java.lang.Exception
Constructs the datastore and initializes the datastore.
Method Detail

connect

public void connect(java.lang.String datastore_name,
                    java.lang.String user_name,
                    java.lang.String authentication,
                    java.lang.String connect_string)
             throws DKException,
                    java.lang.Exception
Connects to a datastore.
Specified by:
connect in interface dkDatastore
Overrides:
connect in class dkAbstractDatastore
Parameters:
datastore_name - the datastore name used for connection
user_name - the user name used for connection
authentication - the authentication used for connection
connect_string - the connect string used for connection. This is used to provide additional connection options.

connection

public DKHandle connection()
                    throws java.lang.Exception
Gets the connection handle for a datastore
Specified by:
connection in interface dkDatastore
Overrides:
connection in class dkAbstractDatastore
Returns:
connection handle

disconnect

public void disconnect()
                throws DKException,
                       java.lang.Exception
Disconnects to a datastore.
Specified by:
disconnect in interface dkDatastore
Overrides:
disconnect in class dkAbstractDatastore

isConnected

public boolean isConnected()
                    throws DKException,
                           java.lang.Exception
Checks to see if the datastore is connected.
Specified by:
isConnected in interface dkDatastore
Overrides:
isConnected in class dkAbstractDatastore
Returns:
true if connected

userName

public java.lang.String userName()
                          throws DKException,
                                 java.lang.Exception
Returns the name of the user for the database connection.
Specified by:
userName in interface dkDatastore
Overrides:
userName in class dkAbstractDatastore
Returns:
the name of the user used to connect.

datastoreName

public java.lang.String datastoreName()
                               throws DKException,
                                      java.lang.Exception
Returns the name of the datastore
Specified by:
datastoreName in interface dkDatastore
Overrides:
datastoreName in class dkAbstractDatastore
Returns:
the name of the datastore

datastoreType

public java.lang.String datastoreType()
                               throws DKException,
                                      java.lang.Exception
Returns the type of the datastore
Specified by:
datastoreType in interface dkDatastore
Overrides:
datastoreType in class dkAbstractDatastore
Returns:
the type of the datastore

createQuery

public dkQuery createQuery(java.lang.String command,
                           short commandLangType,
                           DKNVPair[] params)
                    throws DKException,
                           java.lang.Exception
Creates a query object from a query command. Currently only query languages of types DK_CM_PARAMETRIC_QL_TYPE and DK_CM_SQL_QL_TYPE are supported. If the query is SQL, identifiers must be DB2 identifiers instead of IC identifiers. A DKSQLQuery object is returned.
Specified by:
createQuery in interface dkDatastore
Overrides:
createQuery in class dkAbstractDatastore
Parameters:
command - a query string
commandLang - a query type
params - additional query option in name/value pair
Returns:
a query object

getOption

public java.lang.Object getOption(int option)
                           throws DKException,
                                  java.lang.Exception
Gets a datastore option.
Specified by:
getOption in interface dkDatastore
Overrides:
getOption in class dkAbstractDatastore
Parameters:
option - the option identifier
Returns:
an option value

setOption

public void setOption(int option,
                      java.lang.Object value)
               throws DKException,
                      java.lang.Exception
Sets a datastore option.
Specified by:
setOption in interface dkDatastore
Overrides:
setOption in class dkAbstractDatastore
Parameters:
option - the option identifier
value - the option value

evaluate

public java.lang.Object evaluate(java.lang.String command,
                                 short commandLangType,
                                 DKNVPair[] params)
                          throws DKException,
                                 java.lang.Exception
Evaluates the query and returns a collection of all objects returned.
Specified by:
evaluate in interface dkDatastore
Overrides:
evaluate in class dkAbstractDatastore
Parameters:
command - a query string
commandLang - a query type
params - additional query option in name/value pair
Returns:
a collection of the results
See Also:
execute( String, short, DKNVPair[] )

evaluate

public java.lang.Object evaluate(dkQuery query)
                          throws DKException,
                                 java.lang.Exception
Evaluates the query and returns a collection of all objects returned.
Specified by:
evaluate in interface dkDatastore
Overrides:
evaluate in class dkAbstractDatastore
Parameters:
query - a query object
Returns:
a collection of the results
See Also:
execute( dkQuery )

evaluate

public java.lang.Object evaluate(DKCQExpr qe)
                          throws DKException,
                                 java.lang.Exception
Evaluates the query and returns a collection of all objects returned.
Specified by:
evaluate in interface dkDatastore
Overrides:
evaluate in class dkAbstractDatastore
Parameters:
qe - a common query expression object
Returns:
a collection of the results
See Also:
execute( DKCQExpr )

execute

public dkResultSetCursor execute(java.lang.String command,
                                 short commandLangType,
                                 DKNVPair[] params)
                          throws DKException,
                                 java.lang.Exception
Executes the query and returns a result set cursor to access the data. Currently only query languages of types DK_CM_PARAMETRIC_QL_TYPE and DK_CM_SQL_QL_TYPE are supported. If the query is SQL, identifiers must be DB2 identifiers instead of IC identifiers.
Specified by:
execute in interface dkDatastore
Overrides:
execute in class dkAbstractDatastore
Parameters:
command - a query string
commandLang - a query type
params - additional query option in name/value pair
Returns:
a result set cursor which represents a datastore cursor.

executeDB2

public dkResultSetCursor executeDB2(java.lang.String command,
                                    short commandLangType,
                                    DKNVPair[] params)
                             throws DKException,
                                    java.lang.Exception
Uses the internal DB2 datastore to execute the command query directly. Only DK_CM_SQL_QL_TYPE commands can be processed with this method. This method is for internal use.
Specified by:
executeDB2 in interface dkDatastoreIntIC
Parameters:
command - a query string
commandLang - a query type
params - additional query option in name/value pair
Returns:
a DB2 result set cursor which represents a datastore cursor.

execute

public dkResultSetCursor execute(dkQuery query)
                          throws DKException,
                                 java.lang.Exception
Executes the query and returns a result set cursor to access the data.
Specified by:
execute in interface dkDatastore
Overrides:
execute in class dkAbstractDatastore
Parameters:
query - a query object
Returns:
a result set cursor which represents a datastore cursor.

execute

public dkResultSetCursor execute(DKCQExpr cqe)
                          throws DKException,
                                 java.lang.Exception
Executes the query and returns a result set cursor to access the data.
Specified by:
execute in interface dkDatastore
Overrides:
execute in class dkAbstractDatastore
Parameters:
cqe - a common query expression object
Returns:
a result set cursor which represents a datastore cursor.

executeWithCallback

public void executeWithCallback(java.lang.String command,
                                short commandLangType,
                                DKNVPair[] params,
                                dkCallback callbackObj)
                         throws DKException,
                                java.lang.Exception
execute the query with callback function.
Specified by:
executeWithCallback in interface dkDatastore
Overrides:
executeWithCallback in class dkAbstractDatastore
Parameters:
command - a query string
commandLang - a query type
params - additional query option in name/value pair
callbackObj - a dkCallback object

executeWithCallback

public void executeWithCallback(dkQuery query,
                                dkCallback callbackObj)
                         throws DKException,
                                java.lang.Exception
execute the query with callback function.
Specified by:
executeWithCallback in interface dkDatastore
Overrides:
executeWithCallback in class dkAbstractDatastore
Parameters:
query - a query object
callbackObj - a dkCallback object

executeWithCallback

public void executeWithCallback(DKCQExpr qe,
                                dkCallback callbackObj)
                         throws DKException,
                                java.lang.Exception
execute the query with callback function.
Specified by:
executeWithCallback in interface dkDatastore
Overrides:
executeWithCallback in class dkAbstractDatastore
Parameters:
qe - a common query expression object
callbackObj - a dkCallback object

retrieveObject

public void retrieveObject(dkDataObject dkdo)
                    throws DKException,
                           java.lang.Exception
Retrieves this ddo from this datastore.
Specified by:
retrieveObject in interface dkDatastore
Overrides:
retrieveObject in class dkAbstractDatastore
Parameters:
ddo - the ddo to be retrieved from this datastore

db2AttrToIC

public java.lang.String db2AttrToIC(java.lang.String schema,
                                    java.lang.String table,
                                    java.lang.String column)
                             throws DKException,
                                    java.lang.Exception
Transforms a DB2 column name into a IC attribute name
Parameters:
schema - the DB2 schema, or IC creator, for the object.
table - the DB2 table name that the attribute belongs to
column - the DB2 column name to be converted to a IC attribute name
Returns:
the IC attribute name for the DB2 attribute

icAttrToDB2

public java.lang.String icAttrToDB2(java.lang.String entityName,
                                    java.lang.String attrName)
                             throws DKException,
                                    java.lang.Exception
Transforms an IC attribute identifier into a DB2 column name
Parameters:
entityName - the IC entity name that the attribute belongs to
attrName - the IC attribute name to be converted to a DB2 column name
Returns:
the DB2 column name for the provided Entity + Attribute pair

icEntityToDB2

public java.lang.String icEntityToDB2(java.lang.String entityName)
                               throws DKException,
                                      java.lang.Exception
Transforms an IC entity identifier into a DB2 table name
Parameters:
entityName - the IC entity name to be mapped to a DB2 table name
Returns:
the DB2 table name for the provided entity

db2ToICDDO

public DKDDO db2ToICDDO(DKDDO db2DDO,
                        DKQExpr qe)
                 throws DKException,
                        java.lang.Exception
Converts a DB2 DDO into the appropriate IC DDO format. Returns a new DKDDO object.
Parameters:
db2DDO - The DB2 DDO to convert
Returns:
a new IC DDO representing the data from the DB2 DDO.

datastoreDef

public dkDatastoreDef datastoreDef()
Get datastore definition
Specified by:
datastoreDef in interface dkDatastore
Overrides:
datastoreDef in class dkAbstractDatastore
Returns:
the meta-data (dkDatastoreDef) of this datastore

listEntities

public dkCollection listEntities()
                          throws DKException,
                                 java.lang.Exception
Gets a list of entities from persistent datastore
Specified by:
listEntities in interface dkDatastore
Overrides:
listEntities in class dkAbstractDatastore
Returns:
a collection of entity defs
Throws:
DKException - if error occurs

listEntityNames

public java.lang.String[] listEntityNames()
                                   throws DKException,
                                          java.lang.Exception
Gets a list of entity names from persistent datastore
Specified by:
listEntityNames in interface dkDatastore
Overrides:
listEntityNames in class dkAbstractDatastore
Returns:
an array of entity names
Throws:
DKException - if error occurs

listEntityAttrs

public dkCollection listEntityAttrs(java.lang.String entityName)
                             throws DKException,
                                    java.lang.Exception
Gets a list of attributes for a given entity name.
Specified by:
listEntityAttrs in interface dkDatastore
Overrides:
listEntityAttrs in class dkAbstractDatastore
Parameters:
entityName - name of entity to retrieve attributes for
Returns:
a dkCollection of dkAttrDef objects
Throws:
DKException - if the entity name does not exist

listEntityAttrNames

public java.lang.String[] listEntityAttrNames(java.lang.String entityName)
                                       throws DKException,
                                              java.lang.Exception
Gets a list of attribute names for a given entity name.
Specified by:
listEntityAttrNames in interface dkDatastore
Overrides:
listEntityAttrNames in class dkAbstractDatastore
Parameters:
entityName - name of entity to retrieve attribute names for
Returns:
an array of attribute names
Throws:
DKException - if the entity name does not exist

registerMapping

public java.lang.String registerMapping(DKNVPair sourceMap)
                                 throws DKException,
                                        java.lang.Exception
Registers a mapping definition to this datastore. Mapping is done by entities.
Specified by:
registerMapping in interface dkDatastore
Overrides:
registerMapping in class dkAbstractDatastore
Parameters:
sourceMap - source name and mapping, a DKNVPair class with the following possible values:
  • ("BUFFER", buffer_ref): buffer_ref is a reference to a string in memory
  • ("FILE", file_name): file_name is the name of the file containing the mapping
  • ("URL", url_address): URL-address location of the mapping
  • ("LDAP", LDAP_file): LDAP file-name
  • ("SCHEMA", object_ref): a reference to a dkSchemaMapping object defining the mapping. Currently, only "SCHEMA" option is supported, others may be added later.
    Returns:
    the name of the mapping definition.
    See Also:
    unRegisterMapping(java.lang.String)

unRegisterMapping

public void unRegisterMapping(java.lang.String mappingName)
                       throws DKException,
                              java.lang.Exception
Unregisters mapping information from this datastore.
Specified by:
unRegisterMapping in interface dkDatastore
Overrides:
unRegisterMapping in class dkAbstractDatastore
Parameters:
mappingName - name of the mapping information
See Also:
registerMapping(com.ibm.mm.sdk.common.DKNVPair)

listMappingNames

public java.lang.String[] listMappingNames()
                                    throws DKException,
                                           java.lang.Exception
Gets the list of the registered mappings from this datastore.
Specified by:
listMappingNames in interface dkDatastore
Overrides:
listMappingNames in class dkAbstractDatastore
Returns:
an array of registered mapping objects' names
See Also:
registerMapping(com.ibm.mm.sdk.common.DKNVPair)

getMapping

public dkSchemaMapping getMapping(java.lang.String mappingName)
                           throws DKException,
                                  java.lang.Exception
Gets a mapping information from this datastore.
Specified by:
getMapping in interface dkDatastore
Overrides:
getMapping in class dkAbstractDatastore
Parameters:
mappingName - name of the mapping information
Returns:
the schema mapping object
See Also:
registerMapping(com.ibm.mm.sdk.common.DKNVPair)

getExtension

public dkExtension getExtension(java.lang.String extensionName)
                         throws DKException,
                                java.lang.Exception
Gets the extension object from a given extenstion name.
Specified by:
getExtension in interface dkDatastore
Overrides:
getExtension in class dkAbstractDatastore
Parameters:
extensionName - name of the extension object.
Returns:
extension object.

addExtension

public void addExtension(java.lang.String extensionName,
                         dkExtension extensionObj)
                  throws DKException,
                         java.lang.Exception
Adds a new extension object.
Specified by:
addExtension in interface dkDatastore
Overrides:
addExtension in class dkAbstractDatastore
Parameters:
extensionName - name of new extension object
extensionObj - the extension object to be set

createDDO

public DKDDO createDDO(java.lang.String objectType,
                       int flags)
                throws DKException,
                       java.lang.Exception
Creates a new DDO with object type, properties and attributes set for a given backend server.
Specified by:
createDDO in interface dkDatastore
Overrides:
createDDO in class dkAbstractDatastore
Parameters:
objectType - the name of the IC Object (Entity) to create
flags - to indicate various options to specify more detail characteristics of the DDO to create. For example, it may be a directive to create a document DDO, a folder, etc.
Returns:
a new DDO of the given object type with all the properties and attributes set, so that the user only need to set the attribute values. The attribute values are initialized to null.

ICQueryToDB2

public DKQExpr ICQueryToDB2(DKQExpr dkq)
                     throws DKException,
                            java.lang.Exception
Transforms a parametric query to use DB2 identifiers
Parameters:
dkq - The DKQExpr to be translated to DB2 identifiers.
Returns:
a parametric query where the IC identifiers have been replaced with DB2 table and column names.

setDataSourceFile

public void setDataSourceFile(java.lang.String s)
Set the name of the data file to load the data source list from.
Parameters:
s - a String containing the name of the file.

listDataSources

public dkCollection listDataSources()
                             throws DKException,
                                    java.lang.Exception
List the available datastore sources that can be used to connect with.
Specified by:
listDataSources in interface dkDatastore
Overrides:
listDataSources in class dkAbstractDatastore
Returns:
a collection of server defs

listDataSourceNames

public java.lang.String[] listDataSourceNames()
                                       throws DKException,
                                              java.lang.Exception
List the available datastore source names that can be used to connect with.
Specified by:
listDataSourceNames in interface dkDatastore
Overrides:
listDataSourceNames in class dkAbstractDatastore
Returns:
an array of server names

parseParametricQuery

public static DKQExpr parseParametricQuery(java.lang.String command)
                                    throws DKException,
                                           java.lang.Exception
Creates a DKQExpr from a parametric query in text form.
Parameters:
command - The parametric query string to be parsed.
Returns:
the DKQExpr representation of the parametric query.

EIP Java APIs

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.