easik.sketch.util.Export.Constraints
Class ExportTriggerFormatter

java.lang.Object
  extended by easik.sketch.util.Export.Constraints.ExportTriggerFormatter

public class ExportTriggerFormatter
extends java.lang.Object

A class to format all triggers for SQL exportation. There are three different types of triggers which are created: insert, update, and delete triggers.

Since:
2006-06-16 Vera Ranieri
Version:
2006-07-13 Vera Ranieri
Author:
Vera Ranieri 2006

Field Summary
private  java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> _afterInsertProcedures
          Hash map of all after insert procedures, indexed by the table to which they apply
private  java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> _beforeDeleteProcedures
          Hash map of all before delete procedures, indexed by the table to which they apply
private  java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> _beforeInsertProcedures
          Hash map of all before insert procedures, indexed by the table to which they apply
private  java.util.ArrayList<java.lang.String> _triggerStrings
          List of all trigger strings formatted for SQL
static java.lang.String AFTER_INSERT_TIME
          SQL statement to set trigger to activate after insert
static java.lang.String BEFORE_DELETE_TIME
          SQL statement to set trigger to activate before delete
static java.lang.String BEFORE_INSERT_TIME
          SQL statement to set trigger to activate before insert
 
Constructor Summary
ExportTriggerFormatter()
          Constructor.
 
Method Summary
private  void addTimeTrigger(java.lang.String time, java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> triggers, ExportConstraint c)
          Records constraint to be activated at the given time.
 void addTrigger(ExportConstraint con)
          Adds information about the requirement for a trigger.
 java.util.ArrayList<java.lang.String> getAllTriggers()
          Returns an arraylist of all trigger strings.
private  void setTimeTriggers(java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> triggers, java.lang.String name, java.lang.String time, java.lang.String procVar)
          Sets all triggers based on the time passed as a parameter
 void setTriggers()
          Sets all triggers by determining all procedures that must be called from inside a each respective trigger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEFORE_INSERT_TIME

public static final java.lang.String BEFORE_INSERT_TIME
SQL statement to set trigger to activate before insert

See Also:
Constant Field Values

AFTER_INSERT_TIME

public static final java.lang.String AFTER_INSERT_TIME
SQL statement to set trigger to activate after insert

See Also:
Constant Field Values

BEFORE_DELETE_TIME

public static final java.lang.String BEFORE_DELETE_TIME
SQL statement to set trigger to activate before delete

See Also:
Constant Field Values

_beforeInsertProcedures

private java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> _beforeInsertProcedures
Hash map of all before insert procedures, indexed by the table to which they apply


_afterInsertProcedures

private java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> _afterInsertProcedures
Hash map of all after insert procedures, indexed by the table to which they apply


_beforeDeleteProcedures

private java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> _beforeDeleteProcedures
Hash map of all before delete procedures, indexed by the table to which they apply


_triggerStrings

private java.util.ArrayList<java.lang.String> _triggerStrings
List of all trigger strings formatted for SQL

Constructor Detail

ExportTriggerFormatter

public ExportTriggerFormatter()
Constructor. Initialises all fields so new triggers can be added.

Method Detail

setTriggers

public void setTriggers()
Sets all triggers by determining all procedures that must be called from inside a each respective trigger.


addTrigger

public void addTrigger(ExportConstraint con)
Adds information about the requirement for a trigger. This information is added to a Hashmap that is indexed by the name of the table on which the trigger must be called. The type of trigger needed to be added is determined by the type of constraint being added.

Parameters:
con - The constraint for which a trigger must be enforced.

getAllTriggers

public java.util.ArrayList<java.lang.String> getAllTriggers()
Returns an arraylist of all trigger strings. These strings are formatted for SQL.

Returns:
An arraylist of all trigger strings for the schema.

addTimeTrigger

private void addTimeTrigger(java.lang.String time,
                            java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> triggers,
                            ExportConstraint c)
Records constraint to be activated at the given time. Constraints are stored in a Hashmap indexed by the name of the table to which the constraint applies. This is done so all constraints can be enforced within one trigger.

Parameters:
time - The time at which the constraint should be enforced
triggers - The current hash map of triggers, specific for that time.
c - The constraint to be added to the hash map of triggers
Since:
2006-07-07 Vera Ranieri

setTimeTriggers

private void setTimeTriggers(java.util.HashMap<java.lang.String,java.util.LinkedList<ExportConstraint>> triggers,
                             java.lang.String name,
                             java.lang.String time,
                             java.lang.String procVar)
Sets all triggers based on the time passed as a parameter

Parameters:
triggers - The triggers which need to be set
name - The unique name of the trigger
time - The time at which the trigger is to be called
procVar - The variables which must be passed when formatting the call string.
Since:
2006-07-05 Vera Ranieri