Expresso 5-6

com.jcorporate.expresso.services.dbobj
Class Setup

java.lang.Object
  extended bycom.jcorporate.expresso.core.dataobjects.BaseDataObject
      extended bycom.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
          extended bycom.jcorporate.expresso.core.dbobj.DBObject
              extended bycom.jcorporate.expresso.core.dbobj.SecuredDBObject
                  extended bycom.jcorporate.expresso.services.dbobj.Setup
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Securable, Serializable

public class Setup
extends SecuredDBObject

Copyright 1999, 2000, 2001 Jcorporate Ltd.

Setup is a generic configuration/setup value table. Each schema can define a number of default setup values that are created when the schema is initialized. The user can then customize these values.

Author:
Michael Nash
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.jcorporate.expresso.core.dbobj.DBObject
DBObject.FieldError, DBObject.FieldUpdate
 
Field Summary
static String CACHE_NAME
          Name of the setup cache file.
static String SCHEMA_CLASS
           
static String SETUP_CODE
           
static String SETUP_DESCRIP
           
static String SETUP_VALUE
           
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
ADD, ALL_FUNCTIONS, CACHE_TTY, DELETE, SEARCH, SYSTEM_ACCOUNT, SYSTEM_ACCOUNT_NAME, UPDATE
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.DBObject
ATTRIBUTE_ERROR, ATTRIBUTE_ERROR_MESSAGE, ATTRIBUTE_PAGE_LIMIT, BIG_DECIMAL_ZERO, EMAIL_MASK, EVENT_ADD, EVENT_DELETE, EVENT_UPDATE, FLOAT_MASK, INT_MASK, IS_CHECK_RELATIONAL_INTEGRITY, UPDATE_CHANGED_ONLY, WHERE_KEYWORD
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
anyFieldsDistinct, anyFieldsToRetrieve, appendCustomWhere, caseSensitiveQuery, customWhereClause, dbKey, distinctFields, localConnection, LONGBINARY_READ_DEFAULT_SIZE, maxRecords, myClassName, myUpdates, offsetRecord, recordSet, retrieveFields, sMetadataMap, sortKeys
 
Fields inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
currentStatus, globalMask
 
Fields inherited from interface com.jcorporate.expresso.core.dataobjects.DataObject
STATUS_CURRENT, STATUS_DELETED, STATUS_NEW, STATUS_UPDATED
 
Constructor Summary
Setup()
          Constructor
Setup(ControllerRequest request)
          For using DBObjects within Controllers.
Setup(int uid)
          Initializes Setup with proper user context
 
Method Summary
 void add()
          Extend add to call updatepool
 void delete()
          Extend update to call updatepool
 boolean find()
          Just like retrieve, but works with any fields, not just the key field.
static String getValue(String dbName, String setupCode)
          Get a config value for the default schema Config values are like INI file variables or registry entries - except stored in a database.
static String getValue(String dbName, String schemaName, String setupCode)
          Get a config value for the default schema Config values are like INI file variables or registry entries - except stored in a database.
static String getValueRequired(String dbName, String setupCode)
          Get a value from the configuration values.
static String getValueRequired(String dbName, String schema, String setupCode)
          Get a value from the configuration values.
static String getValueUnrequired(String dbName, String setupCode)
          Get a value from the configuration values.
static String getValueUnrequired(String dbName, String schema, String setupCode)
          Get a value from the configuration values.
static void readSetups()
          Read the setup/config values into a hashtable for cached access
static void readSetups(boolean forceRead)
           
 void retrieve()
          Extend retrieve to supply a defeult for the schemaclass field
 void setCode(String code)
          convenience setter for code
 void setDescrip(String descrip)
          convenience setter for description of Setup item
 void setSchemaClass(String schemaclassname)
          convenience setter for schema class; schema is optional; if not provided, find() will default to Expresso
static void setTableExists(String dbName)
          DB Tool calls this when the Expresso Setup Values are finally able to be read
