org.opennms.netmgt.dao.db
Class InstallerDb

java.lang.Object
  extended by org.opennms.netmgt.dao.db.InstallerDb

public class InstallerDb
extends java.lang.Object


Nested Class Summary
 class InstallerDb.AutoInteger
           
 class InstallerDb.AutoIntegerIdMapStore
           
 class InstallerDb.DoNotAddColumn
           
 class InstallerDb.EventSourceReplacement
           
 class InstallerDb.FixedIntegerReplacement
           
 class InstallerDb.Insert
           
 class InstallerDb.MapStoreIdGetter
           
 class InstallerDb.NextValReplacement
           
 class InstallerDb.NullReplacement
           
 class InstallerDb.RowHasBogusData
           
 
Field Summary
static float POSTGRES_MIN_VERSION
           
 
Constructor Summary
InstallerDb()
           
 
Method Summary
 void addColumnReplacement(java.lang.String tableColumn, ColumnChangeReplacement replacement)
           
 void addColumnReplacements()
           
 void addIndexesForTable(java.lang.String table)
           
 void addStoredProcedures()
           
 void addTriggersForTable(java.lang.String table)
           
 void changeTable(java.lang.String table, Table oldTable, Table newTable)
           
 void checkConstraint(Constraint constraint)
           
 void checkConstraints()
           
 void checkIndexUniqueness()
           
 void checkOldTables()
           
 void checkUnicode()
           
static java.lang.String cleanText(java.util.List<java.lang.String> list)
           
 void closeAdminConnection()
           
 void closeColumnReplacements()
           
 void closeConnection()
           
 void createSequences()
           
 void createTables()
           
 void databaseAddDB()
           
 void databaseAddUser()
           
 void databaseCheckLanguage()
           
 void databaseCheckVersion()
           
 boolean databaseDBExists()
           
 boolean databaseUserExists()
           
 Column findColumn(java.util.List<Column> columns, java.lang.String column)
           
 java.lang.String fixConstraint(Constraint constraint, boolean removeRows)
           
 void fixConstraint(java.lang.String constraintName, boolean removeRows)
           
 void fixData()
           
 boolean functionExists(java.lang.String function, int[] columnTypes, int retType)
           
 boolean functionExists(java.lang.String function, java.lang.String columns, java.lang.String returnType)
           
 javax.sql.DataSource getAdminDataSource()
           
 java.util.List<Column> getColumnsFromDB(java.lang.String tableName)
           
 java.util.List<Constraint> getConstraintsFromDB(java.lang.String tableName)
           
 java.lang.String getCreateSqlLocation()
           
 java.lang.String getDatabaseName()
           
 javax.sql.DataSource getDataSource()
           
 boolean getDebug()
           
 boolean getForce()
           
 java.lang.String getForeignConstraintWhere(java.lang.String table, java.util.List<java.lang.String> columns, java.lang.String ftable, java.util.List<java.lang.String> fcolumns)
           
 java.util.List<Constraint> getForeignKeyConstraints()
           
 java.lang.String getFunctionFromSQL(java.lang.String function)
           
 IndexDao getIndexDao()
           
 java.lang.String getIndexFromSQL(java.lang.String index)
           
 java.util.Map<java.lang.String,java.util.List<InstallerDb.Insert>> getInserts()
           
 java.lang.String getLanguageFromSQL(java.lang.String language)
           
 java.lang.String getPassword()
           
 java.lang.String getPgIpLikeLocation()
           
 java.lang.String getPostgresOpennmsUser()
           
 java.lang.String[] getSequenceMapping(java.lang.String sequence)
           
 java.util.List<java.lang.String> getSequenceNames()
           
 java.lang.String getSql()
           
 java.lang.String getStoredProcedureDirectory()
           
 java.util.List<Column> getTableColumnsFromDB(java.lang.String tableName)
           
 java.util.List<Column> getTableColumnsFromSQL(java.lang.String tableName)
           
 java.lang.String getTableCreateFromSQL(java.lang.String table)
           
 Table getTableFromDB(java.lang.String tableName)
           
 Table getTableFromSQL(java.lang.String tableName)
           
 java.util.List<java.lang.String> getTableNames()
           
 TriggerDao getTriggerDao()
           
 java.util.Map<java.lang.String,java.lang.Integer> getTypesFromDB()
           
 java.lang.String getXFromSQL(java.lang.String item, java.lang.String regex, int itemGroup, int returnGroup, java.lang.String description)
           
 boolean hasTableChanged(java.lang.String table)
           
 void insertData()
           
 boolean isIpLikeUsable()
           
 java.lang.String notNullWhereClause(java.lang.String table, java.util.List<java.lang.String> columns)
           
 void readTables()
           
 void readTables(java.io.Reader reader)
           
 void setAdminDataSource(javax.sql.DataSource dataSource)
           
 void setCreateSqlLocation(java.lang.String createSqlLocation)
           
 void setDatabaseName(java.lang.String name)
           
 void setDataSource(javax.sql.DataSource dataSource)
           
 void setDebug(boolean debug)
           
 void setForce(boolean force)
           
 void setIgnoreNotNull(boolean ignoreNotNull)
           
 void setNoRevert(boolean noRevert)
           
 void setOutputStream(java.io.PrintStream out)
           
 void setPassword(java.lang.String password)
           
 void setPgIpLikeLocation(java.lang.String location)
           
 void setPostgresAdminUser(java.lang.String postgresAdminUser)
           
 void setPostgresOpennmsUser(java.lang.String user)
           
 void setProgresBinaryDirectory(java.lang.String directory)
           
 void setStoredProcedureDirectory(java.lang.String directory)
           
 void setupPlPgsqlIplike()
           
 void tableChanged(java.lang.String table)
           
 boolean tableColumnExists(java.lang.String table, java.lang.String column)
           
 java.util.List<java.lang.String> tableColumnList(java.lang.String table, java.util.List<java.lang.String> columns)
           
 boolean tableExists(java.lang.String table)
           
 void transformData(java.lang.String table, java.lang.String oldTable, java.util.TreeMap<java.lang.String,ColumnChange> columnChanges, java.lang.String[] oldColumnNames)
           
 void updateIplike()
           
 void updatePlPgsql()
           
 void vacuumDatabase(boolean full)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSTGRES_MIN_VERSION

