org.bibalex.daf.entities.job
Class Job

java.lang.Object
  extended by org.bibalex.daf.entities.AdminModuleBase
      extended by org.bibalex.daf.entities.job.Job

public class Job
extends AdminModuleBase

Handles the job related tasks such as starting and finishing a job

Author:
Shehab.Kamal

Nested Class Summary
static class Job.JobOldOrNew
          Enumerator lists the possible states of the Job in the system.
 
Field Summary
private  int batchID
           
private  java.lang.String batchName
           
private  java.lang.String collectionName
           
private  int conditionID
           
private  DBConnection conn
           
private  java.lang.String creator
           
private  java.util.Date date
           
private  java.util.Date dueDate
           
private  java.lang.String externalID
           
private  int externalIDType
           
private  java.lang.String externalIDTypeName
           
private  int id
           
private  java.lang.String identifyingLob
           
private  java.lang.String Info1
           
private  java.lang.String Info2
           
private  java.lang.String Info3
           
private  int jobTypeID
           
private  java.lang.String jobTypeName
           
private  int languageID
           
private  java.lang.String languageName
           
private  java.lang.String path
           
private  int priority
           
private  int storageID
           
private  boolean textualValuesInitialized
          Whether the textual values have been initialized or not.
private  java.lang.String title
           
private  int transactionLog
           
 
Constructor Summary
Job()
          Creates a new instance of Job.
Job(DataTable table)
          Creates a new instance of Job.
Job(int jobID)
          Creates a new instance of Job.
This constructor fills all the fields from the database.
Remarks: Fields that correspond to null database columns are left to default values, i.e.
 
Method Summary
 OperationInfo add()
          Adds this instance to the Job table.
 OperationInfo addMedia(int mediaType, int mediaID, int TLID)
          Add the job to Job_Media table
 OperationInfo addWithID()
          Adds this instance to the Job table With a given ID.
 OperationInfo assign(int user, int phase, java.lang.String comment)
          Assign the specified phase for this Job to the given User.
 OperationInfo assignFromScratch(int user, int phase, java.lang.String comment)
          Assign the job from scratch.
private  OperationInfo assignInDatabase(java.lang.String spName, int user, int phase, java.lang.String comment, boolean ignorePropagationErrors)
          Assign the job.
 OperationInfo assignRestricetd(int user, int phase)
          Assign the specified phase for this Job to the given User.
 boolean canChangeType(int oldOrNew)
          Determines whether the given job can change its type or not.
 boolean canCheckOut(int jobID)
          Determines if the job can check out ro not.
 boolean canDownload()
          Determines if the job can be downloaded or not.
 boolean canFinish(int workstationID)
          Determines whether the job can finish from the given workstation or not.
 boolean canStart(int userID, int wrkstID, int phaseID)
          Determines whether the job can start or not.
 boolean canUpload()
          Determines if the job can be uploaded or not.
static OperationInfo checkIn(int jobID)
          Move the job history from OldTransactionLog to TransactionLog.
 OperationInfo checkNonConfirmedMedias()
          Check if the job medias are all confirmed to delete or not
static OperationInfo checkOut(int jobID, int userID, int wsID, java.lang.String comment)
          Move the job history from TransactionLog to OldTransactionLog.
static OperationInfo checkOutRollback(int jobID)
          Roll back job check out.
 OperationInfo delete()
          Deletes this instance from the Job table.
 boolean deleteBackupFolder()
          Deletes the job version folder(s) located at the backup server.
Notes:
1) All the job versions are deleted from the backup server.
2) If a version folder couldn't be deleted, the error is logged and the program continues and attempts to delete the next next version, if any, and so on.
 OperationInfo deleteCascade()
          Deletes this instance (Cascaded).
 boolean deleteLocalFolder(WorkStation workstation, User user)
          Deletes the job folder located at the given workstation.
Notes:
1) The folder is deleted using a FileHandlerLocalImpl
2) Failure to delete the job folder will be logged to the LogManager.
 boolean deleteRemoteFolder()
          Deletes the job folder located at the server.
Notes:
1) The folder is deleted using a FileHandlerFTPImpl
2) Failure to delete the job folder will be logged to the LogManager.
 boolean download(WorkStation workstation, User user)
          Downloads the job.
 OperationInfo downloadInDatabase(int phaseID, int noOfFiles)
          Sets the job state to download in the database.
 boolean finish(User user, WorkStation workstation, boolean fromCommandLine)
          Finishes the job.
 OperationInfo finishInDatabase(int userID, int workstationID, int noOfFiles, java.lang.String statusData)
          Sets the job state to finish in the database.
 OperationInfo getAllPhasesWithUsers()
          Gets All Phases for this Job, and the Last User on This Phase if there exists one.
static OperationInfo getArchivedAndActiveJobs()
          Get the medias that the job has been saved on
 OperationInfo getArchivingMatrix()
          Get the archiving history matrix
 int getBatchID()
          Gets the batch ID of the job.
 java.lang.String getBatchName()
          Retrieves the Batch name for this job.
