edu.wpi.prc.server.transitioner
Class RemoteTransitionerRPCHandler

java.lang.Object
  extended by edu.wpi.prc.server.transitioner.RemoteTransitionerRPCHandler

public class RemoteTransitionerRPCHandler
extends java.lang.Object

Handles XML-RPC calls for the RemoteTransitioner.

Author:
James Baldassari

Field Summary
private  RemoteTransitioner transitioner
           
 
Constructor Summary
RemoteTransitionerRPCHandler(RemoteTransitioner transitioner)
          Contructor that takes a reference to the remote transition that created this RPC handler.
 
Method Summary
 boolean addIngressResult(java.lang.String taskID)
          Enqueues a result in the ingress result queue.
 boolean addIngressWorkUnit(java.lang.String taskID)
          Enqueues a work unit in the ingress work queue.
 java.util.Vector getAssociatedIngressResults(java.lang.String taskID)
          Finds all ingress Results associated with a given WorkUnit.
 java.util.Vector getAssociatedPendingResults(java.lang.String taskID)
          Finds all pending Results associated with a given WorkUnit.
 java.util.Vector getCanonicalWorkQueue()
           
 java.lang.String getCanonicalWorkUnit()
          Gets the first work unit that has enough Results.
 java.util.Vector getIngressResultQueue()
           
 java.util.Vector getIngressWorkQueue()
           
 java.util.Vector getPendingResultQueue()
           
 java.util.Vector getPendingWorkQueue()
           
 java.lang.String getResult()
          Gets the first result that needs to be validated.
 java.util.Vector getRetiredWorkQueue()
           
 java.util.Vector getValidResultQueue()
           
 java.lang.String getWorkUnit(java.lang.String userID, java.lang.String eMailAddr)
          Gets the next work unit to be processed.
 boolean markResultInvalid(java.lang.String taskID)
          Marks a result as invalid.
 boolean markResultValid(java.lang.String taskID)
          Marks a Result as valid.
 boolean selectCanonicalResult(java.lang.String taskID)
          Designates a canonical Result by removing all related results from the ingress and pending queues, adding the canonical result to the valid queue, and retiring the canonical result's work unit.
 boolean shutdown(java.lang.String password)
          Performs any necessary tasks to safely shut down the Transitioner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transitioner

private RemoteTransitioner transitioner
Constructor Detail

RemoteTransitionerRPCHandler

public RemoteTransitionerRPCHandler(RemoteTransitioner transitioner)
Contructor that takes a reference to the remote transition that created this RPC handler.

Parameters:
transitioner - The RemoteTransitioner object that instantiated the instance of this class.
Method Detail

getIngressWorkQueue

public java.util.Vector getIngressWorkQueue()
Returns:
Returns the ingress work queue.

getPendingWorkQueue

public java.util.Vector getPendingWorkQueue()
Returns:
Returns the pending work queue.

getCanonicalWorkQueue

public java.util.Vector getCanonicalWorkQueue()
Returns:
Returns the work units that have enough results to select a canonical result.

getRetiredWorkQueue

public java.util.Vector getRetiredWorkQueue()
Returns:
Returns the retired work queue.

getIngressResultQueue

public java.util.Vector getIngressResultQueue()
Returns:
Returns the ingress result queue.

getPendingResultQueue

public java.util.Vector getPendingResultQueue()
Returns:
Returns the pending result queue.

getValidResultQueue

public java.util.Vector getValidResultQueue()
Returns:
Returns the valid result queue.

addIngressWorkUnit

public boolean addIngressWorkUnit(java.lang.String taskID)
Enqueues a work unit in the ingress work queue. NOTE: work unit state MUST be set to TaskState.Ingress before calling this method.

Parameters:
taskID - The task ID of the work unit to add.

addIngressResult

public boolean addIngressResult(java.lang.String taskID)
Enqueues a result in the ingress result queue. NOTE: result state MUST be set to TaskState.Ingress before calling this method.

Parameters:
taskID - The task ID of the result to add.

getAssociatedIngressResults

public java.util.Vector getAssociatedIngressResults(java.lang.String taskID)
Finds all ingress Results associated with a given WorkUnit.

Parameters:
taskID - The task ID of the WorkUnit for which to find all associated ingress Results.
Returns:
Vector of ingress Results associated with the given WorkUnit or a Vector of length 0 if none were found.

getAssociatedPendingResults

public java.util.Vector getAssociatedPendingResults(java.lang.String taskID)
Finds all pending Results associated with a given WorkUnit.

Parameters:
taskID - The task ID of the WorkUnit for which to find all associated pending Results.
Returns:
Vector of pending Results associated with the given WorkUnit or an Vector of length 0 if none were found.

getWorkUnit

public java.lang.String getWorkUnit(java.lang.String userID,
                                    java.lang.String eMailAddr)
                             throws EmptyQueueException
Gets the next work unit to be processed. First, it will try to find a work unit in the pending work queue that has not already been sent to the given volunteer. If there are no satisfiable work units in the pending work queue, it will try to return a work unit from the ingress work queue. If there are no work units in the ingress work queue, an EmptyQueueException will be thrown.

Parameters:
userID - The user ID of the volunteer who will receive it.
eMailAddr - The e-mail address of the volunteer who will receive it.
Returns:
The task ID of the next work unit to be processed.
Throws:
EmptyQueueException

getCanonicalWorkUnit

public java.lang.String getCanonicalWorkUnit()
                                      throws EmptyQueueException
Gets the first work unit that has enough Results.

Returns:
The first work unit in the canonical work queue.
Throws:
EmptyQueueException

getResult

public java.lang.String getResult()
                           throws EmptyQueueException
Gets the first result that needs to be validated.

Returns:
The first result in the ingress queue.
Throws:
EmptyQueueException

markResultValid

public boolean markResultValid(java.lang.String taskID)
Marks a Result as valid. If the minimum number of valid results for the Result's associated WorkUnit, the Result is moved from the ingress result queue to the pending result queue. If the minimum number of valid results for the Result's associated WorkUnit has been reached, all Results for that WorkUnit are removed from the pending result queue, a canonical result is chosen, and the canonical result is moved to the valid result queue.

Parameters:
taskID - The task ID of the result from the ingress result queue to be marked valid.

markResultInvalid

public boolean markResultInvalid(java.lang.String taskID)
Marks a result as invalid. This will remove the result from the ingress queue and delete it from the database. If the result is a spot check result, additional steps may be taken depending on the project's spot check failure action.

Parameters:
taskID - The task ID of the result to be marked invalid.

selectCanonicalResult

public boolean selectCanonicalResult(java.lang.String taskID)
Designates a canonical Result by removing all related results from the ingress and pending queues, adding the canonical result to the valid queue, and retiring the canonical result's work unit.

Parameters:
taskID - The task ID of the canonical result to select.

shutdown

public boolean shutdown(java.lang.String password)
                 throws InvalidPasswordException
Performs any necessary tasks to safely shut down the Transitioner.

Throws:
InvalidPasswordException