com.ibm.di.connector
Class PESConnector

java.lang.Object
  extended by com.ibm.di.connector.Connector
      extended by com.ibm.di.connector.PESConnector
All Implemented Interfaces:
ConnectorInterface, VersionInfoInterface

public class PESConnector
extends Connector
implements ConnectorInterface

The PES Connector provides access to the underlying System Store. The primary use of the System Store Connector/PES Connector is to store Entry objects into the System Store tables.


Field Summary
static String DELTA_PREFIX
          Delta store table prefix
static String PS_PREFIX
          Property store table prefix
static int READ_ALL
          specifies read all selection mode
static int READ_DELETED
          specifies read deleted selection mode
static int READ_EXISTING
          specifies read existing selection mode
 
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
 
Constructor Summary
PESConnector()
          Constructor
 
Method Summary
 boolean chkforDML(String table)
          Check whether DML operations are allowed on the specified table.
 void commit()
          Commit the last transactions
 void deleteEntry(Entry entry, SearchCriteria search)
          Deletes an existing entry.
 void dropPesTable(String table)
          Drop table of given name.
 Entry findEntry(SearchCriteria search)
          Finds an existing entry.
 Entry findEntryWithFlag(SearchCriteria search, boolean returnWrappedEntry)
          Wrapped functionality for backward compatibility.
 String getAttrName(Entry entry)
          Returns Attr name if not keyAttribute
 String getCreateTable(String driver)
           
 Entry getNextEntry()
          Returns the next entry from the result set created by selectEntries
 String getUniqueKey(Entry e, Vector<String> keys)
          Generate unique key from list of key Attributes
 String getVersion()
          Return version information
 String getWhereClause(SearchCriteria search, boolean ps)
          Creates where clause for SQL statement
 void initialize(Object p1)
          Method initializes the connector
 boolean isEOCFlag()
          Is end of cycle reached
 void modEntry(Entry entry, SearchCriteria search)
          Modifies an existing entry.
 void modEntry(Entry entry, SearchCriteria search, Entry old)
          Modify the entry in the System Store.
 void putEntry(Entry entry)
          Adds a new entry.
 Object querySchema(Object table)
          This function translates to whatever means a connector has to discover schema for a connection.
 Vector<String> queryTables()
          Method returns list of table names
 void rollback()
          Rollback the last transactions since the last commit
 void saveMetaData(ResultSetMetaData md)
          Saves the Meta Data info
 void selectEntries()
          Prepares for getNextEntry().
 boolean setCommitMode(String mode)
          Set the commit behavior of this PES Connector.
 void setEOCFlag(boolean flag)
          Sets the value for EOC reached
 void setResultSet(ResultSet rs)
          Instructs this connector to use the provided result set instead of its own.
 void setSelectionMode(int mode)
          Set selection mode
 void terminate()
          Terminate the connector.
 
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextClient, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, getUI, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logError, logmsg, pushback, queryOperations, queryReply, reconnect, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setDebugMode, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface, terminateServer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextClient, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, pushback, queryOperations, queryReply, reconnect, registerScriptBeans, replyEntry, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface, terminateServer
 

Field Detail

READ_EXISTING

public static final int READ_EXISTING
specifies read existing selection mode

See Also:
Constant Field Values

READ_ALL

public static final int READ_ALL
specifies read all selection mode

See Also:
Constant Field Values

READ_DELETED

public static final int READ_DELETED
specifies read deleted selection mode

See Also:
Constant Field Values

DELTA_PREFIX

public static final String DELTA_PREFIX
Delta store table prefix

See Also:
Constant Field Values

PS_PREFIX

public static final String PS_PREFIX
Property store table prefix

See Also:
Constant Field Values
Constructor Detail

PESConnector

public PESConnector()
Constructor

Method Detail

initialize

public void initialize(Object p1)
                throws Exception
Method initializes the connector