static OperationInfo getByID(int jobID)
          Gets the job specified by the ID.
 java.lang.String getCollectionName()
          Retrieves the Collection Name for this Job.
 int getConditionID()
          Gets the collection ID of the job.
 DBConnection getConnection()
          Gets the connection of the job.
 java.lang.String getCreator()
          Gets the creator of the job.
 java.util.Date getDate()
          Gets the date of the job.
 OperationInfo getDoneJobs(int MediaTypeID)
          Gets jobs that are finished and ready to archive.
 OperationInfo getDoneJobs(int MediaTypeID, java.lang.String jobCount)
          Gets jobs that are finished and ready to archive (with limit = jobCount).
 java.util.Date getDueDate()
          Gets the due date of the job.
 OperationInfo getExpandedWorkFlowJobs(int jobType, int collID, int batchID)
          Gets the Expanded System WorkFlow.
 java.lang.String getExternalID()
          Gets the external ID of the job.
 int getExternalIDType()
          Gets the external Id type of the job.
 java.lang.String getExternalIDTypeName()
          Retrieves the External ID Type name for this job.
 FileHandlerFTPImpl getFTPFileHandler()
          Gets the FileHandlerFTPImpl used to manipulate the job folder at the server.
 int getID()
          Gets the ID of the job.
 java.lang.String getIdentifyingLob()
          Gets the identifying lob of the job.
 java.lang.String getInfo1()
          Gets the firts info associated with the job.
 java.lang.String getInfo2()
          Gets the second info associated with the job.
 java.lang.String getInfo3()
          Gets the third info associated with the job.
 OperationInfo getJobHistory()
          Gets the job history.
 java.lang.String getJobInformation(boolean includeHistory)
          Gets information about the job.
The information are formed as an Xml string with the following structure:
<job>
<Nama#1>Value1</Name#1>
.
<Nama#n>Value1</Name#n>
<History>
<Entry#1 User="" Workstation="" Status="" Phase="" Date="" NumberOfFile="" />
.
<Entry#n User="" Workstation="" Status="" Phase="" Date="" NumberOfFile="" />
</History>
</job>
Notes:
1) History node will be included if and only if the includeHistory parameter is true.
2) Values are the names that corrspond to the ID, i.e.
 Job.JobOldOrNew getJobOldOrNewState()
          Retrieves wether this Job is Checked-Out or still in the System.
 int getJobTypeID()
          Gets the jobType ID.
 java.lang.String getJobTypeName()
          Retrieves the Batch name for this job.
 int getLanguageID()
          Gets the language ID of the job.
 java.lang.String getLanguageName()
          Retrieves the Language Name for this Job.
 OperationInfo getLastData()
          Gets the last data, the TransactionLog row to which the job points, of the job.
 OperationInfo getLastFinishedInfo()
          Gets the TransactionLog entry that corresponds to the last finished status of the job.
 OperationInfo getLastFinishedInfoForPhase(int phaseID)
          Gets the last finished information for the given phase.
 Phase getLastPhaseBeforeBackup()
          Gets the last phase before the backup phase.
 OperationInfo getLateJobs()
          Gets the Late job.
 java.lang.String getLocalPath(WorkStation workstation, User user)
          Gets the job path at the workstation not including the job name.
 OperationInfo getMedias()
          Get the medias that the job has been saved on
 OperationInfo getMediaTypes()
          Get the media types which the current job should be archived on
 int getMinPhase(int minPhaseID, Phase currentPahse)
          Gets the ID of the phase with the minimum sequence.
 int getNextVersion()
          Gets the next version of the job.
Next version = number of backup entries of the job in the transaction log + 1.
 java.lang.String getPath()
          Gets the language ID of the job.
 OperationInfo getPendingJobs()
          Gets the pending job.
 Phase getPhase()
          Gets the current phase of the job.
 int getPriority()
           
 OperationInfo getRedirectedJobs()
          Gets the rejected job.
 OperationInfo getRejectedJobs()
          Gets the rejected jobs.
 java.lang.String getServerPath()
          Gets the job path at the server not including the job name.
 java.util.Date getStartDate()
          Gets the start date of the job.
 Phase getStartingPhase()
          Gets the phase in which the job will strat.
If the job points to an assign entry then the phase in this entry is considered the satrting phase.
If the job doesn't point to an assign entry then the phase next to the phase in this entry is considered the starting phase.
 int getStorageID()
           
private  void getTextualValues()
          Retrieves the textual values for this job.
 java.lang.String getTitle()
           
 int getTransactionLogID()
           
 OperationInfo getWorkFlowJobs(int jobType, int collID, int batchID)
          Gets the System WorkFlow.
 OperationInfo getZips(int jobVersion)
          Gets the zipped folders in a specific backed up bersion
 boolean isArchivingMatrixComplete()
          Check if the history matrix is complete or not
 boolean isRephase(int phaseID)
          Determines whether the job has started in the given phase at least once.
static OperationInfo loadAll()
          Loads all the entries form the Job table.
static int nextID()
          Gets an integer that can be used as the job ID.
static java.lang.String PadID(long id)
          Converts the given ID into a 0 paded string.
 OperationInfo preAssign(int user, int phase)
          Pre-Assign the specified phase for this Job to the given User.
 boolean redirect(User user, WorkStation workstation, int nextUser, int nextPhase, java.lang.String comment)
          Redirects the job.
 OperationInfo redirectInDatabase(int userID, int phaseID, int noOfFiles, int workstationID, int nextUserID, int nextPhaseID, java.lang.String finishStatusData, java.lang.String redirectStatusData, java.lang.String assignStatusData)
          Sets the job state to redirect in the database.
