org.javagen.agile.db
Class DbLoader

java.lang.Object
  extended by org.javagen.agile.db.DbLoader
All Implemented Interfaces:
Generator

public class DbLoader
extends Object
implements Generator

Create DB model tree from JDBC metadata from provided DataSource.

The scope of the model tree can be limited by specifying a list of includeTableNames and/or excludeTableNames, otherwise all table schemas are loaded.

Author:
Richard Easterling

Field Summary
protected  DataSource dataSource
           
protected  Set<String> excludeTableNames
           
protected  List<String> includeTableNames
           
protected  boolean namesToUpperCase
           
protected  Model parentModel
           
 
Constructor Summary
DbLoader()
           
 
Method Summary
 Model gen(Model input)
          Create DB model tree from JDBC metadata from provided DataSource.
 DataSource getDataSource()
           
 Set<String> getExcludeTableNames()
           
 List<String> getIncludeTableNames()
           
 Model getParentModel()
           
 boolean isNamesToUpperCase()
           
 void load(Database database)
          Load tables into Database instance using supplied DataSource.
 void loadImportedKeys(DatabaseMetaData dbMeta, Database database, List<String> tableList)
          Wire up foreign key relationships
 List<String> loadTableList(DatabaseMetaData dbMeta, Database database)
          Create list of all table names from DatabaseMetaData.
 void loadTables(Connection dbconn, DatabaseMetaData dbMeta, Database database, List<String> tableList)
          Populate column data for this table obtained from DatabaseMetaData.getColumns() ResultSet.
 void setDataSource(DataSource dataSource)
           
 void setExcludeTableNames(Set<String> excludeTableNames)
           
 void setExcludeTables(String delineatedExcludeTables)
          White-space/comma delineated list of table names to exclude from the transformation process.
 void setIncludeTableNames(List<String> tableNames)
           
 void setIncludeTables(String delineatedIncludeTables)
          White-space/comma delineated list of table names to include in the transformation process.
 void setNamesToUpperCase(boolean namesToUpperCase)
           
 void setParentModel(Model baseModel)
           
 void verifyTableList(DatabaseMetaData dbMeta, Database database, List<String> tableList)
          Verify existence of provided table list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSource

protected DataSource dataSource

includeTableNames

protected List<String> includeTableNames

excludeTableNames

protected Set<String> excludeTableNames

parentModel

protected Model parentModel

namesToUpperCase

protected boolean namesToUpperCase
Constructor Detail

DbLoader

public DbLoader()
Method Detail

gen

public Model gen(Model input)
Create DB model tree from JDBC metadata from provided DataSource.

Specified by:
gen in interface Generator
Parameters:
input - can be one of three possibilities:
  1. Database instance - provided database is processed instead of creating a new instance.
  2. A non-Database instance - input model is treated as container for new Database instance.
  3. null - new Database is created.
Returns:
container model if present, otherwise return the Database instance.

load

public void load(Database database)
          throws SQLException
Load tables into Database instance using supplied DataSource.

Throws:
SQLException

loadTableList

public List<String> loadTableList(DatabaseMetaData dbMeta,
                                  Database database)
                           throws SQLException
Create list of all table names from DatabaseMetaData.

Throws:
SQLException

verifyTableList

public void verifyTableList(DatabaseMetaData dbMeta,
                            Database database,
                            List<String> tableList)
                     throws SQLException
Verify existence of provided table list.

Throws:
SQLException

loadTables

public void loadTables(Connection dbconn,
                       DatabaseMetaData dbMeta,
                       Database database,
                       List<String> tableList)
Populate column data for this table obtained from DatabaseMetaData.getColumns() ResultSet.


loadImportedKeys

public void loadImportedKeys(DatabaseMetaData dbMeta,
                             Database database,
                             List<String> tableList)
                      throws SQLException
Wire up foreign key relationships

Parameters:
dbMeta - DatabaseMetaData instance
database - root model node of DB tree
tableSet - Mechinism for mapping subset of tables - FKs to tables not in this list are just treated like data columns.
Throws:
SQLException

getIncludeTableNames

public List<String> getIncludeTableNames()

setIncludeTableNames

public void setIncludeTableNames(List<String> tableNames)

getDataSource

public DataSource getDataSource()

setDataSource

public void setDataSource(DataSource dataSource)

getParentModel

public Model getParentModel()

setParentModel

public void setParentModel(Model baseModel)

isNamesToUpperCase

public boolean isNamesToUpperCase()

setNamesToUpperCase

public void setNamesToUpperCase(boolean namesToUpperCase)

getExcludeTableNames

public Set<String> getExcludeTableNames()

setExcludeTableNames

public void setExcludeTableNames(Set<String> excludeTableNames)

setIncludeTables

public void setIncludeTables(String delineatedIncludeTables)
White-space/comma delineated list of table names to include in the transformation process.


setExcludeTables

public void setExcludeTables(String delineatedExcludeTables)
White-space/comma delineated list of table names to exclude from the transformation process.



Copyright 2006-2006-2007 Outsource Cafe Inc.. All Rights Reserved.