org.bibalex.daf.entities.job
Class ChangingTypeState

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

public class ChangingTypeState
extends JobState

This class contains the logic necessary to change the type of the job. Calling makeTransition method will cause the job to have its type changed.

Author:
Shehab.Kamal

Field Summary
private  boolean assign
           
private  int assignJobTypeID
           
private  int assignPhaseID
           
private  int assignUserID
           
private  java.lang.String errorMessage
           
private  FileHandler ftpHandler
           
private  TransitionInfo info
           
private  Job job
           
private  boolean jobInWorkingDir
           
private  java.lang.String serverDir
           
private  User user
           
private  java.lang.String workingDir
           
private  WorkStation workstation
           
 
Constructor Summary
ChangingTypeState(Job job, User user, WorkStation workstation, boolean jobInWorkingDir, int assignJobTypeID, int assignPhaseID, int assignUserID, boolean assign)
          Creates a new instance of ChangingTypeState.
 
Method Summary
 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 change the type of the job.
 boolean makeTransition()
          Changes the type of the job.
In order to change the type of a job the following actions take place:
1) See if the job has the right to change its type or not (database wise).
2) Apply the phase checks on the job.
4) Make the following database modifications, as needed.
a) Update the job to change its type.
b) Move the job entries from the oldTransactionLog to the TransactionLog.
c) Add an assign entry for the job new phase and user.
5) Copies the job folder back to the production server.
 
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

workingDir

private java.lang.String workingDir

serverDir

private java.lang.String serverDir

ftpHandler

private FileHandler ftpHandler

assignJobTypeID

private int assignJobTypeID

assignPhaseID

private int assignPhaseID

assignUserID

private int assignUserID

jobInWorkingDir

private boolean jobInWorkingDir

assign

private boolean assign

errorMessage

private java.lang.String errorMessage
Constructor Detail

ChangingTypeState

public ChangingTypeState(Job job,
                         User user,
                         WorkStation workstation,
                         boolean jobInWorkingDir,
                         int assignJobTypeID,
                         int assignPhaseID,
                         int assignUserID,
                         boolean assign)
                  throws java.lang.Exception
Creates a new instance of ChangingTypeState.

Parameters:
job - The job to change its job type.
user - The user who is changing the type of the job.
workstation - The workstation from which the job will uploaded.
jobInWorkingDir - Whether the job is in the working directory or at the production server.
assignJobTypeID - The ID of the job type that will be the new type of the job.
assignPhaseID - The ID of the phase to which the job will be assigned. This parameter is used to apply the pre-phase checks on the job folder.
assignUserID - The ID of the user to whom the job will be assigned.
assign - Whether to add an assign entry for the job to the new phase and user.
Throws:
java.lang.Exception - If the information necessary to change the type of 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 change the type of the job.

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

makeTransition

public boolean makeTransition()
Changes the type of the job.
In order to change the type of a job the following actions take place:
1) See if the job has the right to change its type or not (database wise).
2) Apply the phase checks on the job.
4) Make the following database modifications, as needed.
a) Update the job to change its type.
b) Move the job entries from the oldTransactionLog to the TransactionLog.
c) Add an assign entry for the job new phase and user.
5) Copies the job folder back to the production server.

Specified by:
makeTransition in class JobState
Returns:
True if the job has its type changed successfully otherwise false.

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