The stored procedure does the following:
1) Adds a finish entry for the job.
2) Adds the redirect entry for the job.
3) Adds an assign entry if the job has the right to do so.
 boolean reject(User user, WorkStation workstation, User nextUser, Phase nextPhase, java.lang.String comment)
          Rejects the job.
 boolean rejectForced(User user, WorkStation workstation, User nextUser, Phase nextPhase, java.lang.String comment)
          Rejects the job by froce.
 OperationInfo rejectInDatabase(int nextPhaseID, int nextUserID, int workstationID, int noOfFiles, java.lang.String rejectStatusData, java.lang.String assignStatusData, boolean forced)
          Sets the job state to reject in the database.
The stored procedure does the following:
1) Adds the reject entry for the job.
2) Adds an assign entry if the job has the right to do so.
 void setBatchID(int batchID)
          Sets the batch ID of the job.
 void setConditionID(int conditionID)
          Sets the collection ID of the job.
 void setCreator(java.lang.String creator)
          Sets the creator of the job.
 void setDate(java.util.Date date)
          Sets the Date of the job.
 void setDueDate(java.util.Date dueDate)
          Sets the due date of the job.
 void setExternalID(java.lang.String externalID)
          Sets the external ID of the job.
 void setExternalIDType(int externalIDType)
          Sets the external ID type of the job.
 void setFieldsFromDataTable(DataTable table)
          Uses the given DataTable to set the fields.
 void setID(int id)
          Sets the ID of the job.
 void setIdentifyingLob(java.lang.String identifyingLob)
          Sets the identifying lob of the job.
 void setInfo1(java.lang.String info1)
          Sets the first info associated with the job.
 void setInfo2(java.lang.String info2)
          Sets the second info associated with the job.
 void setInfo3(java.lang.String info3)
          Sets the third info associated with the job.
 void setJobTypeID(int jobTypeID)
          Sets the jobType ID.
 void setLanguageID(int languageID)
          Sets the language ID of the job.
 void setPath(java.lang.String path)
          Sets the path of the job.
 void setPriority(int priority)
           
 void setStorageID(int storageID)
           
 void setTitle(java.lang.String title)
           
 void setTransactionLogID(int transactionLogID)
           
 boolean start(WorkStation workstation, User user)
          Starts the job.
 OperationInfo startInDatabase(int userID, int phaseID, int workstationID, java.lang.String statusData)
          Sets the job state to start in the database.
 OperationInfo update()
          Updates this instance in the Job table.
 boolean upload(WorkStation workstation, User user)
          Uploads the job.
 OperationInfo uploadInDatabase(int phaseID, int noOfFiles)
          Sets the job state to upload in the database.
static OperationInfo validateUserWSPhase(int jobID, int userID, int wsID, int phaseID)
          Validate the combination job, user, WS and phase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

textualValuesInitialized

private boolean textualValuesInitialized
Whether the textual values have been initialized or not.


conn

private DBConnection conn

id

private int id

externalID

private java.lang.String externalID

externalIDType

private int externalIDType

title

private java.lang.String title

creator

private java.lang.String creator

date

private java.util.Date date

Info1

private java.lang.String Info1

Info2

private java.lang.String Info2

Info3

private java.lang.String Info3

path

private java.lang.String path

priority

private int priority

dueDate

private java.util.Date dueDate

identifyingLob

private java.lang.String identifyingLob

batchID

private int batchID

jobTypeID

private int jobTypeID

languageID

private int languageID

conditionID

private int conditionID

transactionLog

private int transactionLog

storageID

private int storageID

languageName

private java.lang.String languageName

batchName

private java.lang.String batchName

collectionName

private java.lang.String collectionName

externalIDTypeName

private java.lang.String externalIDTypeName

jobTypeName

private java.lang.String jobTypeName
Constructor Detail

Job

public Job()
Creates a new instance of Job. This constructor leaves all the fields empty.


Job

public Job(int jobID)
    throws java.lang.Exception
Creates a new instance of Job.
This constructor fills all the fields from the database.
Remarks: Fields that correspond to null database columns are left to default values, i.e. String and Date will be null and int will be 0.

Parameters:
jobID - The ID of the job.
Throws:
java.lang.Exception - If the job couldn't be retrieved from the database.

Job

public Job(DataTable table)
    throws java.lang.Exception
Creates a new instance of Job. This constructor fills all the fields from the DataTable. Remarks: Fields that correspond to null database columns are left to default values, i.e. String and Date will be null and int will be 0.

Parameters:
table - The DataTable used to construct the object.
Throws:
java.lang.Exception - If the job couldn't be constructed from the DataTable.
Method Detail

setFieldsFromDataTable

public void setFieldsFromDataTable(DataTable table)
                            throws java.lang.Exception
Uses the given DataTable to set the fields.

Parameters:
table - The DataTable used to set the fields.
Throws:
java.lang.Exception - If the fields couldn't be filled from the DataTable.

getConnection

public DBConnection getConnection()
Gets the connection of the job.

Returns:
Returns the connection.

PadID

public static java.lang.String PadID(long id)
Converts the given ID into a 0 paded string.

Parameters:
id - The ID to pad.
Returns:
A 0 padded ID.

getID

public int getID()
Gets the ID of the job.

Returns:
Returns the ID.

setID

