org.mmbase.storage.database
Interface DatabaseStorage

All Superinterfaces:
Storage
All Known Implementing Classes:
AbstractDatabaseStorage, SQL92DatabaseStorage, Support2Storage, RelationalDatabaseStorage, OODatabaseStorage

public interface DatabaseStorage
extends Storage

Storage interface for use with a database. This interface adds two type of methods. The first are methods used to configure the database, or to store the current configuration, either by using a Document or through seperate calls. The second methods are used as callback methods by a DatabaseTransaction object, to handle specific database dependent routines, such as storing binary objects.

Since:
MMBase-1.6
Version:
$Id: DatabaseStorage.java,v 1.2 2002/11/12 16:57:52 pierre Exp $
Author:
Pierre van Rooden

Field Summary
static int KEY_FOREIGN
          Indicates a field is a foreign key
static int KEY_NONE
          Indicates a field is not a key, and nullable
static int KEY_NOTNULL
          Indicates a field is not a key, and not nullable
static int KEY_PRIMARY
          Indicates a field is a primary key
static int KEY_SECONDARY
          Indicates a field is a unique secondary key
 
Method Summary
 void deployDatabaseDocument(XMLDatabaseReader document)
          This reads database specific content from the database configuration document.
 java.lang.String getBinaryFilePath()
          Returns the filepath where binary objects are stored.
 java.lang.String getCreateExtendedScheme()
          Returns the scheme (SQL command) to use for creating a table that extends another table
 java.lang.String getCreateScheme()
          Returns the scheme (SQL command) to use for creating a table
 java.util.Map getFieldNameMap()
          Returns the current mapping of disallowed fieldsnames (typically reserved words) and their replacement names.
 java.lang.String getForeignKeyScheme()
          Returns the scheme (SQL command) to use for creating a key
 JDBCInterface getJDBC()
          Returns the JDBC module used by this class to connect to the database.
 java.lang.String getKeyScheme()
          Returns the scheme (SQL command) to use for creating a key
 int getMaxDropSize()
          Returns the maximum table drop size.
 java.lang.String getNotNullScheme()
          Returns the scheme (SQL command) to use for creating a non-null field
 java.lang.String getPrimaryKeyScheme()
          Returns the scheme (SQL command) to use for creating a primary key
 boolean getStoreBinaryAsFile()
          Returns whether binary objects are stored as files (rather than in the database)
 java.util.Map getTypeMap()
          Obtains the type map.
 void init(MMBase mmb, XMLDatabaseReader document)
          Initializes the database layer.
 void loadFieldFromTable(MMObjectNode node, java.lang.String fieldname, java.sql.ResultSet rs, int i)
          Stores a field in a table ResultSet in a MMObjectNode.
 java.lang.String mapToMMBaseFieldName(java.lang.String fieldname)
          Maps a database fieldname to a fieldname as used by the MMbase system
 java.lang.String mapToTableFieldName(java.lang.String fieldname)
          Maps a MMBase fieldname to a fieldname acceptable to the database
 void registerChanged(MMObjectNode node, java.lang.String change)
          Registers the change to a node.
 void setBinaryFilePath(java.lang.String path)
          Sets the filepath where binary objects are stored.
 void setCreateExtendedScheme(java.lang.String scheme)
          Sets the scheme (SQL command) to use for creating a table that extends another table
 void setCreateScheme(java.lang.String scheme)
          Sets the scheme (SQL command) to use for creating a table
 void setFieldNameMap(java.util.Map fieldmap)
          Sets the mapping of MMBase fieldnames (typically reserved words) to database fieldnames.
 void setForeignKeyScheme(java.lang.String scheme)
          Sets the scheme (SQL command) to use for creating a key
 void setKeyScheme(java.lang.String scheme)
          Sets the scheme (SQL command) to use for creating a key
 void setMaxDropSize(int value)
          Sets the maximum table drop size.
 void setNotNullScheme(java.lang.String scheme)
          Sets the scheme (SQL command) to use for creating a non-null field
 void setPrimaryKeyScheme(java.lang.String scheme)
          Sets the scheme (SQL command) to use for creating a primary key
 void setStoreBinaryAsFile(boolean value)
          Sets whether binary objects are stored as files (rather than in the database)
 void setTypeMap(java.util.Map typeMap)
          Sets the type map.
 boolean setValuePreparedStatement(java.sql.PreparedStatement stmt, MMObjectNode node, java.lang.String key, int i)
          Set prepared statement field i with value of key from node
 boolean supportsExtendedTables()
          Returns whether this storage layer supports extended tables.
 
