Expresso 5-6

com.jcorporate.expresso.services.dbobj
Class JobQueue

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.JobQueue
All Implemented Interfaces:
Cacheable, ContextNested, DataObject, LookupInterface, Securable, Serializable

public class JobQueue
extends SecuredDBObject

Copyright 1999, 2000, 2001 Jcorporate Ltd.

Jobqueue is a table that contains all the jobs, or asynchronous tasks, to be executed. This table works with JobQueueParam table as a detail table so that multiple parameters per job may be specified. The JobHandler checks the JobQueue table every so often to see if there's a job there waiting to be used. If it is, then the JobHandler server takes ownership of that JobQueue entry, constructs a job object based upon it and executes the appropriate job

Version:
$Revision: 1.16 $ $Date: 2004/11/17 20:48:18 $
Author:
Michael Nash, Cron Enhancements by Mike Dubman
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 FLD_JOB_PROGRESS_MSG
           
static String FLD_JOBCODE
           
static String FLD_JOBCRON_PARAMS
           
static String FLD_JOBNUMBER
           
static String FLD_JOBOSNAME
           
static String FLD_PRIORITY
           
static String FLD_REQUEST_TIME
           
static String FLD_SERVERID
           
static String FLD_STATUS_CODE
           
static String FLD_UID
           
static String JOB_ARCH_ANY
           
static String JOB_ARCH_MSWIN
           
static String JOB_ARCH_UNIX
           
static String JOB_PRIORITY_HIGH
           
static String JOB_PRIORITY_LOW
           
static String JOB_PRIORITY_NORMAL
           
static String JOB_STATUS_AVAILABLE
           
static String JOB_STATUS_COMPLETED
           
static String JOB_STATUS_KILLED
           
static String JOB_STATUS_NEW
           
static String JOB_STATUS_RUNNING
           
static String JOB_STATUS_STOPPED
           
static String JOB_STATUS_SUSPENDED
           
 
Fields inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
ADD, ALL_FUNCTIONS, CACHE_NAME, 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
JobQueue()
           
JobQueue(ControllerRequest request)
          For using DBObjects within Controllers.
JobQueue(DBConnection newConnection)
          Connection that provides a DBConnection.
JobQueue(int uid)
          Initializes the JobQueue with the appropriate user permissions.
 
Method Summary
 void add()
          Extends the usual add method to fetch a next number field and set the Updated flag to Y
 boolean find()
          Extend the normal find method to read the parameters once the find is done.
 String getCronEntry()
           
 String getField(String fieldName)
          Get the string value of a field in this object as a string
 String getJobStatus()
           
 Vector getParams()
          Get the job queue parameters associated with this queue entry
 String getParamValue(String paramCode)
          Get the parameter value for the named parameter code
 Vector getValidValues(String fieldName)
          Override the method getValidValues to provide specific values for our multi-valued fields
 void retrieve()
          Extend the normal retrieve method to read the parameters after the record is retrieved
 void setCronParams(int minute, int hour, int dayOfMonth, int month, int dayOfWeek, int year)
          Cron-like alarm (minute, hour, day of month, month, day of week, year) Repetitive when the year is not specified.
 void setJobCode(String jobCode)
           
 void setJobOSName(String os)
           
 void setJobStatus(String status)
           
 void setUid(String userId)
           
protected  void setupFields()
          Method to set up the fields for this database object.
 boolean useCron()
          Convenience method to determine if cron parameters are associated with this object instance.
 
Methods inherited from class com.jcorporate.expresso.core.dbobj.SecuredDBObject
canRequesterAdd, canRequesterDelete, canRequesterRead, canRequesterUpdate, checkAllowed, copyAttributes, count, createSecurityCache, delete, deleteAll, getRequestingUid, getString, getString, getString, getString, getString, getString, getSystemUid, instantiate, isAllowed, search, searchAndRetrieveList, searchAndRetrieveList, setRequestingUid, update
 
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, 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, 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

FLD_JOBOSNAME

public static final String FLD_JOBOSNAME
See Also:
Constant Field Values

FLD_JOBCRON_PARAMS

public static final String FLD_JOBCRON_PARAMS
See Also:
Constant Field Values

FLD_UID

public static final String FLD_UID
See Also:
Constant Field Values

FLD_JOBCODE

public static final String FLD_JOBCODE
See Also:
Constant Field Values

FLD_STATUS_CODE

public static final String FLD_STATUS_CODE
See Also:
Constant Field Values

FLD_PRIORITY

public static final String FLD_PRIORITY
See Also:
Constant Field Values

FLD_JOBNUMBER

public static final String FLD_JOBNUMBER
See Also:
Constant Field Values

FLD_REQUEST_TIME

public static final String FLD_REQUEST_TIME
See Also:
Constant Field Values

FLD_SERVERID

public static final String FLD_SERVERID
See Also:
Constant Field Values

FLD_JOB_PROGRESS_MSG

public static final String FLD_JOB_PROGRESS_MSG
See Also:
Constant Field Values

JOB_PRIORITY_HIGH

public static final String JOB_PRIORITY_HIGH
See Also:
Constant Field Values

JOB_PRIORITY_NORMAL

public static final String JOB_PRIORITY_NORMAL
See Also:
Constant Field Values

JOB_PRIORITY_LOW

public static final String JOB_PRIORITY_LOW
See Also:
Constant Field Values