Specified by:
initialize in interface ConnectorInterface
Overrides:
initialize in class Connector
Parameters:
p1 - Entry object
Throws:
Exception - Thrown if error occurs during initialization

terminate

public void terminate()
Terminate the connector. This function closes all connection and releases all resources used by the connector.

Specified by:
terminate in interface ConnectorInterface
Overrides:
terminate in class Connector

dropPesTable

public void dropPesTable(String table)
Drop table of given name. Note: This method does not work for Delta and Property Store tables.

Parameters:
table - Table Name

setSelectionMode

public void setSelectionMode(int mode)
Set selection mode

Parameters:
mode - mode to be set

chkforDML

public boolean chkforDML(String table)
Check whether DML operations are allowed on the specified table.

Parameters:
table - Table Name
Returns:
true; if the table is not a Delta, Property store or the Systable

getUniqueKey

public String getUniqueKey(Entry e,
                           Vector<String> keys)
Generate unique key from list of key Attributes

Parameters:
e - Entry object
keys - List of keys
Returns:
uniqueKey from list of keys

getAttrName

public String getAttrName(Entry entry)
Returns Attr name if not keyAttribute

Parameters:
entry - Entry object
Returns:
Returns a String object representing the name of the first non-key Attribute in the supplied Entry. The key Attribute is specified by the "keyAttribute" Connector configuration parameter. If there are no non-key Attributes present in the supplied Entry, then the String "ENTRY" is returned.

putEntry

public void putEntry(Entry entry)
              throws Exception
Adds a new entry.

Specified by:
putEntry in interface ConnectorInterface
Overrides:
putEntry in class Connector
Parameters:
entry - The entry object
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

modEntry

public void modEntry(Entry entry,
                     SearchCriteria search,
                     Entry old)
              throws Exception
Modify the entry in the System Store. The supplied entry should contain a the Attribute(s) which are modified. The old entry object has the attributes which are persisted in the System Store

Specified by:
modEntry in interface ConnectorInterface
Overrides:
modEntry in class Connector
Parameters:
entry - An Entry containing the new values to be set in the System Store.
search - Search Criteria used for updating the specific record in the System Store.
old - The old values persisted in the System Store.
Throws:
Exception - If no distinguished record is found in the System Store.

modEntry

public void modEntry(Entry entry,
                     SearchCriteria search)
              throws Exception
Modifies an existing entry. The new entry data is given by the entry parameter and the search criteria specifies which entry to modify.

Specified by:
modEntry in interface ConnectorInterface
Overrides:
modEntry in class Connector
Parameters:
entry - The entry data
search - The search criteria used to locate the entry to be modified
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

findEntry

public Entry findEntry(SearchCriteria search)
                throws Exception
Finds an existing entry. The search criteria specifies which entry to modify.

Specified by:
findEntry in interface ConnectorInterface
Overrides:
findEntry in class Connector
Parameters:
search - The search criteria used to locate the entry to be modified *
Returns:
Entry obj
Throws:
Exception - derived from the connector's underlying classes

findEntryWithFlag

public Entry findEntryWithFlag(SearchCriteria search,
                               boolean returnWrappedEntry)
                        throws Exception
Wrapped functionality for backward compatibility. See method findEntry( ) and determineIfReturnWrappedEntry().Call this method with returnWrappedEntry to "true", and this method will be findEntry( ) equivalent of TDI6.0 and prior. In TDI61, we wanted an unwrapped Entry, therefore the findEntry( ) method calls this with returnWrappedEntry set to "false".

Parameters:
search - search criteria
returnWrappedEntry - type of the returned entry
Returns:
Entry Entry object
Throws:
Exception - if an error occurs

deleteEntry

public void deleteEntry(Entry entry,
                        SearchCriteria search)
                 throws Exception
Deletes an existing entry. The search criteria specifies which entry to modify.

Specified by:
deleteEntry in interface ConnectorInterface
Overrides:
deleteEntry in class Connector
Parameters:
entry - The entry data
search - The search criteria used to locate the entry to be modified
Throws:
Exception - derived from the connector's underlying classes