public void setID(int id)
Sets the ID of the job.

Parameters:
id - The ID to set.

getBatchID

public int getBatchID()
Gets the batch ID of the job.

Returns:
Returns the batchID.

setBatchID

public void setBatchID(int batchID)
Sets the batch ID of the job.

Parameters:
batchID - The batchID to set.

getConditionID

public int getConditionID()
Gets the collection ID of the job.

Returns:
Returns the conditionID.

setConditionID

public void setConditionID(int conditionID)
Sets the collection ID of the job.

Parameters:
conditionID - The conditionID to set.

getCreator

public java.lang.String getCreator()
Gets the creator of the job.

Returns:
Returns the creator.

setCreator

public void setCreator(java.lang.String creator)
Sets the creator of the job.

Parameters:
creator - The creator to set.

getDate

public java.util.Date getDate()
Gets the date of the job.

Returns:
Returns the date.

setDate

public void setDate(java.util.Date date)
Sets the Date of the job.

Parameters:
date - The date to set.

getDueDate

public java.util.Date getDueDate()
Gets the due date of the job.

Returns:
Returns the dueDate.

setDueDate

public void setDueDate(java.util.Date dueDate)
Sets the due date of the job.

Parameters:
dueDate - The dueDate to set.

getExternalID

public java.lang.String getExternalID()
Gets the external ID of the job.

Returns:
Returns the externalID.

setExternalID

public void setExternalID(java.lang.String externalID)
Sets the external ID of the job.

Parameters:
externalID - The externalID to set.

getExternalIDType

public int getExternalIDType()
Gets the external Id type of the job.

Returns:
Returns the externalIDType.

setExternalIDType

public void setExternalIDType(int externalIDType)
Sets the external ID type of the job.

Parameters:
externalIDType - The externalIDType to set.

getIdentifyingLob

public java.lang.String getIdentifyingLob()
Gets the identifying lob of the job.

Returns:
Returns the identifyingLob.

setIdentifyingLob

public void setIdentifyingLob(java.lang.String identifyingLob)
Sets the identifying lob of the job.

Parameters:
identifyingLob - The identifyingLob to set.

getInfo1

public java.lang.String getInfo1()
Gets the firts info associated with the job.

Returns:
Returns the info1.

setInfo1

public void setInfo1(java.lang.String info1)
Sets the first info associated with the job.

Parameters:
info1 - The info1 to set.

getInfo2

public java.lang.String getInfo2()
Gets the second info associated with the job.

Returns:
Returns the info2.

setInfo2

public void setInfo2(java.lang.String info2)
Sets the second info associated with the job.

Parameters:
info2 - The info2 to set.

getInfo3

public java.lang.String getInfo3()
Gets the third info associated with the job.

Returns:
Returns the info3.

setInfo3

public void setInfo3(java.lang.String info3)
Sets the third info associated with the job.

Parameters:
info3 - The info3 to set.

getJobTypeID

public int getJobTypeID()
Gets the jobType ID.

Returns:
Returns the jobTypeID.

setJobTypeID

public void setJobTypeID(int jobTypeID)
Sets the jobType ID.

Parameters:
jobTypeID - The jobTypeID to set.

getLanguageID

public int getLanguageID()
Gets the language ID of the job.

Returns:
Returns the languageID.

setLanguageID

public void setLanguageID(int languageID)
Sets the language ID of the job.

Parameters:
languageID - The languageID to set.

getPath

public java.lang.String getPath()
Gets the language ID of the job.

Returns:
Returns the path.

setPath

public void setPath(java.lang.String path)
Sets the path of the job.

Parameters:
path - The path to set.

getPriority

public int getPriority()
Returns:
Returns the priority.

setPriority

public void setPriority(int priority)
Parameters:
priority - The priority to set.

getStorageID

public int getStorageID()
Returns:
Returns the storageID.

setStorageID

public void setStorageID(int storageID)
Parameters:
storageID - The storageID to set.

getTitle

public java.lang.String getTitle()
Returns:
Returns the title.

setTitle

public void setTitle(java.lang.String title)
Parameters:
title - The title to set.

getTransactionLogID

public int getTransactionLogID()
Returns:
Returns the transactionLog.

setTransactionLogID

public void setTransactionLogID(int transactionLogID)
Parameters:
transactionLogID - The transactionLog to set.

loadAll

public static OperationInfo loadAll()
Loads all the entries form the Job table.

Returns:
An OperationInfo instance whose result is a DataTable holding all the entries from the Job table.

getByID

public static OperationInfo getByID(int jobID)
Gets the job specified by the ID.

Parameters:
jobID - The ID of the job to get its data.
Returns:
An OperationInfo instance whose result is a DataTable containg the jobs that match the given criterion.

validateUserWSPhase

public static OperationInfo validateUserWSPhase(int jobID,
                                                int userID,
                                                int wsID,
                                                int phaseID)
Validate the combination job, user, WS and phase.

Parameters:
jobID - The ID of the job to validate.
userID - The ID of the user.
wsID - The ID of the workstation.
phaseID - The ID of the phase.
Returns:
An OperationInfo instance whose result is a DataTable containg 1 if valid, 0 otherwise

checkIn

public static OperationInfo checkIn(int jobID)
Move the job history from OldTransactionLog to TransactionLog.

