org.bibalex.daf.entities.job
Class FinishingState

java.lang.Object
  extended by org.bibalex.daf.entities.job.JobState
      extended by org.bibalex.daf.entities.job.FinishingState

public class FinishingState
extends JobState

This class contains the logic necessary to finish the job. Calling makeTransition method will cause the job to be finished.

Author:
Shehab.Kamal

Field Summary
private static int BACKUP_PHASE_ID
           
private  Phase currentPhase
           
private  java.lang.String destination
           
private  java.lang.String errorMessage
           
private  boolean fromCommandLine
           
private  FileHandler ftpHandler
           
private  TransitionInfo info
           
private  Job job
           
private static int QUICK_BACKUP_PHASE_ID
          Holds the ID of the backup phase.
private  java.lang.String source
           
private  User user
           
private  WorkStation workstation
           
 
Constructor Summary
FinishingState(Job job, User user, WorkStation workstation, boolean fromCommandLine)
          Creates a new instance of FinishingState.
 
Method Summary
private  void canFinish_FileLevelInfo(java.util.ArrayList<FileLevelInfo> todoInfo, java.util.ArrayList<FileLevelInfo> nextInfo, int phaseID)
          Determines whether the user can finish the job because of the FileLevelInfo or not
A job cannot be finsihed in the following 2 cases:
1) There exist entries in the 'Next' FileLeveloInfo file.
 java.lang.String getErrorMessage()
          This method gets the mesage that is to be displaed to the user
 java.lang.String getName()
          Gets the name of the state.
 int getNoOfFiles()
          Gets the number of files required to be transferred in order to finish the job.
 boolean makeTransition()
          Finishes the job.
private  void updateFileLevelInfo(java.util.ArrayList<FileLevelInfo> todoFileLevelInfo, Phase currentPhase)
          Updates the FileLevelInfo after finishing the phase.
Entries that point to the this phase will be updated to point to the next phase if it has been revisited before.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QUICK_BACKUP_PHASE_ID

private static int QUICK_BACKUP_PHASE_ID
Holds the ID of the backup phase.


BACKUP_PHASE_ID

private static int BACKUP_PHASE_ID

job

private Job job

user

private User user

workstation

private WorkStation workstation

info

private TransitionInfo info

currentPhase

private Phase currentPhase

ftpHandler

private FileHandler ftpHandler

source

private java.lang.String source

destination

private java.lang.String destination

fromCommandLine

private boolean fromCommandLine

errorMessage

private java.lang.String errorMessage
Constructor Detail

FinishingState

public FinishingState(Job job,
                      User user,
                      WorkStation workstation,
                      boolean fromCommandLine)
               throws java.lang.Exception
Creates a new instance of FinishingState.

Parameters:
job - The job to finish.
user - The user who is finishing the job.
workstation - The workstation form which the job is being finished.
fromCommandLine - Whether the job is beuing finsihed from the command line or not.
If true the ToDo FileLevelInfo will be set to true without the user interaction.
Throws:
java.lang.Exception - If the information necessary to finish the job cannot be obtained.
Method Detail

getName

public java.lang.String getName()
Gets the name of the state.

Specified by:
getName in class JobState
Returns:
The name of the state.

getNoOfFiles

public int getNoOfFiles()
Gets the number of files required to be transferred in order to finish the job.

Specified by:
getNoOfFiles in class JobState
Returns:
The number of files to finish the job.

makeTransition

public boolean makeTransition()
Finishes the job. In order to finish a job the following actions take place: 0) Make sure that the job is eligable to be finihsed. 1) Perform the post-phase checks. 2) Perform the post-phase actions. 3) Collect the necessary information in order to finish the job (NoOfFiles & PhaseData) 4) Adjust the job status in the database by calling Job_Finish.

Specified by:
makeTransition in class JobState
Returns:
True if the job has been finished successfully otherwise false.

canFinish_FileLevelInfo

private void canFinish_FileLevelInfo(java.util.ArrayList<FileLevelInfo> todoInfo,
                                     java.util.ArrayList<FileLevelInfo> nextInfo,
                                     int phaseID)
                              throws java.lang.Exception
Determines whether the user can finish the job because of the FileLevelInfo or not
A job cannot be finsihed in the following 2 cases:
1) There exist entries in the 'Next' FileLeveloInfo file. In this case it should be redirected.
2) There exist undone entries in the 'ToDo' FileLeveloInfo file. The user should 'Done' all the entries.

Parameters:
todoInfo - The 'ToDo' FileLevelInfo.
nextInfo - The 'Next' FileLevelInfo.
phaseID - The current phase ID.
Throws:
java.lang.Exception - If the user cannot finish the job.

updateFileLevelInfo

private void updateFileLevelInfo(java.util.ArrayList<FileLevelInfo> todoFileLevelInfo,
                                 Phase currentPhase)
                          throws java.lang.Exception
Updates the FileLevelInfo after finishing the phase.
Entries that point to the this phase will be updated to point to the next phase if it has been revisited before.

Parameters:
todoFileLevelInfo - The FileLevelInfo to update.
currentPhase - The current phase of the job.
Throws:
java.lang.Exception - If the next phase couldn't be obtained.

getErrorMessage

public java.lang.String getErrorMessage()
Description copied from class: JobState
This method gets the mesage that is to be displaed to the user

Specified by:
getErrorMessage in class JobState
Returns:
The error message to be dispalayed to the user