org.bibalex.daf.entities.job
Class RedirectingState

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

public class RedirectingState
extends JobState

This class contains the logic necessary to redirect the job. Calling makeTransition method will cause the job to be redirected.

Author:
Shehab.Kamal

Field Summary
private  java.lang.String comment
           
private  Phase currentPhase
           
private  java.lang.String destination
           
private  java.lang.String errorMessage
           
private  FileHandler ftpHandler
           
private  TransitionInfo info
           
private  Job job
           
private  int nextPhase
           
private  int nextUser
           
private  java.lang.String source
           
private  User user
           
private  WorkStation workstation
           
 
Constructor Summary
RedirectingState(Job job, User user, WorkStation workstation, int nextUser, int nextPhase, java.lang.String comment)
          Creates a new instance of RedirectingState.
 
Method Summary
 void canRedirect_FileLevelInfo(java.util.ArrayList<FileLevelInfo> todoInfo, java.util.ArrayList<FileLevelInfo> nextInfo, Phase currentPhase, int nextPhaseID)
          Determines whether the job can be redirected to the given phase because of the FileLevelInfo or not.
A Job can be redirected to the given phase, if it satisfies the following conditions:
1) All the ToDo entries that point to this phase are done.
2) The given phase is equal to or less than the minimum phase in the ToDo and Next FileLevelInfo.
 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 redirect the job.
 boolean makeTransition()
          Redirects the job.
private  void updateFileLevelInfo(java.util.ArrayList<FileLevelInfo> todoFileLevelInfo)
          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

job

private Job job

user

private User user

workstation

private WorkStation workstation

info

private TransitionInfo info

nextUser

private int nextUser

nextPhase

private int nextPhase

comment

private java.lang.String comment

currentPhase

private Phase currentPhase

ftpHandler

private FileHandler ftpHandler

source

private java.lang.String source

destination

private java.lang.String destination

errorMessage

private java.lang.String errorMessage
Constructor Detail

RedirectingState

public RedirectingState(Job job,
                        User user,
                        WorkStation workstation,
                        int nextUser,
                        int nextPhase,
                        java.lang.String comment)
                 throws java.lang.Exception
Creates a new instance of RedirectingState.

Parameters:
job - The job to redirect.
user - The user who is redirecting the job.
workstation - The workstation from which the job will be redirected.
nextUser - The ID of the suggested user.
nextPhase - The ID of the suggested phase.
comment - The reason the job is to be redirected.
Throws:
java.lang.Exception - If the information necessary to redirect 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 redirect the job.

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

makeTransition

public boolean makeTransition()
Redirects the job. In order to redirect a job the following actions take place: 1) Finish the job. 2) Adjust the job status in the database by calling Job_Redirect.

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

canRedirect_FileLevelInfo

public void canRedirect_FileLevelInfo(java.util.ArrayList<FileLevelInfo> todoInfo,
                                      java.util.ArrayList<FileLevelInfo> nextInfo,
                                      Phase currentPhase,
                                      int nextPhaseID)
                               throws java.lang.Exception
Determines whether the job can be redirected to the given phase because of the FileLevelInfo or not.
A Job can be redirected to the given phase, if it satisfies the following conditions:
1) All the ToDo entries that point to this phase are done.
2) The given phase is equal to or less than the minimum phase in the ToDo and Next FileLevelInfo.

Parameters:
todoInfo - An ArrayList holding the 'ToDo' FileLevelInfo.
nextInfo - An ArrayList holding the 'Next' FileLevelInfo.
currentPhase - The current phase of the job.
nextPhaseID - The suggested phase to redirect the job to.
Throws:
java.lang.Exception - if the job cannot be redirected from this phase to the given next phase.

updateFileLevelInfo

private void updateFileLevelInfo(java.util.ArrayList<FileLevelInfo> todoFileLevelInfo)
                          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.
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