JOB_ARCH_UNIX

public static final String JOB_ARCH_UNIX
See Also:
Constant Field Values

JOB_ARCH_MSWIN

public static final String JOB_ARCH_MSWIN
See Also:
Constant Field Values

JOB_ARCH_ANY

public static final String JOB_ARCH_ANY
See Also:
Constant Field Values

JOB_STATUS_NEW

public static final String JOB_STATUS_NEW
See Also:
Constant Field Values

JOB_STATUS_AVAILABLE

public static final String JOB_STATUS_AVAILABLE
See Also:
Constant Field Values

JOB_STATUS_COMPLETED

public static final String JOB_STATUS_COMPLETED
See Also:
Constant Field Values

JOB_STATUS_RUNNING

public static final String JOB_STATUS_RUNNING
See Also:
Constant Field Values

JOB_STATUS_STOPPED

public static final String JOB_STATUS_STOPPED
See Also:
Constant Field Values

JOB_STATUS_KILLED

public static final String JOB_STATUS_KILLED
See Also:
Constant Field Values

JOB_STATUS_SUSPENDED

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

JobQueue

public JobQueue()
         throws DBException
See Also:
SecuredDBObject

JobQueue

public JobQueue(DBConnection newConnection)
         throws DBException
Connection that provides a DBConnection.

Parameters:
newConnection - an already created DBConnection grabbed from the connection pool that will be used for the lifetime of the object.

JobQueue

public JobQueue(int uid)
         throws DBException
Initializes the JobQueue with the appropriate user permissions.

Parameters:
uid - The User's uid
Throws:
DBException - on error

JobQueue

public JobQueue(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.
Method Detail

add

public void add()
         throws DBException
Extends the usual add method to fetch a next number field and set the Updated flag to Y

Specified by:
add in interface DataObject
Overrides:
add in class SecuredDBObject
Throws:
DBException - If the next number cannot be determined or the add fails

find

public boolean find()
             throws DBException
Extend the normal find method to read the parameters once the find is done.

Specified by:
find in interface DataObject
Overrides:
find in class SecuredDBObject
Returns:
boolean
Throws:
DBException - if search is not allowed

getParams

public Vector getParams()
                 throws DBException
Get the job queue parameters associated with this queue entry

Returns:
Vector A vector of JobQueueParam objects for this entry
Throws:
DBException - If the job queue entry has not yet been retrieved

getParamValue

public String getParamValue(String paramCode)
                     throws DBException
Get the parameter value for the named parameter code

Parameters:
paramCode - Code for which we want the value
Returns:
String The parameter value
Throws:
DBException - If the paramter value cannot be retrieved

getValidValues

public Vector getValidValues(String fieldName)
                      throws DBException
Override the method getValidValues to provide specific values for our multi-valued fields

Overrides:
getValidValues in class DBObject
Parameters:
fieldName - Field name for which values are requested
Returns:
Vector The ValidValues field
Throws:
DBException - If the values cannot be retrieved

retrieve

public void retrieve()
              throws DBException
Extend the normal retrieve method to read the parameters after the record is retrieved

Overrides:
retrieve in class SecuredDBObject
Throws:
DBException - If the parameters or the entry cannot be retrieved

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()

getField

public String getField(String fieldName)
                throws DBException
Description copied from class: DBObject
Get the string value of a field in this object as a string

Specified by:
getField in interface DataObject
Overrides:
getField in class DBObject
Parameters:
fieldName - Name of the field to fetch
Returns:
The value of the given field as a string - if the field is null, an empty string is returned.
Throws:
DBException - If there is no such field or it's value cannot be accessed

setJobOSName

public void setJobOSName(String os)
                  throws DBException
Throws:
DBException

setUid

public void setUid(String userId)
            throws DBException
Throws:
DBException

setJobCode

public void setJobCode(String jobCode)
                throws DBException
Throws:
DBException

setJobStatus

public void setJobStatus(String status)
                  throws DBException
Throws:
DBException

getJobStatus

public String getJobStatus()
                    throws DBException
Throws:
DBException

useCron

public boolean useCron()
                throws DBException
Convenience method to determine if cron parameters are associated with this object instance.

Returns:
true if cron parameters are associated with this job
Throws:
DBException

getCronEntry

public String getCronEntry()
                    throws DBException
Throws:
DBException

setCronParams

public void setCronParams(int minute,
                          int hour,
                          int dayOfMonth,
                          int month,
                          int dayOfWeek,
                          int year)
                   throws DBException

Cron-like alarm (minute, hour, day of month, month, day of week, year) Repetitive when the year is not specified.

Examples:

Every minute:
: setCronParams(-1, -1, -1, -1, -1)

Every hour at 5:
: setCronParams(5, -1, -1, -1, -1, -1)

Lunch time:
setCronParams(00, 12, -1, -1, -1, -1)

On the first of every month at 9:30
setCronParams(30, 9, 1, -1, -1, -1)

On every Friday at 18:00
setCronParams(00, 18, -1, -1, Calendar.FRIDAY, -1)

2 years that this class was programmed !
setCronParams(00, 13, 1, Calendar.AUGUST, -1, 2001)

Parameters:
minute - The minute code
hour - The hour code
dayOfMonth - The day of Month code
month - the Month to execute code
dayOfWeek - The day of week to execute code
year - The year to execute code
Throws:
DBException - upon error

Expresso 5-6

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