Parameters:
jobID - The ID of the job to move its entries
Returns:
An OperationInfo instance whose result is a DataTable containg the job entries in the TransactionLog.

canCheckOut

public boolean canCheckOut(int jobID)
Determines if the job can check out ro not.

Parameters:
jobID - The ID of the job.
Returns:
True if the job can check out, otherwise false.

checkOut

public static OperationInfo checkOut(int jobID,
                                     int userID,
                                     int wsID,
                                     java.lang.String comment)
Move the job history from TransactionLog to OldTransactionLog.

Parameters:
jobID - The ID of the job.
userID - teh user who check the job out
wsID - the workstation that the job had been checked out there
comment - A Comment to be added to the Check-Out operation
Returns:
An OperationInfo instance contains a DataTable of the jobs that match the given criterion.

checkOutRollback

public static OperationInfo checkOutRollback(int jobID)
Roll back job check out.

Parameters:
jobID - The job ID
Returns:
operationInfo

checkNonConfirmedMedias

public OperationInfo checkNonConfirmedMedias()
Check if the job medias are all confirmed to delete or not

Returns:
An OperationInfo instance contains a DataTable of the medias that need a delete confirmation

getArchivedAndActiveJobs

public static OperationInfo getArchivedAndActiveJobs()
Get the medias that the job has been saved on

Returns:
OperationInfo

getMedias

public OperationInfo getMedias()
Get the medias that the job has been saved on

Returns:
OperationInfo

getMediaTypes

public OperationInfo getMediaTypes()
Get the media types which the current job should be archived on

Returns:
OperationInfo

getArchivingMatrix

public OperationInfo getArchivingMatrix()
Get the archiving history matrix

Returns:
OperationInfo

getJobInformation

public java.lang.String getJobInformation(boolean includeHistory)
Gets information about the job.
The information are formed as an Xml string with the following structure:
<job>
<Nama#1>Value1</Name#1>
.
<Nama#n>Value1</Name#n>
<History>
<Entry#1 User="" Workstation="" Status="" Phase="" Date="" NumberOfFile="" />
.
<Entry#n User="" Workstation="" Status="" Phase="" Date="" NumberOfFile="" />
</History>
</job>
Notes:
1) History node will be included if and only if the includeHistory parameter is true.
2) Values are the names that corrspond to the ID, i.e. batch name instead of batch ID and so on.

Parameters:
includeHistory - Whether to include the TransactionLog entries of the job in the returned information or not.
Returns:
A valid Xml String containing information about the job, or null if calling a stored procedure fails.

isArchivingMatrixComplete

public boolean isArchivingMatrixComplete()
Check if the history matrix is complete or not

Returns:
true if matrix is complete, otherwise return false

addMedia

public OperationInfo addMedia(int mediaType,
                              int mediaID,
                              int TLID)
Add the job to Job_Media table

Parameters:
mediaType - type is type of media (mediaID)
mediaID - The ID of the media .
TLID - the ID of the TransactionLog to add media for.
Returns:
An OperationInfo instance whose result holds the newly inserted row.

nextID

public static int nextID()
Gets an integer that can be used as the job ID.

Returns:
An integer that can bne as the job ID or -1 if the databse couldn't be queried.

add

public OperationInfo add()
Adds this instance to the Job table.

Specified by:
add in class AdminModuleBase
Returns:
An OperationInfo instance whose result is a DataTable holding the instance that has been added.

addWithID

public OperationInfo addWithID()
Adds this instance to the Job table With a given ID.

Returns:
An OperationInfo instance whose result is a DataTable holding the instance that has been added.

update

public OperationInfo update()
Updates this instance in the Job table.

Specified by:
update in class AdminModuleBase
Returns:
An OperationInfo whose result is a DataTable containing the updated record.

delete

public OperationInfo delete()
Deletes this instance from the Job table.

Specified by:
delete in class AdminModuleBase
Returns:
An OperationInfo instance whose result is null.

deleteCascade

public OperationInfo deleteCascade()
Deletes this instance (Cascaded).

Returns:
An OperationInfo instance whose result is null.

getDoneJobs

public OperationInfo getDoneJobs(int MediaTypeID)
Gets jobs that are finished and ready to archive.

Parameters:
MediaTypeID - The media type ID.
Returns:
An OperationInfo whose result is a DataTable containing the ready to archive jobs.

getDoneJobs

public OperationInfo getDoneJobs(int MediaTypeID,
                                 java.lang.String jobCount)
Gets jobs that are finished and ready to archive (with limit = jobCount).

Parameters:
MediaTypeID - The media type ID.
jobCount - the count limit to be retrieved
Returns:
An OperationInfo whose result is a DataTable containing the ready to archive jobs.

getRedirectedJobs

public OperationInfo getRedirectedJobs()
Gets the rejected job.

Returns:
An OperationInfo whose result is a DataTable containing the redirected jobs.

getPendingJobs

public OperationInfo getPendingJobs()
Gets the pending job.

Returns:
An OperationInfo whose result is a DataTable containing the redirected jobs.

getLateJobs

public OperationInfo getLateJobs()
Gets the Late job.

Returns:
An OperationInfo whose result is a DataTable containing the redirected jobs.

getWorkFlowJobs

public OperationInfo getWorkFlowJobs(int jobType,
                                     int collID,
                                     int batchID)
Gets the System WorkFlow.

