org.sormula.operation.cascade
Class SelectCascadeOperation<S,T>

java.lang.Object
  extended by org.sormula.operation.cascade.CascadeOperation<S,T>
      extended by org.sormula.operation.cascade.SelectCascadeOperation<S,T>
Type Parameters:
S - row class of table that is source of cascade
T - row class of table that is target of cascade

public class SelectCascadeOperation<S,T>
extends CascadeOperation<S,T>

Cascade that selects rows from target table into target field when source operation initiates a cascade.

Author:
Jeff Miller

Constructor Summary
SelectCascadeOperation(SormulaField<S,?> targetField, Table<T> targetTable, SelectCascade selectCascadeAnnotation)
          Constructor used by SelectOperation.
 
Method Summary
 void cascade(S sourceRow)
          Performs cascade operation.
 void close()
          Cleans up by closing any JDBC resources.
 void prepare()
          Prepares operation by initializing JDBC statements.
protected  void prepareParameterFields()
          Uses reflection to get fields for each of the source class variables that will be read from source and set as parameters on cascade operation.
protected  void setParameters(S sourceRow)
          cascade(S) invokes this method to set parameters in cascade operation based upon parameter fields that were created by prepareParameterFields().
protected  T[] toTargetArray(java.util.Collection<T> c)
           
 
Methods inherited from class org.sormula.operation.cascade.CascadeOperation
createOperation, getTargetField, getTargetTable, isPost
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelectCascadeOperation

public SelectCascadeOperation(SormulaField<S,?> targetField,
                              Table<T> targetTable,
                              SelectCascade selectCascadeAnnotation)
Constructor used by SelectOperation.

Parameters:
targetField - cascade select operation modifies this field
targetTable - cascade select operation is performed on this table
selectCascadeAnnotation - cascade operation
Method Detail

cascade

public void cascade(S sourceRow)
             throws OperationException
Performs cascade operation.

Specified by:
cascade in class CascadeOperation<S,T>
Parameters:
sourceRow - row in parent table that was source the cascade
Throws:
OperationException - if error

prepare

public void prepare()
             throws OperationException
Prepares operation by initializing JDBC statements.

Specified by:
prepare in class CascadeOperation<S,T>
Throws:
OperationException - if error

prepareParameterFields

protected void prepareParameterFields()
                               throws OperationException
Uses reflection to get fields for each of the source class variables that will be read from source and set as parameters on cascade operation. Parameter values are set when setParameters(S) is invoked by cascade(S).

Throws:
OperationException - if error

setParameters

protected void setParameters(S sourceRow)
                      throws OperationException
cascade(S) invokes this method to set parameters in cascade operation based upon parameter fields that were created by prepareParameterFields(). Override for custom parameter initialization.

Parameters:
sourceRow - cascade source row
Throws:
OperationException

close

public void close()
           throws OperationException
Cleans up by closing any JDBC resources.

Specified by:
close in class CascadeOperation<S,T>
Throws:
OperationException - if error

toTargetArray

protected T[] toTargetArray(java.util.Collection<T> c)
                     throws OperationException
Throws:
OperationException