public static final float POSTGRES_MIN_VERSION
See Also:
Constant Field Values
Constructor Detail

InstallerDb

public InstallerDb()
Method Detail

readTables

public void readTables()
                throws java.lang.Exception
Throws:
java.lang.Exception

readTables

public void readTables(java.io.Reader reader)
                throws java.lang.Exception
Throws:
java.lang.Exception

cleanText

public static java.lang.String cleanText(java.util.List<java.lang.String> list)

createSequences

public void createSequences()
                     throws java.lang.Exception
Throws:
java.lang.Exception

updatePlPgsql

public void updatePlPgsql()
                   throws java.lang.Exception
Throws:
java.lang.Exception

isIpLikeUsable

public boolean isIpLikeUsable()

updateIplike

public void updateIplike()
                  throws java.lang.Exception
Throws:
java.lang.Exception

setupPlPgsqlIplike

public void setupPlPgsqlIplike()
                        throws java.lang.Exception
Throws:
java.lang.Exception

addStoredProcedures

public void addStoredProcedures()
                         throws java.lang.Exception
Throws:
java.lang.Exception

functionExists

public boolean functionExists(java.lang.String function,
                              java.lang.String columns,
                              java.lang.String returnType)
                       throws java.lang.Exception
Throws:
java.lang.Exception

functionExists

public boolean functionExists(java.lang.String function,
                              int[] columnTypes,
                              int retType)
                       throws java.lang.Exception
Throws:
java.lang.Exception

getTypesFromDB

public java.util.Map<java.lang.String,java.lang.Integer> getTypesFromDB()
                                                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

addTriggersForTable

public void addTriggersForTable(java.lang.String table)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

createTables

public void createTables()
                  throws java.lang.Exception
Throws:
java.lang.Exception

getTableFromSQL

