com.serotonin.m2m2.module
Class DatabaseSchemaDefinition

java.lang.Object
  extended by com.serotonin.m2m2.module.ModuleElementDefinition
      extended by com.serotonin.m2m2.module.DatabaseSchemaDefinition

public abstract class DatabaseSchemaDefinition
extends ModuleElementDefinition

A database schema definition allows a module to create an manage database tables and other objects as necessary to perform its functionality. IMPORTANT: any tables with foreign keys into core tables MUST have an "on delete cascade" clause. FKs that reference non-PK fields MUST also have an "on update cascade" clause. Failure to do this will result in esoteric error messages presented to users, and the final blame for such being assigned to your module. Failure to fix such conditions will result in bad module karma, if not outright module removal.

Author:
Matthew Lohbihler

Constructor Summary
DatabaseSchemaDefinition()
           
 
Method Summary
abstract  void addConversionTableNames(java.util.List<java.lang.String> tableNames)
          Modules should add all table names that they manage to the given list.
abstract  java.lang.String getUpgradePackage()
          The Java package in which upgrade classes can be found.
abstract  void newInstallationCheck(com.serotonin.db.spring.ExtendedJdbcTemplate ejt)
          Provides the module an opportunity to check if it is a new installation (typically by checking if a table that it uses exists or not).
 
Methods inherited from class com.serotonin.m2m2.module.ModuleElementDefinition
getModule, initialize, uninstall
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseSchemaDefinition

public DatabaseSchemaDefinition()
Method Detail

newInstallationCheck

public abstract void newInstallationCheck(com.serotonin.db.spring.ExtendedJdbcTemplate ejt)
Provides the module an opportunity to check if it is a new installation (typically by checking if a table that it uses exists or not). Modules should perform any required installation tasks at this time.

Parameters:
ejt - the JDBC template that provides access to the database

addConversionTableNames

public abstract void addConversionTableNames(java.util.List<java.lang.String> tableNames)
Modules should add all table names that they manage to the given list. The names are used to perform conversions between one type of database (e.g. Derby) and another (e.g. MySQL).

Parameters:
tableNames - the list of table name to add to

getUpgradePackage

public abstract java.lang.String getUpgradePackage()
The Java package in which upgrade classes can be found. An upgrade class must be provided for every new version of the module, and must be named Upgrade<version>, where <version> is the version from which the module is being upgraded, and dots have been replaced with underscores. (For example, Upgrade1_0_1 will upgrade version 1.0.1 to the next version.) Upgrade classes extend the DBUpgrade class.

Returns:
the package name where upgrade classes can be found