selectEntries

public void selectEntries()
                   throws Exception
Prepares for getNextEntry(). If no SQL stament is specified use "SELECT * FROM " + getParam("dbTableName") as default

Specified by:
selectEntries in interface ConnectorInterface
Overrides:
selectEntries in class Connector
Throws:
Exception - Any exceptions thrown by the connector's underlying classes
See Also:
getNextEntry()

getNextEntry

public Entry getNextEntry()
                   throws Exception
Returns the next entry from the result set created by selectEntries

Specified by:
getNextEntry in interface ConnectorInterface
Overrides:
getNextEntry in class Connector
Returns:
The nextEntry value
Throws:
Exception - Exception thrown during database operations
See Also:
ConnectorInterface.selectEntries()

getWhereClause

public String getWhereClause(SearchCriteria search,
                             boolean ps)
                      throws Exception
Creates where clause for SQL statement

Parameters:
search - SearchCriteria
ps - Boolean which determines if is a prepared statement.
Returns:
sql SQL string with generated where clause
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

saveMetaData

public void saveMetaData(ResultSetMetaData md)
                  throws SQLException
Saves the Meta Data info

Parameters:
md - ResultSetMetaData
Throws:
SQLException - Any exceptions thrown by the connector's underlying classes

querySchema

public Object querySchema(Object table)
                   throws Exception
This function translates to whatever means a connector has to discover schema for a connection. The connector may implement this, in which case a Vector of Entry objects is returned for each column/attribute it discovered. For a database connector this would typically be column names and their attributes.

Each Entry in the Vector returned should contain the following attributes:

Name Value
name The name of the column/attribute/field ....
syntax The syntax or expected value type
size If specified this will give the user a hint as to how long the field may be

Specified by:
querySchema in interface ConnectorInterface
Overrides:
querySchema in class Connector
Parameters:
table - The object on which to discover schema. This may be an Entry or a string value
Returns:
A Vector of com.ibm.di.entry.Entry objects describing each entity
Throws:
Exception - if an error while retrieving the schema occurs.
See Also:
Entry, Vector

setResultSet

public void setResultSet(ResultSet rs)
                  throws Exception
Instructs this connector to use the provided result set instead of its own.

Parameters:
rs - The new resultSet value
Throws:
Exception - Any exceptions thrown by the connector's underlying classes

commit

public void commit()
            throws SQLException
Commit the last transactions

Throws:
SQLException - Any exceptions thrown by the connector's underlying classes

rollback

public void rollback()
              throws SQLException
Rollback the last transactions since the last commit

Throws:
SQLException - Thrown if an error occurs
See Also:
commit(), setCommitMode(java.lang.String)

setCommitMode

public boolean setCommitMode(String mode)
Set the commit behavior of this PES Connector.

Parameters:
mode - The intended behavior. Possible values are:
  • "After every database operation"
  • "On Connector close"
  • "Manual"
Returns:
false if the requested mode is not a legal value
See Also:
commit()

getCreateTable

public String getCreateTable(String driver)
Parameters:
driver - java class name of the JDBC driver
Returns:
the configured createTable or proper 'CREATE TABLE' statement if the specified driver is known

queryTables

public Vector<String> queryTables()
                           throws Exception
Method returns list of table names

Overrides:
queryTables in class Connector
Returns:
List of tables
Throws:
Exception - Any exceptions thrown by the connector's underlying classes
See Also:
Vector

getVersion

public String getVersion()
Return version information

Specified by:
getVersion in interface VersionInfoInterface
Returns:
version info

isEOCFlag

public boolean isEOCFlag()
Is end of cycle reached

Returns:
true if EOC is reached

setEOCFlag

public void setEOCFlag(boolean flag)
Sets the value for EOC reached

Parameters:
flag - true , if EOC is reached, false otherwise