protected  void setupFields()
          Method to set up the fields for this database object.
 void setValue(String value)
          convenience setter for value
 void update()
          Extend update to validate some setup values
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, deleteAll, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, instantiate, isAllowed, search, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.DBObject
addDetail, addField, addField, addFieldError, addFoundKeys, addIfNeeded, addIndex, addKey, addOrUpdate, addSortKey, addTransition, addVirtualField, addVirtualField, addVirtualField, addVirtualField, average, basicAdd, cacheIsChangedComparison, checkAllReferredToBy, checkAllRefs, checkAllRefsPublic, checkDeleteDetailPerm, checkField, checkRef, checkRef, clear, clearDistinctFields, clearError, clearFieldsToRetrieve, clearSortKeys, containsWildCards, delete, deleteAll, deleteDetails, denotesRange, equals, forKey, formatDateTime, get, getAllAttributes, getAttribute, getAttributesIterator, getBooleanFieldValue, getCacheSize, getCacheStatsMap, getCacheUtil, getCheckZeroUpdate, getCustomWhereClause, getDataContext, getDataField, getDataTransferObject, getDBName, getDetails, getDistinctFieldCount, getDistinctFields, getField, getFieldBigDecimal, getFieldBoolean, getFieldByte, getFieldByteArray, getFieldData, getFieldDate, getFieldDecimalFormatted, getFieldDouble, getFieldErrorMessage, getFieldFloat, getFieldInt, getFieldLong, getFieldMetaData, getFieldShort, getFieldsToRetrieveCount, getFilterClass, getFoundCount, getFoundKeysArray, getIndexArray, getISOValuesDefault, getISOValuesDefault, getISOValuesDefault, getKey, getKeyFieldListIterator, getLength, getLengthInt, getLocalConnection, getLocale, getLogger, getLookupObject, getMax, getMax, getMaxRecords, getMyKeys, getMyUpdatesArray, getOffsetRecord, getPatternMatcher, getPrecision, getSerializedForm, getStringFilter, getThisDBbj, getThisDBObj, getValidValueDescrip, getValidValues, getValidValuesList, getValues, getValuesDefault, getValuesDefault, getValuesDefault, hasError, hasErrors, haveAllKeys, initialize, isCached, isChanged, isDistinct, isEmpty, isFieldDistinct, isFieldNull, isFieldsToRetrieve, isFieldToRetrieve, isMultiValued, isReadOnly, isSecret, isVirtual, loadFromConnection, logChange, max, min, newInstance, noNewLine, noQuotes, notifyListeners, populateDefaultValues, referredToBy, removeAttribute, removeFromCache, retrieveFromCache, saveBinaryField, search, set, setAttribute, setCacheSize, setCharset, setCheckZeroUpdate, setConnection, setConnection, setCustomWhereClause, setCustomWhereClause, setDataContext, setDataField, setDataTransferObject, setDefaultValue, setDescription, setField, setField, setField, setField, setField, setField, setField, setField, setField, setField, setFieldData, setFieldData, setFieldDistinct, setFieldsToRetrieve, setFilterClass, setFilterClass, setKeys, setLocale, setLookupField, setLookupObject, setMask, setMaxRecords, setMultiValued, setName, setOffsetRecord, setReadOnly, setSchema, setSecret, setSortKey, setStringFilter, setStringFiltersOnAll, setTargetDbSchema, setTargetTable, sqlAggrFunction, sum, toDebugString, update, updateAll, updateAll, verify
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.jdbc.JDBCDataObject
addInParam, addOutParam, buildWhereClause, buildWhereClauseBuffer, checkZeroUpdate, constructNewMetaData, createAndExecuteSearch, createAndRunStoreProcedure, getConnectionPool, getCustomStringFieldValue, getDef, getDistinctFieldArrayList, getExecutor, getFieldsToRetrieveIterator, getJDBCMetaData, getJDBCUtil, getMappedDataContext, getMetaData, getQueryInterface, getSerialForm, loadFromConnection, makeLimitationStub, quoteIfNeeded, runStoredProcedure, runStoredProcedureAndRetrieveList, selectFieldString, setCaseSensitiveQuery, setDBConnectionPool, setDBName, setMappedDataContext, setOriginalDBName, setTargetStoreProcedure
 
Methods inherited from class com.jcorporate.expresso.core.dataobjects.BaseDataObject
getGlobalMask, getStatus, isGlobalMasked, setFieldsWithDefaults, setGlobalMask, setStatus
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_NAME

public static final String CACHE_NAME
Name of the setup cache file.


SETUP_CODE

public static final String SETUP_CODE
See Also:
Constant Field Values

SETUP_DESCRIP

public static final String SETUP_DESCRIP
See Also:
Constant Field Values

SETUP_VALUE

public static final String SETUP_VALUE
See Also:
Constant Field Values

SCHEMA_CLASS

public static final String SCHEMA_CLASS
See Also:
Constant Field Values
Constructor Detail

Setup

public Setup()
      throws DBException
Constructor

Throws:
DBException - upon error

Setup

public Setup(int uid)
      throws DBException
Initializes Setup with proper user context

Parameters:
uid - the Owning user's uid
Throws:
DBException - upon error

Setup

public Setup(ControllerRequest request)
      throws DBException
For using DBObjects within Controllers. Initializes based upon the current user and the requested db. [Of course this can be modified later]

Parameters:
request - - The controller request handed to you by the framework.
Throws:
DBException - upon error
Method Detail

add

public void add()
         throws DBException
Extend add to call updatepool

Specified by:
add in interface DataObject
Overrides:
add in class SecuredDBObject
Throws:
DBException - upon error

delete

public void delete()
            throws DBException