Parameters:
jobType - The job type ID to filter on.
collID - The collection to filter on .
batchID - The batch to filter on.
Returns:
An OperationInfo whose result is a DataTable containing the redirected jobs.

getExpandedWorkFlowJobs

public OperationInfo getExpandedWorkFlowJobs(int jobType,
                                             int collID,
                                             int batchID)
Gets the Expanded System WorkFlow.

Parameters:
jobType - The job type ID.
collID - The collection to filter on .
batchID - The batch to filter on.
Returns:
An OperationInfo whose result is a DataTable containing the redirected jobs.

getRejectedJobs

public OperationInfo getRejectedJobs()
Gets the rejected jobs.

Returns:
An OperationInfo whose result is a DataTable containing the rejected jobs.

getZips

public OperationInfo getZips(int jobVersion)
Gets the zipped folders in a specific backed up bersion

Parameters:
jobVersion -
Returns:
An OperationInfo whose result is a DataTable containing the zipped folders as one string

getJobHistory

public OperationInfo getJobHistory()
Gets the job history.

Returns:
An OperationInfo whose result is a DataTable containing the TransactionLog of jobs.

getAllPhasesWithUsers

public OperationInfo getAllPhasesWithUsers()
Gets All Phases for this Job, and the Last User on This Phase if there exists one.

Returns:
OperationInfo with all the Phases and the Last User ID for each Phase.

getNextVersion

public int getNextVersion()
Gets the next version of the job.
Next version = number of backup entries of the job in the transaction log + 1.

Returns:
The next version of the job. If an error occurs -1 is returned.

getLastPhaseBeforeBackup

public Phase getLastPhaseBeforeBackup()
Gets the last phase before the backup phase. The job is assumed to be at the backup phase when this method is called.

Returns:
The Phase before backup or null.

getLastData

public OperationInfo getLastData()
Gets the last data, the TransactionLog row to which the job points, of the job.

Returns:
An OperationInfo instance whose result is a TransactionLog row.

getLastFinishedInfo

public OperationInfo getLastFinishedInfo()
Gets the TransactionLog entry that corresponds to the last finished status of the job.

Returns:
An OperationInfo instance whose result is a TransactionLog row.

getLastFinishedInfoForPhase

public OperationInfo getLastFinishedInfoForPhase(int phaseID)
Gets the last finished information for the given phase.

Parameters:
phaseID - The ID of the phase to get its information, which is a TransactionLog entry.
Returns:
An OperationInfo instance whose result is a TransactionLog row.

canChangeType

public boolean canChangeType(int oldOrNew)
Determines whether the given job can change its type or not.

Parameters:
oldOrNew - Whether the job is in the OldTransactionLog or the TransactionLog.
Returns:
True if the job can change its type otherwise false.

preAssign

public OperationInfo preAssign(int user,
                               int phase)
Pre-Assign the specified phase for this Job to the given User.

Parameters:
user - The User ID to assign for.
phase - The Phase to Assign on.
Returns:
The transaction Log entry added.

assignFromScratch

public OperationInfo assignFromScratch(int user,
                                       int phase,
                                       java.lang.String comment)
Assign the job from scratch.

Parameters:
user - The user to whom the job will be assigned.
phase - The phase to which the job will be assigned.
comment - The comment.
Returns:
An OperationInfo instance whose valid result contians the TransactionLog entry added.

assign

public OperationInfo assign(int user,
                            int phase,
                            java.lang.String comment)
Assign the specified phase for this Job to the given User.

Parameters:
user - The User ID to assign for.
phase - The Phase to Assign on.
comment - The comment.
Returns:
An OperationInfo instance whose valid result contians the TransactionLog entry added.

assignRestricetd

public OperationInfo assignRestricetd(int user,
                                      int phase)
Assign the specified phase for this Job to the given User.

Parameters:
user - The User ID to assign for.
phase - The Phase to Assign on.
Returns:
An OperationInfo instance whose valid result contians the TransactionLog entry added.

assignInDatabase

private OperationInfo assignInDatabase(java.lang.String spName,
                                       int user,
                                       int phase,
                                       java.lang.String comment,
                                       boolean ignorePropagationErrors)
Assign the job.

Parameters:
spName - The name of the stord procedure to call.
user - The user to assign the job to
phase - The phase to assign the job to.
comment - The comment.
ignorePropagationErrors - Ignore any error that might happen while propagating FileLevelInfo.
Errors might be inability to query the database or parse the retrieved data.
Returns:
An OperationInfo instance whose valid result contians the TransactionLog entry added.

canUpload

public boolean canUpload()
Determines if the job can be uploaded or not.

Returns:
True if the job can be uplaoded, otherwise false.

upload

public boolean upload(WorkStation workstation,
                      User user)
Uploads the job.

Parameters:
workstation - The workstation from which the job will uploaded.
user - The user who is uploading the job.
Returns:
True if the job has been uploaded successfully, otherwise false.

uploadInDatabase

public OperationInfo uploadInDatabase(int phaseID,
                                      int noOfFiles)
Sets the job state to upload in the database.

Parameters:
phaseID - The ID of the phase.
noOfFiles - The number of files to upload.
Returns:
An OperationInfo whose result is the row that has been inserted for the job in the TransactionLog.

canDownload

public boolean canDownload()
Determines if the job can be downloaded or not.

Returns:
True if the job can be downloaded, otherwise false.

