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

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

public abstract class CascadeOperation<S,T>
extends java.lang.Object

Base class for all cascade operations.

Author:
Jeff Miller

Constructor Summary
CascadeOperation(SormulaField<S,?> targetField, Table<T> targetTable, java.lang.Class<?> cascadeOperationClass, boolean post)
          Constructs for field and table to be affected by cascade.
 
Method Summary
abstract  void cascade(S sourceRow)
          Performs cascade operation.
abstract  void close()
          Cleans up by closing any JDBC resources.
protected  SqlOperation<?> createOperation()
          Creates new instance of sql operation from cascadeOperationClass supplied in the constructor.
 SormulaField<S,?> getTargetField()
          Gets target field as SormulaField.
 Table<T> getTargetTable()
           
 boolean isPost()
           
abstract  void prepare()
          Prepares operation by initializing JDBC statements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CascadeOperation

public CascadeOperation(SormulaField<S,?> targetField,
                        Table<T> targetTable,
                        java.lang.Class<?> cascadeOperationClass,
                        boolean post)
Constructs for field and table to be affected by cascade.

Parameters:
targetField - in source row to be affected by cascade operation
targetTable - sorm table that will be cascaded
cascadeOperationClass - class of cascade operation (used to create new instance)
post - true if operation is to be performed after source row operation; false if operation is to be performed before source row operation
Method Detail

isPost

public boolean isPost()
Returns:
true if cascade is to be performed after select/execute; false if cascade is to be performed before select/execute

cascade

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

Parameters:
sourceRow - row in parent table that was source the cascade
Throws:
OperationException - if error

prepare

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

Throws:
OperationException - if error

close

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

Throws:
OperationException - if error

getTargetField

public SormulaField<S,?> getTargetField()
Gets target field as SormulaField.

Returns:
field in source row to be affected by cascade operation

getTargetTable

public Table<T> getTargetTable()
Returns:
table to be used in cascade

createOperation

protected SqlOperation<?> createOperation()
                                   throws OperationException
Creates new instance of sql operation from cascadeOperationClass supplied in the constructor.

Throws:
OperationException