Methods inherited from interface org.mmbase.storage.Storage
addField, changeField, commit, commit, create, create, created, createKey, createKey, createObjectStorage, createObjectStorage, createTransaction, delete, delete, drop, getBytes, getNode, getNode, getNodeType, getNodeType, getText, insert, insert, isAllowedParentBuilder, registerParentBuilder, removeField, size, supportsRollback, updateStorage
 

Field Detail

KEY_NONE

public static final int KEY_NONE
Indicates a field is not a key, and nullable

KEY_PRIMARY

public static final int KEY_PRIMARY
Indicates a field is a primary key

KEY_SECONDARY

public static final int KEY_SECONDARY
Indicates a field is a unique secondary key

KEY_FOREIGN

public static final int KEY_FOREIGN
Indicates a field is a foreign key

KEY_NOTNULL

public static final int KEY_NOTNULL
Indicates a field is not a key, and not nullable
Method Detail

init

public void init(MMBase mmb,
                 XMLDatabaseReader document)
Initializes the database layer. This reads database specific content from the database configuration document. If needed, the code creates a 'numbertable' for mmbase to track number generation.
Parameters:
mmb - the MBase instance that uses this database layer
document - the database configuration document

deployDatabaseDocument

public void deployDatabaseDocument(XMLDatabaseReader document)
This reads database specific content from the database configuration document.
Parameters:
document - the database configuration document

getStoreBinaryAsFile

public boolean getStoreBinaryAsFile()
Returns whether binary objects are stored as files (rather than in the database)
Returns:
true if binary objects are stored as files

setStoreBinaryAsFile

public void setStoreBinaryAsFile(boolean value)
Sets whether binary objects are stored as files (rather than in the database)
Parameters:
value - if true, binary objects will be stored as files

getBinaryFilePath

public java.lang.String getBinaryFilePath()
Returns the filepath where binary objects are stored. Only applies if getStoreBinaryAsFile() returns true.
Returns:
the file path

setBinaryFilePath

public void setBinaryFilePath(java.lang.String path)
Sets the filepath where binary objects are stored. Only applies if getStoreBinaryAsFile() returns true.
Parameters:
path - the file path

setFieldNameMap

public void setFieldNameMap(java.util.Map fieldmap)
Sets the mapping of MMBase fieldnames (typically reserved words) to database fieldnames. This map is used to map MMBase fieldnames to fieldnames that are acceptable to the database, i.e. Oracle does not accept 'number' as a fieldname, though MMBase uses it as a field name.
Parameters:
fieldmap - Map of field mappings. The map contins a key value pairs where the key is the MMbase fieldname, and the value the replacement acceptable to the database.

getFieldNameMap

public java.util.Map getFieldNameMap()
Returns the current mapping of disallowed fieldsnames (typically reserved words) and their replacement names. Note that this is a copy. Changes made to this map will not affect the databse until set with setFieldNameMap(java.util.Map).
Returns:
a Map of field mappings.

setTypeMap

public void setTypeMap(java.util.Map typeMap)
Sets the type map. The type map is used to convert MMBase types to database types (needed for creating tables).
Parameters:
typemap - Map of MMBase types and their database type.

getTypeMap

public java.util.Map getTypeMap()
Obtains the type map. The type map is used to convert MMBase types to database types (needed for creating tables). Note that this is a copy. Changes made to this map will not affect the database until set with setTypeMap(java.util.Map). However, the individual map elements are not copies - changing the dTypeInfo objects wil affect the database layer directly.
Returns:
a Map of MMBase types and their database type.

