ch.sahits.codegen.java.input.db
Class OracleConnectorModelGenerator

java.lang.Object
  extended by ch.sahits.codegen.java.input.db.DBConnection
      extended by ch.sahits.codegen.java.input.db.OracleConnection
          extended by ch.sahits.codegen.java.input.db.OracleConnectorModelGenerator
All Implemented Interfaces:
IDBConnectionModelGenerator, IBasicDBConnectionModelGenerator, IGeneralDBConnectionModelGenerator

public class OracleConnectorModelGenerator
extends OracleConnection
implements IDBConnectionModelGenerator, IGeneralDBConnectionModelGenerator

This class can generate a model from a connection to a Oracle database.

Since:
0.9.4
Author:
Andit Hotz

Field Summary
 
Fields inherited from class ch.sahits.codegen.java.input.db.DBConnection
conn, db, host, password, port, product, schema, table, user
 
Constructor Summary
OracleConnectorModelGenerator()
          Default constructor
 
Method Summary
 DataBaseTable generateModel()
          Generate the database model
 java.lang.String getDefaultHost()
          Retrieve the default name of the database host
 java.lang.String getDefaultPort()
          Retrieve the default port number of the data base
 java.lang.String getDefaultUserName()
          Retrieve the default user name for the data base
 int getRating()
          This method rates the implementation.
 int getWorkload()
          Defines how complex the generation of the model is.
 boolean hasSchema()
          Indicates if this database works through schemas
 void init(java.lang.String hostname, java.lang.String uname, java.lang.String pwd, java.lang.String database, java.lang.String tablename, int port, java.lang.String schema)
          Initialize the generator by calling init(String, String, String, String, String, String, String, int, String) and passing an empty class and package name
 void init(java.lang.String hostname, java.lang.String uname, java.lang.String pwd, java.lang.String database, java.lang.String tablename, java.lang.String _packageName, java.lang.String _className, int _port, java.lang.String _schema)
          Constructor initializes the connection data
 void setDatabase(java.lang.String dbName)
          Set the name of the database
 java.lang.String testConnection()
          Test the connection
 
Methods inherited from class ch.sahits.codegen.java.input.db.OracleConnection
convert2Java, createDataBaseTable, getConnectionDriverClass, getConnectionString, getConstraintFieldSQL, getIndexConstraintSQL, getStructure, getTableSQL, isAutogenKey, loadDriver
 
Methods inherited from class ch.sahits.codegen.java.input.db.DBConnection
addFields2Index, getConstraintsFields, getPort, getSchema, init, isAutGenKey, setHost, setPassword, setPort, setProduct, setSchema, setTableName, setUserName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ch.sahits.codegen.model.IBasicDBConnectionModelGenerator
getConnectionDriverClass, getConnectionString, setHost, setPassword, setPort, setTableName, setUserName
 

Constructor Detail

OracleConnectorModelGenerator

public OracleConnectorModelGenerator()
Default constructor

Method Detail

init

public final void init(java.lang.String hostname,
                       java.lang.String uname,
                       java.lang.String pwd,
                       java.lang.String database,
                       java.lang.String tablename,
                       java.lang.String _packageName,
                       java.lang.String _className,
                       int _port,
                       java.lang.String _schema)
                throws java.sql.SQLException
Constructor initializes the connection data

Specified by:
init in interface IDBConnectionModelGenerator
Parameters:
hostname - of the db eg. localhost
uname - user name to connect to the DB
pwd - password of the user
database - or schema of the table
tablename - table name
_schema - Schema name
_packageName - name of the package
_className - name of the class
_port - number
Throws:
java.sql.SQLException - Connecting failed probably due to incorrect input

generateModel

public DataBaseTable generateModel()
Generate the database model

Specified by:
generateModel in interface IBasicDBConnectionModelGenerator
Returns:
generated database table model

getDefaultHost

public java.lang.String getDefaultHost()
Description copied from interface: IBasicDBConnectionModelGenerator
Retrieve the default name of the database host

Specified by:
getDefaultHost in interface IBasicDBConnectionModelGenerator
Returns:
"localhost"

getDefaultPort

public java.lang.String getDefaultPort()
Description copied from interface: IBasicDBConnectionModelGenerator
Retrieve the default port number of the data base

Specified by:
getDefaultPort in interface IBasicDBConnectionModelGenerator
Returns:
1521

getDefaultUserName

public java.lang.String getDefaultUserName()
Description copied from interface: IBasicDBConnectionModelGenerator
Retrieve the default user name for the data base

Specified by:
getDefaultUserName in interface IBasicDBConnectionModelGenerator
Returns:
"sys"

setDatabase

public final void setDatabase(java.lang.String dbName)
Set the name of the database

Specified by:
setDatabase in interface IBasicDBConnectionModelGenerator
Parameters:
dbName - database name

testConnection

public final java.lang.String testConnection()
Test the connection

Specified by:
testConnection in interface IBasicDBConnectionModelGenerator
Returns:
null or error message

getRating

public int getRating()
This method rates the implementation. Since this Interface is used for an extension point Implementations with the highest ranking are choosen. Since this is the default implementation the ranking is low

Specified by:
getRating in interface IBasicDBConnectionModelGenerator
Returns:
1

getWorkload

public int getWorkload()
Defines how complex the generation of the model is.
For the retrieving of the table structure three tables must be querried. The forth part of the costs are taken up by putting the pieces together

Specified by:
getWorkload in interface IBasicDBConnectionModelGenerator
Returns:
Number of work steps

hasSchema

public boolean hasSchema()
Indicates if this database works through schemas

Specified by:
hasSchema in interface IBasicDBConnectionModelGenerator
Returns:
true since Oracle embraces the concept of schemas

init

public void init(java.lang.String hostname,
                 java.lang.String uname,
                 java.lang.String pwd,
                 java.lang.String database,
                 java.lang.String tablename,
                 int port,
                 java.lang.String schema)
          throws java.sql.SQLException
Initialize the generator by calling init(String, String, String, String, String, String, String, int, String) and passing an empty class and package name

Specified by:
init in interface IGeneralDBConnectionModelGenerator
Parameters:
hostname - of the db eg. localhost
uname - user name to connect to the DB
pwd - password of the user
database - or schema of the table
tablename - table name
schema - Schema name
port - number
Throws:
java.sql.SQLException - Connecting failed probably due to incorrect input