uws.job
Class JobPhase

java.lang.Object
  extended by uws.job.JobPhase
All Implemented Interfaces:
java.io.Serializable

public class JobPhase
extends java.lang.Object
implements java.io.Serializable

An instance of this class represents the current execution phase of a given job, and it describes the transitions between the different phases.

Version:
02/2011
Author:
Grégory Mantelet (CDS)
See Also:
ExecutionPhase, AbstractJob, Serialized Form

Field Summary
protected  AbstractJob job
          The job whose the current phase is represented by this class.
protected  ExecutionPhase phase
          Current phase of the associated job.
 
Constructor Summary
JobPhase(AbstractJob j)
          Builds the phase manager of the given job.
 
Method Summary
 AbstractJob getJob()
          Gets the job whose the execution phase is represented by this object.
 ExecutionPhase getPhase()
          Gets the current phase of the job.
 boolean isExecuting()
          Indicates whether the job is executing, considering its current phase.
 boolean isFinished()
          Indicates whether the job is finished or not, considering its current phase.
 boolean isJobUpdatable()
          Indicates whether the job attributes (except errors and results) can be updated, considering its current phase.
protected  void setAbortedPhase(boolean force)
          Changes the current phase to ABORTED.
protected  void setCompletedPhase(boolean force)
          Changes the current phase to COMPLETED.
protected  void setErrorPhase(boolean force)
          Changes the current phase to ERROR.
protected  void setExecutingPhase(boolean force)
          Changes the current phase to EXECUTING.
protected  void setHeldPhase(boolean force)
          Changes the current phase to HELD.
protected  void setPendingPhase(boolean force)
          Changes the current phase to PENDING.
 void setPhase(ExecutionPhase p)
          Lets changing the current phase of the associated job considering the order of execution phases.
 void setPhase(ExecutionPhase p, boolean force)
          Lets changing the current phase of the associated job considering or not the order of execution phases.
protected  void setQueuedPhase(boolean force)
          Changes the current phase to QUEUED.
protected  void setSuspendedPhase(boolean force)
          Changes the current phase to SUSPENDED.
protected  void setUnknownPhase(boolean force)
          Changes the current phase to UNKNOWN.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

phase

protected ExecutionPhase phase
Current phase of the associated job.


job

protected final AbstractJob job
The job whose the current phase is represented by this class.

Constructor Detail

JobPhase

public JobPhase(AbstractJob j)
         throws UWSException
Builds the phase manager of the given job.

Parameters:
j - The job whose the execution phase must be represented by the built JobPhase instance.
Throws:
UWSException - If the given job is null.
Method Detail

getJob

public final AbstractJob getJob()
Gets the job whose the execution phase is represented by this object.

Returns:
The associated job.

getPhase

public final ExecutionPhase getPhase()
Gets the current phase of the job.

Returns:
The current job phase.

setPhase

public final void setPhase(ExecutionPhase p)
                    throws UWSException
Lets changing the current phase of the associated job considering the order of execution phases.

Parameters:
p - The new execution phase.
Throws:
UWSException - If the given phase is null or if the phase transition is forbidden.
See Also:
setPhase(ExecutionPhase, boolean)

setPhase

public void setPhase(ExecutionPhase p,
                     boolean force)
              throws UWSException
Lets changing the current phase of the associated job considering or not the order of execution phases.

Parameters:
p - The new phase.
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If the given phase is null or if the phase transition is forbidden.
See Also:
setPendingPhase(boolean), setQueuedPhase(boolean), setExecutingPhase(boolean), setCompletedPhase(boolean), setAbortedPhase(boolean), setErrorPhase(boolean), setHeldPhase(boolean), setSuspendedPhase(boolean), setUnknownPhase(boolean)

setPendingPhase

protected void setPendingPhase(boolean force)
                        throws UWSException
Changes the current phase to PENDING.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If this phase transition is forbidden (by default: IF force=false AND currentPhase != PENDING or UNKNOWN).

setQueuedPhase

protected void setQueuedPhase(boolean force)
                       throws UWSException
Changes the current phase to QUEUED.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If this phase transition is forbidden (by default: IF force=false AND currentPhase != QUEUED or HELD or PENDING or UNKNOWN).

setExecutingPhase

protected void setExecutingPhase(boolean force)
                          throws UWSException
Changes the current phase to EXECUTING.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If this phase transition is forbidden (by default: IF force=false AND currentPhase != EXECUTING or SUSPENDED or QUEUED or UNKNOWN).

setCompletedPhase

protected void setCompletedPhase(boolean force)
                          throws UWSException
Changes the current phase to COMPLETED.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If this phase transition is forbidden (by default: IF force=false AND currentPhase != COMPLETED or EXECUTING or UNKNOWN).

setAbortedPhase

protected void setAbortedPhase(boolean force)
                        throws UWSException
Changes the current phase to ABORTED.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If this phase transition is forbidden (by default: IF force=false AND currentPhase = COMPLETED or ERROR).

setErrorPhase

protected void setErrorPhase(boolean force)
                      throws UWSException
Changes the current phase to ERROR.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If this phase transition is forbidden (by default: IF force=false AND currentPhase = COMPLETED or ABORTED).

setHeldPhase

protected void setHeldPhase(boolean force)
                     throws UWSException
Changes the current phase to HELD.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - If this phase transition is forbidden (by default: IF force=false AND currentPhase != HELD or PENDING or UNKNOWN).

setSuspendedPhase

protected void setSuspendedPhase(boolean force)
                          throws UWSException
Changes the current phase to SUSPENDED.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - By default, never !

setUnknownPhase

protected void setUnknownPhase(boolean force)
                        throws UWSException
Changes the current phase to UNKNOWN.

Parameters:
force - true to ignore the phases order, false otherwise.
Throws:
UWSException - By default, never !

isJobUpdatable

public boolean isJobUpdatable()

Indicates whether the job attributes (except errors and results) can be updated, considering its current phase.

Note: By default, it returns TRUE only if the current phase is equals to PENDING !

Returns:
true if the job can be updated, false otherwise.

isFinished

public boolean isFinished()

Indicates whether the job is finished or not, considering its current phase.

Note: By default, it returns TRUE only if the current phase is either COMPLETED, ABORTED or ERROR !

Returns:
true if the job is finished, false otherwise.

isExecuting

public boolean isExecuting()

Indicates whether the job is executing, considering its current phase.

Note: By default, it returns TRUE only if the current phase is EXECUTING !

Returns:
true if the job is executing, false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object