public Table getTableFromSQL(java.lang.String tableName)
                      throws java.lang.Exception
Throws:
java.lang.Exception

getXFromSQL

public java.lang.String getXFromSQL(java.lang.String item,
                                    java.lang.String regex,
                                    int itemGroup,
                                    int returnGroup,
                                    java.lang.String description)
                             throws java.lang.Exception
Throws:
java.lang.Exception

findColumn

public Column findColumn(java.util.List<Column> columns,
                         java.lang.String column)

tableColumnExists

public boolean tableColumnExists(java.lang.String table,
                                 java.lang.String column)
                          throws java.lang.Exception
Throws:
java.lang.Exception

getTableColumnsFromDB

public java.util.List<Column> getTableColumnsFromDB(java.lang.String tableName)
                                             throws java.lang.Exception
Throws:
java.lang.Exception

getTableFromDB

public Table getTableFromDB(java.lang.String tableName)
                     throws java.lang.Exception
Throws:
java.lang.Exception

tableExists

public boolean tableExists(java.lang.String table)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

getColumnsFromDB

public java.util.List<Column> getColumnsFromDB(java.lang.String tableName)
                                        throws java.lang.Exception
Throws:
java.lang.Exception

getConstraintsFromDB

public java.util.List<Constraint> getConstraintsFromDB(java.lang.String tableName)
                                                throws java.sql.SQLException,
                                                       java.lang.Exception
Throws:
java.sql.SQLException
java.lang.Exception

changeTable

public void changeTable(java.lang.String table,
                        Table oldTable,
                        Table newTable)
                 throws java.lang.Exception
Throws:
java.lang.Exception

transformData

public void transformData(java.lang.String table,
                          java.lang.String oldTable,
                          java.util.TreeMap<java.lang.String,ColumnChange> columnChanges,
                          java.lang.String[] oldColumnNames)
                   throws java.sql.SQLException,
                          java.text.ParseException,
                          java.lang.Exception
Throws:
java.sql.SQLException
java.text.ParseException
java.lang.Exception

databaseCheckVersion

public void databaseCheckVersion()
                          throws java.lang.Exception
Throws:
java.lang.Exception

databaseCheckLanguage

public void databaseCheckLanguage()
                           throws java.lang.Exception
Throws:
java.lang.Exception

checkOldTables

public void checkOldTables()
                    throws java.sql.SQLException,
                           BackupTablesFoundException
Throws:
java.sql.SQLException
BackupTablesFoundException

getForeignKeyConstraints

public java.util.List<Constraint> getForeignKeyConstraints()
                                                    throws java.lang.Exception
Throws:
java.lang.Exception

checkConstraints

public void checkConstraints()
                      throws java.lang.Exception
Throws:
java.lang.Exception

checkConstraint

public void checkConstraint(Constraint constraint)
                     throws java.lang.Exception
Throws:
java.lang.Exception

getForeignConstraintWhere

public java.lang.String getForeignConstraintWhere(java.lang.String table,
                                                  java.util.List<java.lang.String> columns,
                                                  java.lang.String ftable,
                                                  java.util.List<java.lang.String> fcolumns)
                                           throws java.lang.Exception
Throws:
java.lang.Exception

notNullWhereClause

public java.lang.String notNullWhereClause(java.lang.String table,
                                           java.util.List<java.lang.String> columns)

tableColumnList

public java.util.List<java.lang.String> tableColumnList(java.lang.String table,
                                                        java.util.List<java.lang.String> columns)

fixConstraint

public void fixConstraint(java.lang.String constraintName,
                          boolean removeRows)
                   throws java.lang.Exception
Throws:
java.lang.Exception

fixConstraint

public java.lang.String fixConstraint(Constraint constraint,
                                      boolean removeRows)
                               throws java.lang.Exception
Throws:
java.lang.Exception

databaseUserExists

public boolean databaseUserExists()
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

databaseAddUser

public void databaseAddUser()
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

databaseDBExists

public boolean databaseDBExists()
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

databaseAddDB

public void databaseAddDB()
                   throws java.lang.Exception
Throws:
java.lang.Exception

