org.makumba.db.makumba
Class Database

java.lang.Object
  extended by org.makumba.db.makumba.Database
Direct Known Subclasses:
Database

public abstract class Database
extends Object

A generic Makumba database (used by the MakumbaTransactionProvider, that maps RecordInfos to tables. It also takes care of creating and maintaining the schema. FIXME methods in here should get some documentation

Author:
Cristian Bogdan, Thomas Laroche, Rudolf Mayer, Marius Andra, Manuel Gay, please add if more

Field Summary
(package private)  Properties config
           
(package private)  String dataSourceName
          the name of the configured dataSource
(package private)  int initConnections
           
(package private)  int nconn
           
protected  NameResolver nr
           
(package private)  NamedResources queries
           
protected static boolean requestForeignKeys
           
protected static boolean requestUTF8
           
(package private)  Class<?> tableclass
           
(package private)  NamedResourceFactory tableFactory
           
(package private)  NamedResources tables
           
protected  TransactionProvider tp
           
(package private)  NamedResources updates
           
 
Constructor Summary
protected Database(Properties config)
           
 
Method Summary
(package private)  void addTable(String s)
           
 void checkForeignKeys(String table)
           
 void close()
           
protected abstract  void closeResourcePool()
           
(package private)  void configureTable(Table tbl, DataDefinition ri)
           
 void copyFrom(DBConnection c, String[] tables, DBConnection sourceDB, boolean ignoreDbsv)
           
 void copyFrom(DBConnection c, String table, DBConnection sourceDB, boolean ignoreDbsv)
           
 void copyFrom(String source, boolean ignoreDbsv)
           
 void copyFrom(String source, String[] tables, boolean ignoreDbsv)
           
 void copyFrom(String sourceDB, String table, boolean ignoreDbsv)
           
 void deleteFrom(DBConnection c, String[] tables, DBConnection sourceDB, boolean ignoreDbsv)
           
 void deleteFrom(DBConnection c, String table, DBConnection sourceDB, boolean ignoreDbsv)
           
 void deleteFrom(String source, String[] tables, boolean ignoreDbsv)
           
 void deleteFrom(String sourceDB, String table, boolean ignoreDbsv)
           
protected  void finalize()
           
static String findConfig(Properties cnf, String pattern)
          finds the longest configuration string that matches the pattern and returns the associated property
 String getConfiguration(String v)
           
 Properties getConfigurationProperties()
           
 DBConnection getDBConnection()
           
 DBConnection getDBConnection(String dataSource)
           
 int getDbsv()
          return the unique index of this database
abstract  Map<String,String> getDuplicateFields(SQLException e)
           
 String getFieldNameInSource(DataDefinition dd, String field)
           
protected abstract  int getIdleConnections()
           
abstract  int getMaxPointerValue()
           
abstract  int getMinPointerValue()
           
 String getName()
           
 NameResolver getNameResolver()
           
protected abstract  int getOpenedConnections()
           
abstract  Pointer getPointer(String type, int uid)
           
protected abstract  DBConnection getPooledDBConnection()
           
protected abstract  int getResourcePoolSize()
           
 Table getTable(DataDefinition ri)
          get the table from this database associated with the given RecordInfo
 Table getTable(String name)
          this method will return a table by macumba name.
protected  Class<?> getTableClassConfigured()
          this method should be redefined by database classes that have a default table class. this returns null
 String getTypeNameInSource(DataDefinition dd)
           
 void initialiseTables(String name)
           
 boolean isAutoIncrement()
           
abstract  boolean isDuplicateException(SQLException e)
           
protected abstract  DBConnection makeDBConnection()
           
 Table makePseudoTable(DataDefinition ri)
           
 void openTable(String table)
           
 void openTables(String[] _tables)
           
abstract  String OQLDate(Date d)
          write a date constant in OQL
abstract  Query prepareQueryImpl(String query, String insertIn)
           
abstract  Update prepareUpdateImpl(String type, String set, String where)
           
protected static boolean supportsForeignKeys()
           
 boolean usesHibernateIndexes()
          If this is true, i.e. hibernate is used, makumba will not take care of creating indexes itself FIXME this should somehow be more separated, e.g. through some schema configuration mechanism
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tp

protected TransactionProvider tp

queries

NamedResources queries

updates

NamedResources updates

nconn

int nconn

initConnections

int initConnections

requestUTF8

protected static boolean requestUTF8

requestForeignKeys

protected static boolean requestForeignKeys

config

Properties config

tableclass

Class<?> tableclass

dataSourceName

String dataSourceName
the name of the configured dataSource


nr

protected NameResolver nr

tables

NamedResources tables

tableFactory

NamedResourceFactory tableFactory
Constructor Detail

Database

protected Database(Properties config)
Method Detail

getName

public String getName()

supportsForeignKeys

protected static boolean supportsForeignKeys()

closeResourcePool

protected abstract void closeResourcePool()

getResourcePoolSize

protected abstract int getResourcePoolSize()

getOpenedConnections

protected abstract int getOpenedConnections()

getIdleConnections

protected abstract int getIdleConnections()

getPooledDBConnection

protected abstract DBConnection getPooledDBConnection()

close

public void close()

getDBConnection

public DBConnection getDBConnection(String dataSource)

getDBConnection

public DBConnection getDBConnection()

makeDBConnection

protected abstract DBConnection makeDBConnection()

isDuplicateException

public abstract boolean isDuplicateException(SQLException e)

getDuplicateFields

public abstract Map<String,String> getDuplicateFields(SQLException e)

getDbsv

public int getDbsv()
return the unique index of this database


isAutoIncrement

public boolean isAutoIncrement()

getPointer

public abstract Pointer getPointer(String type,
                                   int uid)

getConfiguration

public String getConfiguration(String v)

getTableClassConfigured

protected Class<?> getTableClassConfigured()
this method should be redefined by database classes that have a default table class. this returns null


OQLDate

public abstract String OQLDate(Date d)
write a date constant in OQL


getTable

public Table getTable(String name)
this method will return a table by macumba name. Subtables (->) are returned as well (for now) maybe we could write Table.getSubtable(ptr, field) to operate with subsets? how about 1:1 pointers? need to think of that API further


getTable

public Table getTable(DataDefinition ri)
get the table from this database associated with the given RecordInfo


findConfig

public static String findConfig(Properties cnf,
                                String pattern)
finds the longest configuration string that matches the pattern and returns the associated property


prepareQueryImpl

public abstract Query prepareQueryImpl(String query,
                                       String insertIn)

prepareUpdateImpl

public abstract Update prepareUpdateImpl(String type,
                                         String set,
                                         String where)

getMinPointerValue

public abstract int getMinPointerValue()

getMaxPointerValue

public abstract int getMaxPointerValue()

deleteFrom

public void deleteFrom(DBConnection c,
                       String table,
                       DBConnection sourceDB,
                       boolean ignoreDbsv)

deleteFrom

public void deleteFrom(String sourceDB,
                       String table,
                       boolean ignoreDbsv)

deleteFrom

public void deleteFrom(String source,
                       String[] tables,
                       boolean ignoreDbsv)

deleteFrom

public void deleteFrom(DBConnection c,
                       String[] tables,
                       DBConnection sourceDB,
                       boolean ignoreDbsv)

copyFrom

public void copyFrom(String sourceDB,
                     String table,
                     boolean ignoreDbsv)

copyFrom

public void copyFrom(String source,
                     String[] tables,
                     boolean ignoreDbsv)

copyFrom

public void copyFrom(DBConnection c,
                     String[] tables,
                     DBConnection sourceDB,
                     boolean ignoreDbsv)

copyFrom

public void copyFrom(DBConnection c,
                     String table,
                     DBConnection sourceDB,
                     boolean ignoreDbsv)

copyFrom

public void copyFrom(String source,
                     boolean ignoreDbsv)

openTables

public void openTables(String[] _tables)

openTable

public void openTable(String table)

checkForeignKeys

public void checkForeignKeys(String table)

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

addTable

void addTable(String s)

makePseudoTable

public Table makePseudoTable(DataDefinition ri)

configureTable

void configureTable(Table tbl,
                    DataDefinition ri)

usesHibernateIndexes

public boolean usesHibernateIndexes()
If this is true, i.e. hibernate is used, makumba will not take care of creating indexes itself FIXME this should somehow be more separated, e.g. through some schema configuration mechanism


getTypeNameInSource

public String getTypeNameInSource(DataDefinition dd)

getFieldNameInSource

public String getFieldNameInSource(DataDefinition dd,
                                   String field)

getConfigurationProperties

public Properties getConfigurationProperties()

getNameResolver

public NameResolver getNameResolver()

initialiseTables

public void initialiseTables(String name)