org.cofax
Class DataStore

java.lang.Object
  |
  +--org.cofax.DataStore
Direct Known Subclasses:
DummyDataStore, OracleDataStore, SqlDataStore

public abstract class DataStore
extends java.lang.Object

Cofax's top level data store class. Cofax compatible handlers for data store implement this API. One example of such a handler is SqlDataStore. It uses an SQL compatible database as the data store for Cofax. SqlDataStore is flexible since it is not tied to a given table or field naming structure. Other data stores classes like OdiDataStore can be used to allow Cofax to use an ODI object database as the data store. Other data stores like XMLDataStore can be used for PersonalCofax to power small sites for those who do not wish to use an SQL database. Future data stores can be used for distributed content and storage over the internet. For example, a company that owns several newspapers can use a DistributedDataStore along with a DistributedDataCache to serve multiple newspapers from remote locations. DataStore classes are listed in the configuration and loaded dynamically.

Author:
Rajiv Pant, Karl Martino

Field Summary
static int CLOB_COLUMNS
           
static java.lang.String dataLog
          whether to print logs or not
static java.lang.String dataLogLocation
          whether to print logs to a file location (named) or System.out(empty)
static long dataLogMaxSize
          Max size (in bits) of the log
static int PACKAGE_TAG_CACHE
           
static int PACKAGE_TAG_CACHE_COMMAND
           
static int PACKAGE_TAG_PROCESSED
           
static int PACKAGE_TAG_RESULTS
           
 
Constructor Summary
DataStore()
           
 
Method Summary
abstract  void clearCache(int whichCache)
          Clears the cache indicated with whichCache
abstract  boolean connect(java.lang.String dataStoreName)
          Establishes a connection to the datastore.
abstract  boolean connectFromPool()
          Establishes a connection to the datastore.
abstract  void destroy()
          To be ran once after using the data store.
abstract  boolean disConnect(java.lang.String dataStoreName)
          Disconnects from the data store.
abstract  java.lang.Object getCacheValue(java.lang.Object key, int whichCache)
          Gets a single value from a cache object
 boolean getError()
          Gets the error set with setError()
 java.lang.String getLastError()
          Returns the last error recorded.
abstract  java.util.List getPackageData(java.util.HashMap data, java.lang.String tagName, java.lang.String tagData, boolean init)
          Overload for getPackageData that handles tag data and clobs additionally.
abstract  java.util.List getPackageData(java.lang.String tag, java.lang.String tagStatement)
          Executes the tag definition and prefixes the name of returned values with the tag name.
abstract  java.lang.String getPackageTag(java.lang.String tag, java.util.HashMap params)
          Looks up the package tag definition and does variable substitution with the params HashMap.
abstract  void init(java.util.Properties dbProps)
          To be ran once before using the data store.
abstract  void init(java.lang.String configFile)
          To be ran once before using the data store.
abstract  void initPool()
          To be ran once before using the data store.
abstract  boolean insertArticle(java.util.HashMap article, java.lang.String approvedBy, java.lang.String xmlFileType, java.util.ArrayList mappings, java.util.ArrayList relatedLinks)
          Inserts an article to the datastore.
abstract  void setCache(java.lang.Object cache, int whichCache)
          Set's the cache indicated with whichCache
protected  void setError(boolean error)
          Sets the error message to be returned to the caller
 void setLastError(java.lang.String lastError)
          Sets an error message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKAGE_TAG_CACHE

public static final int PACKAGE_TAG_CACHE

PACKAGE_TAG_PROCESSED

public static final int PACKAGE_TAG_PROCESSED

PACKAGE_TAG_RESULTS

public static final int PACKAGE_TAG_RESULTS

CLOB_COLUMNS

public static final int CLOB_COLUMNS

PACKAGE_TAG_CACHE_COMMAND

public static final int PACKAGE_TAG_CACHE_COMMAND

dataLog

public static java.lang.String dataLog
whether to print logs or not

dataLogLocation

public static java.lang.String dataLogLocation
whether to print logs to a file location (named) or System.out(empty)

dataLogMaxSize

public static long dataLogMaxSize
Max size (in bits) of the log
Constructor Detail

DataStore

public DataStore()
Method Detail

init

public abstract void init(java.lang.String configFile)
To be ran once before using the data store. With a config file.

init

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

initPool

public abstract void initPool()
To be ran once before using the data store. With a pre-loaded Properties object.

setCache

public abstract void setCache(java.lang.Object cache,
                              int whichCache)
Set's the cache indicated with whichCache

clearCache

public abstract void clearCache(int whichCache)
Clears the cache indicated with whichCache

getCacheValue

public abstract java.lang.Object getCacheValue(java.lang.Object key,
                                               int whichCache)
Gets a single value from a cache object

setError

protected void setError(boolean error)
Sets the error message to be returned to the caller

getError

public boolean getError()
Gets the error set with setError()

destroy

public abstract void destroy()
To be ran once after using the data store. Do clean up here.

getLastError

public java.lang.String getLastError()
Returns the last error recorded.

setLastError

public void setLastError(java.lang.String lastError)
Sets an error message.

connect

public abstract boolean connect(java.lang.String dataStoreName)
Establishes a connection to the datastore.

connectFromPool

public abstract boolean connectFromPool()
Establishes a connection to the datastore.

getPackageTag

public abstract java.lang.String getPackageTag(java.lang.String tag,
                                               java.util.HashMap params)
Looks up the package tag definition and does variable substitution with the params HashMap.
Parameters:
tag - The tag name. The Data Store must have a lookup table of names and definitions. the command.

getPackageData

public abstract java.util.List getPackageData(java.lang.String tag,
                                              java.lang.String tagStatement)
Executes the tag definition and prefixes the name of returned values with the tag name. Requires getting a tagStatement with getPackageTag()

getPackageData

public abstract java.util.List getPackageData(java.util.HashMap data,
                                              java.lang.String tagName,
                                              java.lang.String tagData,
                                              boolean init)
Overload for getPackageData that handles tag data and clobs additionally.

disConnect

public abstract boolean disConnect(java.lang.String dataStoreName)
Disconnects from the data store.

insertArticle

public abstract boolean insertArticle(java.util.HashMap article,
                                      java.lang.String approvedBy,
                                      java.lang.String xmlFileType,
                                      java.util.ArrayList mappings,
                                      java.util.ArrayList relatedLinks)
Inserts an article to the datastore. TO DO: KILL ME PLEASE!!!


Copyright 2001 KnightRidder.com. All Rights Reserved.