Dresden OCL Toolkit

tudresden.ocl.sql
Class TriggerGenerator

java.lang.Object
  extended bytudresden.ocl.sql.TriggerGenerator
All Implemented Interfaces:
SQLDirector

public class TriggerGenerator
extends Object
implements SQLDirector

A trigger generator that can generate trigger definitions, which can be used to evaluate integrity views. Two kinds of trigger definitions are possible. Trigger definitions which serve as SQL92-assertion-replacements and ECA-trigger-templates. The trigger templates must be further edited by the application developer. The trigger generator takes care for multiple tables which can be involved in one integrity view evaluation. Hence, the information about the involved tables must be provided to the generator. The generator then generates one trigger per involved table.

Author:
Sten Loecher
See Also:
SQLBuilder

Field Summary
static int ASSERTION_REPLACEMENT
           
static int ECA_TRIGGER_TEMPLATE
           
(package private)  int kindOfTrigger
           
(package private)  String theErrorMessage
           
(package private)  String[] theInvolvedTables
           
(package private)  String[] theResult
           
(package private)  SQLBuilder theSQLBuilder
           
(package private)  String theTriggerName
           
(package private)  String theViewName
           
 
Constructor Summary
TriggerGenerator(SQLBuilder sqlBuilder)
          Creates a new TriggerGenerator
 
Method Summary
 void construct()
          Does the construction of the SQL code.
private  String[] getAssertionReplacement()
           
 String[] getAssertionReplacement(String triggerName, String errorMsg, String viewName, String[] involvedTables)
           
 String getCode()
           
private  String[] getECATriggerTemplate()
           
 String[] getECATriggerTemplate(String triggerName, String viewName, String[] involvedTables)
           
 void setBuilder(SQLBuilder sqlb)
           
 void setErrorMsg(String msg)
          An error message that will be thrown from assertion replacement triggers.
 void setInvolvedTables(String[] tables)
          An array of table names that are involved in evaluating the related integrity view.
 void setKindOfTrigger(int kot)
           
 void setTriggerName(String name)
          The prefix of all trigger names.
 void setViewName(String name)
          The name of the integrity view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theTriggerName

String theTriggerName

theViewName

String theViewName

theErrorMessage

String theErrorMessage

theInvolvedTables

String[] theInvolvedTables

theResult

String[] theResult

theSQLBuilder

SQLBuilder theSQLBuilder

kindOfTrigger

int kindOfTrigger

ASSERTION_REPLACEMENT

public static int ASSERTION_REPLACEMENT

ECA_TRIGGER_TEMPLATE

public static int ECA_TRIGGER_TEMPLATE
Constructor Detail

TriggerGenerator

public TriggerGenerator(SQLBuilder sqlBuilder)
Creates a new TriggerGenerator

Method Detail

getAssertionReplacement

private String[] getAssertionReplacement()

getECATriggerTemplate

private String[] getECATriggerTemplate()

getAssertionReplacement

public String[] getAssertionReplacement(String triggerName,
                                        String errorMsg,
                                        String viewName,
                                        String[] involvedTables)
Parameters:
triggerName - the prefix of each trigger name, the actual trigger name will get further information appended
errorMsg - the error message that will be thrown by the triggers
viewName - the name of the integrity view
involvedTables - a list of involved tables
Returns:
a number of trigger definitions that can serve as an SQL92 assertion replacement (the number of trigger definitions is equal to the number of involved tables)

getECATriggerTemplate

public String[] getECATriggerTemplate(String triggerName,
                                      String viewName,
                                      String[] involvedTables)
Parameters:
triggerName - the prefix of each trigger name, the actual trigger name will get further information appended
viewName - the name of the integrity view
involvedTables - a list of involved tables
Returns:
a number of trigger definitions that can serve as ECA trigger templates (the number of trigger definitions is equal to the number of involved tables)

setTriggerName

public void setTriggerName(String name)
The prefix of all trigger names.


setViewName

public void setViewName(String name)
The name of the integrity view.


setErrorMsg

public void setErrorMsg(String msg)
An error message that will be thrown from assertion replacement triggers.


setInvolvedTables

public void setInvolvedTables(String[] tables)
An array of table names that are involved in evaluating the related integrity view.


setKindOfTrigger

public void setKindOfTrigger(int kot)

setBuilder

public void setBuilder(SQLBuilder sqlb)
Specified by:
setBuilder in interface SQLDirector
Parameters:
sqlb - a builder used by the director to build database specific code

construct

public void construct()
               throws IllegalStateException
Does the construction of the SQL code.

Specified by:
construct in interface SQLDirector
Throws:
IllegalStateException

getCode

public String getCode()
Specified by:
getCode in interface SQLDirector
Returns:
the resulting SQL code from the construction process

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.