public abstract class Job extends DBPersist
Abstract base class for Job Commands Implementations
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COMMAND_DUMY |
static java.lang.String |
COMMAND_FAX |
static java.lang.String |
COMMAND_FTP |
static java.lang.String |
COMMAND_MAIL |
static java.lang.String |
COMMAND_SAVE |
static java.lang.String |
COMMAND_SEND |
static short |
STATUS_ABORTED |
static short |
STATUS_FINISHED |
static short |
STATUS_INTERRUPTED |
static short |
STATUS_PENDING |
static short |
STATUS_RUNNING |
static short |
STATUS_SUSPENDED |
Constructor and Description |
---|
Job() |
Modifier and Type | Method and Description |
---|---|
void |
abort(JDCConnection oConn) |
boolean |
delete(JDCConnection oConn)
Delete Job
|
static boolean |
delete(JDCConnection oConn,
java.lang.String sJobId)
Delete Job
Call k_sp_del_job stored procedure
|
abstract void |
free()
This method must free all the resource allocated by a Job
|
DBBind |
getDataBaseBind()
Get database binding for this Job
|
static java.lang.String |
getIdFromTitle(JDCConnection oConn,
java.lang.String sTitle,
java.lang.String sGuWorkArea)
Get a Job GUID given its title
|
java.lang.String |
getParameter(java.lang.String sParamName)
Get parameter extracted from tx_parameter field
|
java.util.Properties |
getParameters()
Get parameters extracted from tx_parameter field
|
java.util.Properties |
getProperties()
Get Environment Properties Collection
|
java.lang.String |
getProperty(java.lang.String sPropertyName)
Get Environment Property
Environment properties are readed from hipergate.cnf.
|
short |
getStatus()
Get Job status
|
void |
insertRecipients(JDCConnection oConn,
java.lang.String[] aRecipients,
java.lang.String sRecipientTp,
java.lang.String sFormat,
short iStatusId)
Insert a recipients list as new atoms of this Job
The recipient data is readed from k_member_address by using recipient's e-mail as key.
|
static Job |
instantiate(JDCConnection oConn,
java.lang.String sJobId,
java.util.Properties oEnvironmentProps)
Create an instance of a Job subclass
The new object class name will be readed form k_jobs.nm_class field.
|
static Job |
instantiate(JDCConnection oConn,
java.lang.String sJobId,
java.lang.String sProfileName)
Create an instance of a Job subclass
The new object class name will be readed form k_jobs.nm_class field.
|
boolean |
load(JDCConnection oConn,
java.lang.Object[] PKVals)
Load Job
|
void |
log(java.lang.String sStr)
Write Line to Job Log File
|
java.io.File |
logFile()
Get reference to Job log file
Job log file is placed at /storage/jobs/gu_workarea/
|
static void |
main(java.lang.String[] argv) |
int |
pending()
Count of atoms pending of processing for this Job
This count is decremented upon each successfull call to process() method
|
abstract java.lang.Object |
process(Atom oAtm)
Process an atom
Concrete atom processing implementation must be provided by each derived subclass.
|
void |
resolveAtomsEMails(JDCConnection oConn)
Fills atoms data from their e-mails
This method call k_sp_resolve_atoms stored procedure which takes each atom
mail address and looks it up at k_member_address table for completing name
surname and other personalization data embedded into each atom's record
|
void |
setDataBaseBind(DBBind oDbb)
Assign a database binding to the Job
|
void |
setStatus(JDCConnection oConn,
int iStatus)
Set Job Status
If Status if set to Job.STATUS_FINISHED then dt_finished is set to current
system date.
|
boolean |
store(JDCConnection oConn)
Store Job
By default jobs are created with id_status=STATUS_PENDING
|
allcaps, allcaps, clear, clone, columns, containsKey, containsValue, entrySet, exists, get, get, getAuditClassName, getCreationDate, getDate, getDate, getDateFormated, getDateShort, getDateTime, getDateTime24, getDecimal, getDecimalFormated, getDecimalFormated, getDouble, getDoubleFormated, getFloat, getFloatFormated, getInt, getIntArray, getInteger, getIntegerArray, getIntervalPart, getItemMap, getItems, getMoney, getPrimaryKey, getShort, getSQLDate, getSQLTime, getString, getStringHtml, getStringNull, getTable, getTable, getTime, getTimeOfDay, getTimestamp, isEmpty, isNull, iterator, keySet, load, parseXML, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, put, putAll, putAll, remove, remove, replace, replace, replace, replace, replace, replace, replace, replace, setAuditTransact, setAuditUser, setCreationDate, setPrimaryKey, size, toLowerCase, toUpperCase, toXML, toXML, toXML, values
public static final short STATUS_ABORTED
public static final short STATUS_FINISHED
public static final short STATUS_PENDING
public static final short STATUS_SUSPENDED
public static final short STATUS_RUNNING
public static final short STATUS_INTERRUPTED
public static final java.lang.String COMMAND_SEND
public static final java.lang.String COMMAND_MAIL
public static final java.lang.String COMMAND_SAVE
public static final java.lang.String COMMAND_FAX
public static final java.lang.String COMMAND_FTP
public static final java.lang.String COMMAND_DUMY
public abstract java.lang.Object process(Atom oAtm) throws java.sql.SQLException, java.io.FileNotFoundException, java.io.IOException, javax.mail.MessagingException, java.lang.NullPointerException, java.lang.ClassNotFoundException, java.lang.InstantiationException, java.lang.IllegalAccessException
Process an atom
Concrete atom processing implementation must be provided by each derived subclass.oAtm
- Atom to be processedjava.sql.SQLException
java.io.FileNotFoundException
java.io.IOException
javax.mail.MessagingException
java.lang.NullPointerException
java.lang.ClassNotFoundException
java.lang.InstantiationException
java.lang.IllegalAccessException
public abstract void free()
This method must free all the resource allocated by a Job
public int pending()
Count of atoms pending of processing for this Job
This count is decremented upon each successfull call to process() methodpublic void abort(JDCConnection oConn) throws java.sql.SQLException, java.lang.IllegalStateException
java.sql.SQLException
java.lang.IllegalStateException
public boolean load(JDCConnection oConn, java.lang.Object[] PKVals) throws java.sql.SQLException
Load Job
public boolean delete(JDCConnection oConn) throws java.sql.SQLException
Delete Job
public boolean store(JDCConnection oConn) throws java.sql.SQLException
Store Job
By default jobs are created with id_status=STATUS_PENDINGpublic java.util.Properties getParameters()
Get parameters extracted from tx_parameter field
public java.lang.String getParameter(java.lang.String sParamName)
Get parameter extracted from tx_parameter field
sParamName
- Parameter Namepublic java.lang.String getProperty(java.lang.String sPropertyName)
Get Environment Property
Environment properties are readed from hipergate.cnf.sPropertyName
- public java.util.Properties getProperties()
public java.io.File logFile()
Get reference to Job log file
Job log file is placed at /storage/jobs/gu_workarea/public void log(java.lang.String sStr)
Write Line to Job Log File
sStr
- Line to be writtenpublic DBBind getDataBaseBind()
public void setDataBaseBind(DBBind oDbb)
oDbb
- DBBindpublic void setStatus(JDCConnection oConn, int iStatus) throws java.sql.SQLException
Set Job Status
If Status if set to Job.STATUS_FINISHED then dt_finished is set to current system date.oConn
- Database ConnectioniStatus
- Job Status
Status |
STATUS_ABORTED (-1) |
STATUS_FINISHED (0) |
STATUS_PENDING (1) |
STATUS_SUSPENDED (2) |
STATUS_RUNNING (3) |
java.sql.SQLException
public short getStatus()
Get Job status
public void resolveAtomsEMails(JDCConnection oConn) throws java.sql.SQLException
Fills atoms data from their e-mails
This method call k_sp_resolve_atoms stored procedure which takes each atom mail address and looks it up at k_member_address table for completing name surname and other personalization data embedded into each atom's recordoConn
- JDCConnectionjava.sql.SQLException
public static boolean delete(JDCConnection oConn, java.lang.String sJobId) throws java.sql.SQLException
Delete Job
Call k_sp_del_job stored procedureoConn
- Database ConnectionsJobId
- GUID of Job to be deletedjava.sql.SQLException
public static Job instantiate(JDCConnection oConn, java.lang.String sJobId, java.util.Properties oEnvironmentProps) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.sql.SQLException, java.lang.InstantiationException, java.io.FileNotFoundException
Create an instance of a Job subclass
The new object class name will be readed form k_jobs.nm_class field.
oConn
- Database ConnectionsJobId
- GUID of Job to be instantiatedoEnvironmentProps
- Environment properties taken from hipergate.cnfjava.io.FileNotFoundException
- If any directory for Job log file could not be createdjava.lang.ClassNotFoundException
- If no class with name k_jobs.nm_class was foundjava.lang.IllegalAccessException
java.lang.InstantiationException
java.sql.SQLException
public static Job instantiate(JDCConnection oConn, java.lang.String sJobId, java.lang.String sProfileName) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.sql.SQLException, java.lang.InstantiationException, java.io.FileNotFoundException
Create an instance of a Job subclass
The new object class name will be readed form k_jobs.nm_class field.
oConn
- Database ConnectionsJobId
- GUID of Job to be deletedsProfileName
- Name without .cnf extension of the properties file to usejava.io.FileNotFoundException
- If any directory for Job log file could not be createdjava.lang.ClassNotFoundException
- If no class with name k_jobs.nm_class was foundjava.lang.IllegalAccessException
java.lang.InstantiationException
java.sql.SQLException
public static java.lang.String getIdFromTitle(JDCConnection oConn, java.lang.String sTitle, java.lang.String sGuWorkArea) throws java.sql.SQLException
Get a Job GUID given its title
oConn
- Database ConnectionsTitle
- Job Title (search is case sensitive)oGuWorkArea
- GUID of WorkArea to restrict search, if null then all workareas are searchedjava.sql.SQLException
public void insertRecipients(JDCConnection oConn, java.lang.String[] aRecipients, java.lang.String sRecipientTp, java.lang.String sFormat, short iStatusId) throws java.sql.SQLException
Insert a recipients list as new atoms of this Job
The recipient data is readed from k_member_address by using recipient's e-mail as key.oConn
- Database ConnectionaRecipients
- Recipients list (e-mail addresses)sRecipientTp
- Recipient Type {to,cc,bcc}sFormat
- Message Format {text,html}iStatusId
- {Job.STATUS_PENDING,STATUS_SUSPENDED}java.sql.SQLException
public static void main(java.lang.String[] argv) throws java.sql.SQLException, org.xml.sax.SAXException, java.io.IOException, java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.InstantiationException
java.sql.SQLException
org.xml.sax.SAXException
java.io.IOException
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException