org.cofax
Class SqlDataStore

java.lang.Object
  |
  +--org.cofax.DataStore
        |
        +--org.cofax.SqlDataStore

public class SqlDataStore
extends DataStore

Provides SQL database connectivity for Cofax. A subclass of DataStore. SqlDataStore uses an SQL compatible database as the data store for Cofax. SqlDataStore itself is flexible since it is not tied to a given table or field naming structure other then it's packageTag lookup table. tblPackageTags must contain the fields tag_name and tag_value for packageTag lookups. To add a new packageTag to the system simply add a row to this table. There should be no mention of the SqlDataStore in any client code.

Version:
1.5
Author:
Rajiv Pant, Karl Martino, Sam Cohen

Field Summary
static java.util.HashMap clobColumns
          Hashmap into a determination of if stored procedures contain clobs is placed to speed transactions.
static java.util.HashMap dbPackageTags
          Hashmap into which package tags may be placed into memory upon initialization.
static java.util.HashMap dbPackageTagsCache
          Hashmap into which package tag results are cached.
static java.util.HashMap dbPackageTagsCacheCommand
          Hashmap into which the cache results parameter (1,0) is thrown upon initialization.
 
Fields inherited from class org.cofax.DataStore
CLOB_COLUMNS, dataLog, dataLogLocation, dataLogMaxSize, PACKAGE_TAG_CACHE, PACKAGE_TAG_CACHE_COMMAND, PACKAGE_TAG_PROCESSED, PACKAGE_TAG_RESULTS
 
Constructor Summary
SqlDataStore()
          Initializes variables.
 
Method Summary
static java.util.HashMap checkInstance(java.lang.String tag, java.lang.String key)
           
 void clearCache(int whichCache)
          Clears the cache indicated with whichCache
 boolean connect(java.lang.String dbPool)
          Connects to the database using a connection established in the database poo
 boolean connectFromPool()
          Connects to the database using a connection established in the database poo
 void destroy()
          To be ran once after using the data store.
 boolean disConnect(java.lang.String dataStoreName)
          Free's a connection from the database pool.
static java.lang.String fillToolsTag(java.util.HashMap ht, java.lang.String tag)
          Populates A SQL String with query values from a HashMap when String is formatted as: select req:value from etc.
 java.lang.Object getCacheValue(java.lang.Object key, int whichCache)
          Gets a single value from a cache object
 java.util.List getPackageData(java.util.HashMap data, java.lang.String tagName, java.lang.String tagData, boolean init)
          Returns a set of content by tag for stored procedures, inserts, updates, or selects.
 java.util.List getPackageData(java.lang.String tag, java.lang.String tagStatement)
          Returns a set of content by tag.
 java.lang.String getPackageTag(java.lang.String tag, java.util.HashMap params)
          Gets the sql string that is used for the packageTag request and parses it with it's parameters.
 void init(java.util.Properties dbProps)
          To be ran once before using the data store.
 void init(java.lang.String configFile)
          Initializes the connection pool.
 void initPool()
          To be ran once before using the data store.
 boolean insertArticle(java.util.HashMap article, java.lang.String approvedBy, java.lang.String xmlFileType, java.util.ArrayList mappings, java.util.ArrayList relatedLinks)
          Purpose: The main insertArticle routine.
 void setCache(java.lang.Object cache, int whichCache)
          Set's this data store's cache object and caches all package tags.
 
Methods inherited from class org.cofax.DataStore
getError, getLastError, setError, setLastError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clobColumns

public static java.util.HashMap clobColumns
Hashmap into a determination of if stored procedures contain clobs is placed to speed transactions.

dbPackageTagsCacheCommand

public static java.util.HashMap dbPackageTagsCacheCommand
Hashmap into which the cache results parameter (1,0) is thrown upon initialization.

dbPackageTags

public static java.util.HashMap dbPackageTags
Hashmap into which package tags may be placed into memory upon initialization.

dbPackageTagsCache

public static java.util.HashMap dbPackageTagsCache
Hashmap into which package tag results are cached.
Constructor Detail

SqlDataStore

public SqlDataStore()
Initializes variables.
Method Detail

init

public void init(java.lang.String configFile)
Initializes the connection pool.
Overrides:
init in class DataStore

init

public void init(java.util.Properties dbProps)
To be ran once before using the data store. With a pre-loaded Properties object.
Overrides:
init in class DataStore

setCache

public void setCache(java.lang.Object cache,
                     int whichCache)
Set's this data store's cache object and caches all package tags.
Overrides:
setCache in class DataStore

clearCache

public void clearCache(int whichCache)
Description copied from class: DataStore
Clears the cache indicated with whichCache
Overrides:
clearCache in class DataStore

getCacheValue

public java.lang.Object getCacheValue(java.lang.Object key,
                                      int whichCache)
Description copied from class: DataStore
Gets a single value from a cache object
Overrides:
getCacheValue in class DataStore

connect

public final boolean connect(java.lang.String dbPool)
Connects to the database using a connection established in the database poo
Overrides:
connect in class DataStore

initPool

public void initPool()
Description copied from class: DataStore
To be ran once before using the data store. With a pre-loaded Properties object.
Overrides:
initPool in class DataStore

connectFromPool

public final boolean connectFromPool()
Connects to the database using a connection established in the database poo
Overrides:
connectFromPool in class DataStore

getPackageTag

public final java.lang.String getPackageTag(java.lang.String tag,
                                            java.util.HashMap params)
Gets the sql string that is used for the packageTag request and parses it with it's parameters.
Overrides:
getPackageTag in class DataStore
Following copied from class: org.cofax.DataStore
Parameters:
tag - The tag name. The Data Store must have a lookup table of names and definitions. the command.

getPackageData

public final java.util.List getPackageData(java.lang.String tag,
                                           java.lang.String tagStatement)
Returns a set of content by tag. Prefixes returned names of values with the tag name.
Overrides:
getPackageData in class DataStore

getPackageData

public final java.util.List getPackageData(java.util.HashMap data,
                                           java.lang.String tagName,
                                           java.lang.String tagData,
                                           boolean init)
Returns a set of content by tag for stored procedures, inserts, updates, or selects. Handles clobs both on the way in and the way out.
Overrides:
getPackageData in class DataStore

disConnect

public final boolean disConnect(java.lang.String dataStoreName)
Free's a connection from the database pool.
Overrides:
disConnect in class DataStore

destroy

public void destroy()
Description copied from class: DataStore
To be ran once after using the data store. Do clean up here.
Overrides:
destroy in class DataStore

insertArticle

public final boolean insertArticle(java.util.HashMap article,
                                   java.lang.String approvedBy,
                                   java.lang.String xmlFileType,
                                   java.util.ArrayList mappings,
                                   java.util.ArrayList relatedLinks)
Purpose: The main insertArticle routine.
Overrides:
insertArticle in class DataStore

fillToolsTag

public static java.lang.String fillToolsTag(java.util.HashMap ht,
                                            java.lang.String tag)
Populates A SQL String with query values from a HashMap when String is formatted as: select req:value from etc. Duplex method exists for package tags that have fulfillable values.

checkInstance

public static java.util.HashMap checkInstance(java.lang.String tag,
                                              java.lang.String key)


Copyright 2001 KnightRidder.com. All Rights Reserved.