setPrimaryKeyScheme

public void setPrimaryKeyScheme(java.lang.String scheme)
Sets the scheme (SQL command) to use for creating a primary key
Parameters:
scheme - the scheme to use

getPrimaryKeyScheme

public java.lang.String getPrimaryKeyScheme()
Returns the scheme (SQL command) to use for creating a primary key

setNotNullScheme

public void setNotNullScheme(java.lang.String scheme)
Sets the scheme (SQL command) to use for creating a non-null field
Parameters:
scheme - the scheme to use

getNotNullScheme

public java.lang.String getNotNullScheme()
Returns the scheme (SQL command) to use for creating a non-null field

setKeyScheme

public void setKeyScheme(java.lang.String scheme)
Sets the scheme (SQL command) to use for creating a key
Parameters:
scheme - the scheme to use

getKeyScheme

public java.lang.String getKeyScheme()
Returns the scheme (SQL command) to use for creating a key

setForeignKeyScheme

public void setForeignKeyScheme(java.lang.String scheme)
Sets the scheme (SQL command) to use for creating a key
Parameters:
scheme - the scheme to use

getForeignKeyScheme

public java.lang.String getForeignKeyScheme()
Returns the scheme (SQL command) to use for creating a key

setCreateScheme

public void setCreateScheme(java.lang.String scheme)
Sets the scheme (SQL command) to use for creating a table
Parameters:
scheme - the scheme to use

getCreateScheme

public java.lang.String getCreateScheme()
Returns the scheme (SQL command) to use for creating a table

setCreateExtendedScheme

public void setCreateExtendedScheme(java.lang.String scheme)
Sets the scheme (SQL command) to use for creating a table that extends another table
Parameters:
scheme - the scheme to use

getCreateExtendedScheme

public java.lang.String getCreateExtendedScheme()
Returns the scheme (SQL command) to use for creating a table that extends another table

setMaxDropSize

public void setMaxDropSize(int value)
Sets the maximum table drop size.
Parameters:
value - the maximum size to set

getMaxDropSize

public int getMaxDropSize()
Returns the maximum table drop size.

supportsExtendedTables

public boolean supportsExtendedTables()
Returns whether this storage layer supports extended tables.
Returns:
boolean true if extended tables are supported

mapToTableFieldName

public java.lang.String mapToTableFieldName(java.lang.String fieldname)
Maps a MMBase fieldname to a fieldname acceptable to the database
Parameters:
fieldname - the fieldname to map

mapToMMBaseFieldName

public java.lang.String mapToMMBaseFieldName(java.lang.String fieldname)
Maps a database fieldname to a fieldname as used by the MMbase system
Parameters:
fieldname - the fieldname to map

getJDBC

public JDBCInterface getJDBC()
Returns the JDBC module used by this class to connect to the database. Note that this interface may be up to change, so use with care.
Returns:
the JDBC Module.

loadFieldFromTable

public void loadFieldFromTable(MMObjectNode node,
                               java.lang.String fieldname,
                               java.sql.ResultSet rs,
                               int i)
Stores a field in a table ResultSet in a MMObjectNode.
Parameters:
node - the node to store the field in
fieldname - the name of the field as it is known to MMBase
rs - the ResultSet containing the table row
i - the index of the field in the ResultSet

setValuePreparedStatement

public boolean setValuePreparedStatement(java.sql.PreparedStatement stmt,
                                         MMObjectNode node,
                                         java.lang.String key,
                                         int i)
                                  throws java.sql.SQLException
Set prepared statement field i with value of key from node
Throws:
java.sql.SQLException - if an error occurred while filling in the fields

registerChanged

public void registerChanged(MMObjectNode node,
                            java.lang.String change)
Registers the change to a node. Clears the change status of a ndoe, then broadcasts changes to the node's parent builder. If the node is a relation, it also updates the relationcache and broadcasts these changes to the relation' s source and destination.
Parameters:
node - the node to register
change - the type of change: "n": new, "c": commit, "d": delete


MMBase build 1.6.5.20030923