easik.sketch.util.Export.Database
Class DatabaseBuilder

java.lang.Object
  extended by easik.sketch.util.Export.Database.DatabaseBuilder

public class DatabaseBuilder
extends java.lang.Object

A class to convert a sketch to a database through an existing database platform.

Since:
2006-05-10 Vera Ranieri
Version:
2006-06-15 Vera Ranieri
Author:
Vera Ranieri 2006

Field Summary
private  java.sql.Connection _con
          The connection made to the database
private  java.lang.String _dataTypePlatform
          The database used
private  DatabaseUI _db
          The UI used to gather information to form the connection
private  java.lang.String _name
          The name of the database
private  SketchToSchema _schema
          The schema built from the XML file
private  ExportHandler _sqlHandler
          The handler made from the file
 
Constructor Summary
DatabaseBuilder(ExportHandler sh, DatabaseUI db)
          Creates a new database builder which forms a connection to the database.
 
Method Summary
private  java.lang.String checkURL(java.lang.String url)
          Class to prompt the user for the URL of the database.
private  boolean setConstraints()
          Sets the constraint string in the database.
private  boolean setDatabase()
          Method to create a new database and set this database to be the one to use from all points afterwords
private  boolean setFailTable()
          Sets the fail table and procedure for the newly created database so failures can be logged and triggers can produce an error statement should an illegal operation be performed.
private  boolean setTables()
          A method to create the database tables.
private  boolean setTriggers()
          A method to pass trigger strings to the SQL server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_con

private java.sql.Connection _con
The connection made to the database


_name

private java.lang.String _name
The name of the database


_dataTypePlatform

private java.lang.String _dataTypePlatform
The database used


_schema

private SketchToSchema _schema
The schema built from the XML file


_sqlHandler

private ExportHandler _sqlHandler
The handler made from the file


_db

private DatabaseUI _db
The UI used to gather information to form the connection

Constructor Detail

DatabaseBuilder

public DatabaseBuilder(ExportHandler sh,
                       DatabaseUI db)
Creates a new database builder which forms a connection to the database. It then adds all relevant information to the database.

Parameters:
sh - The export handler for this sketch
db - The UI containing information about the connection
Method Detail

checkURL

private java.lang.String checkURL(java.lang.String url)
                           throws java.lang.Exception
Class to prompt the user for the URL of the database. Returns null if it is an invalid address

Parameters:
url - The URL provided by the user
Returns:
String URL formatted for database connection
Throws:
java.lang.Exception - If the URL is null or contains spaces

setDatabase

private boolean setDatabase()
Method to create a new database and set this database to be the one to use from all points afterwords

Returns:
True if the database was successfully set, false otherwise

setTables

private boolean setTables()
A method to create the database tables.

Returns:
true if the tables were successfully set, false otherwise

setFailTable

private boolean setFailTable()
Sets the fail table and procedure for the newly created database so failures can be logged and triggers can produce an error statement should an illegal operation be performed.

Returns:
True if the fail table was successfully created, false otherwise
Since:
2006-06-15 Vera Ranieri

setConstraints

private boolean setConstraints()
Sets the constraint string in the database.

Returns:
True if constraints were successfully set, false otherwise
Since:
2006-06-14 Vera Ranieri

setTriggers

private boolean setTriggers()
A method to pass trigger strings to the SQL server.

Returns:
True if all triggers were successfully accepted by the server, false otherwise
Since:
2006-06-15 Vera Ranieri