Extend update to call updatepool

Specified by:
delete in interface DataObject
Overrides:
delete in class SecuredDBObject
Throws:
DBException - upon error

find

public boolean find()
             throws DBException
Description copied from class: SecuredDBObject
Just like retrieve, but works with any fields, not just the key field. Finds only first record matching the criteria

Specified by:
find in interface DataObject
Overrides:
find in class SecuredDBObject
Returns:
boolean true if something was indeed found.
Throws:
DBException - upon error

getValue

public static String getValue(String dbName,
                              String setupCode)
                       throws DBException
Get a config value for the default schema Config values are like INI file variables or registry entries - except stored in a database. There is one database connection held open for accessing these values from the connection pool. This function simply references the Expresso Schema's setup values. For your own application you will want to call the getValue that names your Schema

Parameters:
dbName - The data context to get the value for
setupCode - The code string of the setup code required
Returns:
String value stored in the given config value
Throws:
DBException - If the value cannot be retrieved

getValue

public static String getValue(String dbName,
                              String schemaName,
                              String setupCode)
                       throws DBException
Get a config value for the default schema Config values are like INI file variables or registry entries - except stored in a database. There is one database connection held open for accessing these values from the connection pool

Parameters:
dbName - The data context name
schemaName - The name of the schema
setupCode - The code string of the setup code required
Returns:
String value stored in the given config value
Throws:
DBException - If the value cannot be retrieved

getValueRequired

public static String getValueRequired(String dbName,
                                      String setupCode)
                               throws DBException
Get a value from the configuration values. The value must be valid (not null) or the method throws an exception

Parameters:
dbName - The datacontext name
setupCode - Code of the required setup value
Returns:
java.lang.String
Throws:
DBException - if the value does not exist or is null

getValueUnrequired

public static String getValueUnrequired(String dbName,
                                        String setupCode)
Get a value from the configuration values. Return null (no exception) if value doesn't exist

Parameters:
dbName - The datacontext name
setupCode - Code of the required setup value
Returns:
java.lang.String of value, or null if not found

getValueUnrequired

public static String getValueUnrequired(String dbName,
                                        String schema,
                                        String setupCode)
Get a value from the configuration values. Return null (no exception) if value doesn't exist

Parameters:
dbName - The datacontext name
setupCode - Code of the required setup value
schema - name of schema
Returns:
java.lang.String of value, or null if not found

getValueRequired

public static String getValueRequired(String dbName,
                                      String schema,
                                      String setupCode)
                               throws DBException
Get a value from the configuration values. The value must be valid or the method throws an exception

Parameters:
dbName - The data context for the value
schema - The schema class for this setup code
setupCode - Code of the required setup value
Returns:
String
Throws:
DBException - if the value does not exist or is null

readSetups

public static void readSetups(boolean forceRead)
                       throws DBException
Parameters:
forceRead - - Tries to reread the setup values even if the db tables don't exist yet.
Throws:
DBException - if there's an error reading the setups

readSetups

public static void readSetups()
                       throws DBException
Read the setup/config values into a hashtable for cached access

Throws:
DBException - upon error

retrieve

public void retrieve()
              throws DBException
Extend retrieve to supply a defeult for the schemaclass field

Overrides:
retrieve in class SecuredDBObject
Throws:
DBException - If the retrieve fails

setTableExists

public static void setTableExists(String dbName)
DB Tool calls this when the Expresso Setup Values are finally able to be read

Parameters:
dbName - the data context that setup tables now exist for

setupFields

protected void setupFields()
                    throws DBException
Description copied from class: DBObject
Method to set up the fields for this database object. This method should be defined in the implementing object and should make calls to addField, addKey, setMultiValued, etc. as required to define the content of the DBObject. Each setupFields method should call "super.setupFields()" so that field definitions can be "inheritcable"

Overrides:
setupFields in class DBObject
Throws:
DBException - If there is an error setting up the fields as requested. For example, if a field allowing null is requested as part of the key
See Also:
DBObject.setupFields()

update

public void update()
            throws DBException
Extend update to validate some setup values

Specified by:
update in interface DataObject
Overrides:
update in class SecuredDBObject
Throws:
DBException - upon error

setCode

public void setCode(String code)
             throws DBException
convenience setter for code

Parameters:
code - new code to set
Throws:
DBException

setValue

public void setValue(String value)
              throws DBException
convenience setter for value

Parameters:
value - new value to set
Throws:
DBException

setDescrip

public void setDescrip(String descrip)
                throws DBException
convenience setter for description of Setup item

Parameters:
descrip - new description to set
Throws:
DBException

setSchemaClass

public void setSchemaClass(String schemaclassname)
                    throws DBException
convenience setter for schema class; schema is optional; if not provided, find() will default to Expresso

Parameters:
schemaclassname - new name to set
Throws:
DBException

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.