download

public boolean download(WorkStation workstation,
                        User user)
Downloads the job.

Parameters:
workstation - The workstation to which the job will downloaded.
user - The user who is downloading the job.
Returns:
true if the job has been dowloaded successfully otherwise false.

downloadInDatabase

public OperationInfo downloadInDatabase(int phaseID,
                                        int noOfFiles)
Sets the job state to download in the database.

Parameters:
phaseID - The ID of the phase.
noOfFiles - The number of files to download.
Returns:
An OperationInfo whose result is the row that has been inserted for the job in the TransactionLog.

getStartingPhase

public Phase getStartingPhase()
Gets the phase in which the job will strat.
If the job points to an assign entry then the phase in this entry is considered the satrting phase.
If the job doesn't point to an assign entry then the phase next to the phase in this entry is considered the starting phase.

Returns:
The phase in which the job will start, or null.

canStart

public boolean canStart(int userID,
                        int wrkstID,
                        int phaseID)
Determines whether the job can start or not.

Parameters:
userID - The ID of the user who is starting the job.
wrkstID - The ID of the workstation on which the job is to be started.
phaseID - The ID of the phase to start the job in.
Returns:
True if the job can start otherwise false.

start

public boolean start(WorkStation workstation,
                     User user)
Starts the job.

Parameters:
workstation - The workstation on which the job will start.
user - The user who is starting the job.
Returns:
True if the job has been started successfully otherwise false.

startInDatabase

public OperationInfo startInDatabase(int userID,
                                     int phaseID,
                                     int workstationID,
                                     java.lang.String statusData)
Sets the job state to start in the database.

Parameters:
userID - The ID of the user who is starting the job
phaseID - The ID of the phase in which the job is starting.
workstationID - The ID of the workstation on which the job is started.
statusData - The status data.
Returns:
An OperationInfo instance that returns the row that has been inserted for the job in the TransactionLog.

canFinish

public boolean canFinish(int workstationID)
Determines whether the job can finish from the given workstation or not.

Parameters:
workstationID - The ID of the workstation from which the job is to be finished.
Returns:
True if the job can finsih otherwise false.

finish

public boolean finish(User user,
                      WorkStation workstation,
                      boolean fromCommandLine)
Finishes the job.

Parameters:
user - The user who is finishing the job.
workstation - The workstation form which the job is being finished.
fromCommandLine - Whether the job is being finished from the command line or not. If true the ToDo FileLevelInfo will be set to true without the user interaction.
Returns:
True if the job has been finished successfully otherwise false.

finishInDatabase

public OperationInfo finishInDatabase(int userID,
                                      int workstationID,
                                      int noOfFiles,
                                      java.lang.String statusData)
Sets the job state to finish in the database.

Parameters:
userID - The ID of the user who is finishing the job
workstationID - The ID of the workstation from which the job is finished.
noOfFiles - The number of files created/changed by the user.
statusData - The status data.
Returns:
An OperationInfo instance that returns the row that has been inserted for the job in the TransactionLog.

redirect

public boolean redirect(User user,
                        WorkStation workstation,
                        int nextUser,
                        int nextPhase,
                        java.lang.String comment)
Redirects the job.

Parameters:
user - The user who is redirecting the job.
workstation - The workstation form which the job is being redirected.
nextUser - The ID of the suggested user.
nextPhase - The ID of the suggested phase.
comment - The reason the job is to be redirected.
Returns:
True if the job has been redirected successfully otherwise false.

redirectInDatabase

public OperationInfo redirectInDatabase(int userID,
                                        int phaseID,
                                        int noOfFiles,
                                        int workstationID,
                                        int nextUserID,
                                        int nextPhaseID,
                                        java.lang.String finishStatusData,
                                        java.lang.String redirectStatusData,
                                        java.lang.String assignStatusData)
Sets the job state to redirect in the database.
The stored procedure does the following:
1) Adds a finish entry for the job.
2) Adds the redirect entry for the job.
3) Adds an assign entry if the job has the right to do so.

Parameters:
userID - The ID of the user who is redircting the job.
phaseID - The ID of the phase the job is finishing.
noOfFiles - The number of files modified when the job was finihsed.
workstationID - The ID of the workstation from which the job is redirected.
nextUserID - The ID of the user to whom the job is redircted.
nextPhaseID - The ID of the phase to which the job is redirected.
finishStatusData - The status data for the finish entry.
redirectStatusData - The status data for the redirect entry.
assignStatusData - The status data for the assign entry.
Returns:
An OperationInfo instance that returns the row that has been inserted for the job in the TransactionLog.

reject

public boolean reject(User user,
                      WorkStation workstation,
                      User nextUser,
                      Phase nextPhase,
                      java.lang.String comment)
Rejects the job.

Parameters:
user - The User who is rejecting the job.
workstation - The workstation from which the job is being rejected.
nextUser - The User entity representing the suggested user.
nextPhase - The Phase entity representing the suggested phase.
comment - The reason the job is to be redirected.
Returns:
True if the job status in the database has changed to rejected.

rejectForced

public boolean rejectForced(User user,
                            WorkStation workstation,
                            User nextUser,
                            Phase nextPhase,
                            java.lang.String comment)
Rejects the job by froce.