addIndexesForTable

public void addIndexesForTable(java.lang.String table)
                        throws java.sql.SQLException
Throws:
java.sql.SQLException

fixData

public void fixData()
             throws java.lang.Exception
Throws:
java.lang.Exception

insertData

public void insertData()
                throws java.lang.Exception
Throws:
java.lang.Exception

checkUnicode

public void checkUnicode()
                  throws java.lang.Exception
Throws:
java.lang.Exception

checkIndexUniqueness

public void checkIndexUniqueness()
                          throws java.lang.Exception
Throws:
java.lang.Exception

getTableColumnsFromSQL

public java.util.List<Column> getTableColumnsFromSQL(java.lang.String tableName)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

getTableCreateFromSQL

public java.lang.String getTableCreateFromSQL(java.lang.String table)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

getIndexFromSQL

public java.lang.String getIndexFromSQL(java.lang.String index)
                                 throws java.lang.Exception
Throws:
java.lang.Exception

getFunctionFromSQL

public java.lang.String getFunctionFromSQL(java.lang.String function)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

getLanguageFromSQL

public java.lang.String getLanguageFromSQL(java.lang.String language)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

closeConnection

public void closeConnection()
                     throws java.sql.SQLException
Throws:
java.sql.SQLException

closeAdminConnection

public void closeAdminConnection()
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

setCreateSqlLocation

public void setCreateSqlLocation(java.lang.String createSqlLocation)

getCreateSqlLocation

public java.lang.String getCreateSqlLocation()

getTableNames

public java.util.List<java.lang.String> getTableNames()

getSequenceNames

public java.util.List<java.lang.String> getSequenceNames()

getSequenceMapping

public java.lang.String[] getSequenceMapping(java.lang.String sequence)

getIndexDao

public IndexDao getIndexDao()

getInserts

public java.util.Map<java.lang.String,java.util.List<InstallerDb.Insert>> getInserts()

getSql

public java.lang.String getSql()

hasTableChanged

public boolean hasTableChanged(java.lang.String table)

tableChanged

public void tableChanged(java.lang.String table)

setOutputStream

public void setOutputStream(java.io.PrintStream out)

setPostgresOpennmsUser

public void setPostgresOpennmsUser(java.lang.String user)

getPostgresOpennmsUser

public java.lang.String getPostgresOpennmsUser()

getTriggerDao

public TriggerDao getTriggerDao()

setStoredProcedureDirectory

public void setStoredProcedureDirectory(java.lang.String directory)

getStoredProcedureDirectory

public java.lang.String getStoredProcedureDirectory()

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)

getDataSource

public javax.sql.DataSource getDataSource()

setAdminDataSource

public void setAdminDataSource(javax.sql.DataSource dataSource)

getAdminDataSource

public javax.sql.DataSource getAdminDataSource()

setForce

public void setForce(boolean force)

getForce

public boolean getForce()

setDebug

public void setDebug(boolean debug)

getDebug

public boolean getDebug()

addColumnReplacement

public void addColumnReplacement(java.lang.String tableColumn,
                                 ColumnChangeReplacement replacement)

setIgnoreNotNull

public void setIgnoreNotNull(boolean ignoreNotNull)

getDatabaseName

public java.lang.String getDatabaseName()

setDatabaseName

public void setDatabaseName(java.lang.String name)

setNoRevert

public void setNoRevert(boolean noRevert)

setPassword

public void setPassword(java.lang.String password)

getPassword

public java.lang.String getPassword()

setProgresBinaryDirectory

public void setProgresBinaryDirectory(java.lang.String directory)

setPostgresAdminUser

public void setPostgresAdminUser(java.lang.String postgresAdminUser)

setPgIpLikeLocation

public void setPgIpLikeLocation(java.lang.String location)

getPgIpLikeLocation

public java.lang.String getPgIpLikeLocation()

addColumnReplacements

public void addColumnReplacements()
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

closeColumnReplacements

public void closeColumnReplacements()
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

vacuumDatabase

public void vacuumDatabase(boolean full)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException


Copyright © 2007. All Rights Reserved.