Parameters:
user - The User who is rejecting the job.
workstation - The workstation from which the job is being rejected.
nextUser - The User entity representing the suggested user.
nextPhase - The Phase entity representing the suggested phase.
comment - The reason the job is to be redirected.
Returns:
True if the job status in the database has changed to rejected.

rejectInDatabase

public OperationInfo rejectInDatabase(int nextPhaseID,
                                      int nextUserID,
                                      int workstationID,
                                      int noOfFiles,
                                      java.lang.String rejectStatusData,
                                      java.lang.String assignStatusData,
                                      boolean forced)
Sets the job state to reject in the database.
The stored procedure does the following:
1) Adds the reject entry for the job.
2) Adds an assign entry if the job has the right to do so.

Parameters:
nextPhaseID - The ID of the phase to which the job is redirected.
nextUserID - The ID of the user to whom the job is redircted.
workstationID - The ID of the workstation from which the job is redirected.
noOfFiles - The number of files.
rejectStatusData - The status data for the reject entry.
assignStatusData - The status data for the assign entry.
forced - Determines which stored procedure to be called. If true Job_RejectForced is called otherwise Job_Reject is called.
Returns:
An OperationInfo instance that returns the row that has been inserted for the job in the TransactionLog.

getMinPhase

public int getMinPhase(int minPhaseID,
                       Phase currentPahse)
Gets the ID of the phase with the minimum sequence.

Parameters:
minPhaseID - The ID of the phase that is candidate to be a minmum phase. -1 indicates that there is no minimum phase.
currentPahse - The current phase.
Returns:
If the misPhaseID = -1 then the ID of the next phase is returned if the job has visited it earlier. Otherwise the phase ID with the minimum sequence is returned.

isRephase

public boolean isRephase(int phaseID)
Determines whether the job has started in the given phase at least once.

Parameters:
phaseID - The phase ID.
Returns:
True if the job has started in the given phase at least once, otherwise false.

getLocalPath

public java.lang.String getLocalPath(WorkStation workstation,
                                     User user)
Gets the job path at the workstation not including the job name. To get the full job path append job.Path to the result of this method.

Parameters:
workstation - The workstation at which the job reside.
user - The user holding the job.
Returns:
The parent path of the job at the given workstation. For a job named "job name" this method will return "d:\\user data\\user name\\My Jobs".

deleteLocalFolder

public boolean deleteLocalFolder(WorkStation workstation,
                                 User user)
Deletes the job folder located at the given workstation.
Notes:
1) The folder is deleted using a FileHandlerLocalImpl
2) Failure to delete the job folder will be logged to the LogManager.

Parameters:
workstation - The workstation at which the job resides.
user - The user logged on to the machine.
Returns:
True if the job folder has been deleted, otherwise false.

deleteRemoteFolder

public boolean deleteRemoteFolder()
Deletes the job folder located at the server.
Notes:
1) The folder is deleted using a FileHandlerFTPImpl
2) Failure to delete the job folder will be logged to the LogManager.

Returns:
True if the job folder has been deleted, otherwise false.

deleteBackupFolder

public boolean deleteBackupFolder()
Deletes the job version folder(s) located at the backup server.
Notes:
1) All the job versions are deleted from the backup server.
2) If a version folder couldn't be deleted, the error is logged and the program continues and attempts to delete the next next version, if any, and so on.

Returns:
True if the all the job version folders have been deleted, otherwise false.

getFTPFileHandler

public FileHandlerFTPImpl getFTPFileHandler()
Gets the FileHandlerFTPImpl used to manipulate the job folder at the server. The server information to connect to is obtained by through the use of 'storageID'

Returns:
A FileHandlerFTPImpl instance or null if such instance couldn't be created.

getServerPath

public java.lang.String getServerPath()
Gets the job path at the server not including the job name. To get the full job path append job.Path to the result of this method.

Returns:
The parent path of the job at the storage server. For a job named "job name" this method will return "./Collection".
If the database couldn't be queried, null is returned.

getPhase

public Phase getPhase()
Gets the current phase of the job. The phase is obtained from the last transacton log entry of the job.

Returns:
The phase of the job or null if the database couldn't be queried.

getStartDate

public java.util.Date getStartDate()
Gets the start date of the job. The start date is obtained from the last transacton log entry of the job.

Returns:
The start date of the job or null if the database couldn't be queried.

getJobOldOrNewState

public Job.JobOldOrNew getJobOldOrNewState()
Retrieves wether this Job is Checked-Out or still in the System.

Returns:
A JobOldOrNew determinig the state of the Job, or null.
See Also:
Job.JobOldOrNew

getTextualValues

private void getTextualValues()
Retrieves the textual values for this job. like Collection name, Language name, Batch name, Job Type name and External ID Type name.


getCollectionName

public java.lang.String getCollectionName()
Retrieves the Collection Name for this Job.

Returns:
Collection Name

getLanguageName

public java.lang.String getLanguageName()
Retrieves the Language Name for this Job.

Returns:
Language Name.

getExternalIDTypeName

public java.lang.String getExternalIDTypeName()
Retrieves the External ID Type name for this job.

Returns:
External ID Type Name for this job.

getBatchName

public java.lang.String getBatchName()
Retrieves the Batch name for this job.

Returns:
Batch name for this job.

getJobTypeName

public java.lang.String getJobTypeName()
Retrieves the Batch name for this job.

Returns:
Batch name for this job.