|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opensubsystems.core.persist.db.DatabaseSchemaImpl
org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl
org.opensubsystems.patterns.mappeddata.persist.db.MappingDatabaseSchema
public abstract class MappingDatabaseSchema
Database specific operations related to persistence of mapping tables. Multiple records from TABLE1 can be mapped to records in TABLE2. The total relationship between these two tables is is N:M. The same two records can be also mapped using different mapping types. Subsystems that want to create mappings should derive database schema class from this class. The only thing which is required is to implement constructor that provides attributes, that are use to construct database tables where the mappings will be stored. - 1st important rule is, that name of the table should contains part of: a.) name of the table the 1 related record is comming from b.) name of the table the M related records are comming from For example: a.) TABLE1 ... we want to map 1 record from this table b.) TABLE2 ... we want to map M records from this table mapped table name =
| Field Summary | |
|---|---|
protected java.lang.Class |
m_schema1
Schema entry from which we are mapping. |
protected java.lang.Class |
m_schema2
Schema entry from which we are mapping. |
protected java.lang.String |
m_strColumnName1
Name of the column used for constructing of mapping table. |
protected java.lang.String |
m_strColumnName2
Name of the column used for constructing of mapping table. |
protected java.lang.String |
m_strConstraintBody
Constructed body of the constraint. |
protected java.lang.String |
m_strMapTableName
Name of the mapping table that will be created. |
protected java.lang.String |
m_strTableName1
Name of the table used for constructing of mapping table. |
protected java.lang.String |
m_strTableName2
Name of the table used for constructing of mapping table. |
static int |
MAPPING_CUSTOM_DATA_MAXLENGTH
Maximal length of custom data. |
static java.lang.String |
MAPPING_SCHEMA_COLUMN1
Name identifies new column of the mapping table. |
static java.lang.String |
MAPPING_SCHEMA_COLUMN2
Name identifies new column of the mapping table. |
static java.lang.String |
MAPPING_SCHEMA_NAME
Name identifies this schema in the database. |
static int |
MAPPING_SCHEMA_VERSION
Version of this schema in the database. |
| Fields inherited from class org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl |
|---|
m_mapModifiableTableNames |
| Fields inherited from class org.opensubsystems.core.persist.db.DatabaseSchemaImpl |
|---|
DATABASE_SCHEMA_PREFIX, DATABASE_SCHEMA_PREFIX_DEFAULT, m_arrDependentSchemas, m_bIsInDomain, m_iSchemaVersion, m_strSchemaName, NL |
| Fields inherited from interface org.opensubsystems.core.persist.db.DatabaseOperations |
|---|
DBOP_DELETE, DBOP_INSERT, DBOP_SELECT, DBOP_UPDATE |
| Constructor Summary | |
|---|---|
MappingDatabaseSchema(java.lang.String strMapTableName,
java.lang.Class schema1,
java.lang.String strTableName1,
java.lang.String strColumnName1,
java.lang.Class schema2,
java.lang.String strTableName2,
java.lang.String strColumnName2)
Full constructor. |
|
| Method Summary | |
|---|---|
protected java.lang.String |
constructConstraintName()
Method constructs name of the constraint. |
protected java.lang.String |
constructSQL(java.lang.String strIDDefinition,
java.lang.String strColDataType,
java.lang.String strTextDataType,
java.lang.String strTmstpDataType,
java.lang.String strConstraintBody,
boolean bCascade,
boolean bPKConstraint)
Method constructs sql for creating mapping table |
void |
create(java.sql.Connection cntDBConnection,
java.lang.String strUserName)
|
java.lang.String |
geSelectMappingMultipleRecords(java.lang.String strColumnIDs)
Method returns simple select mapping multiple record query. |
java.lang.String |
geSelectMappingRecords()
Method returns simple select mapping record query. |
java.lang.StringBuffer |
getColumns(boolean specific,
int[] columns,
java.lang.Object[] prefixes,
java.lang.Object[] postfixes,
java.lang.StringBuffer buffer)
Convert any attribute regardless if it is in the main table or in join table into database column name. |
protected MappingDatabaseSchema |
getDatabaseSpecificInstance()
Create instance of database specific schema. |
java.lang.String |
getDeleteMappedDataById()
Get query to delete mapped data by id. |
java.lang.String |
getDeleteMappingRecord()
Method returns simple delete mapping record query. |
java.lang.String |
getInsertMappingRecord()
Method returns simple insert mapping record query. |
java.lang.String |
getSelectMappedDataById(int[] columns)
Get query to select mapped data by id. |
protected void |
handleInsertMappedDataException(java.sql.SQLException exc)
Common exception handler for insert of mapped data. |
protected void |
handleUpdateMappedDataException(java.sql.SQLException exc,
java.sql.Connection dbConnection,
MappedData data)
Common exception handler for update of mapped data. |
MappedData |
insertMappedData(java.sql.Connection cntDBConnection,
MappedData data)
Insert MappedData to the database and return the generated values. |
MappedData |
updateMappedData(java.sql.Connection cntDBConnection,
MappedData data)
Update MappedData in the database and return the generated values. |
| Methods inherited from class org.opensubsystems.core.persist.db.ModifiableDatabaseSchemaImpl |
|---|
deleteRelatedData, getModifiableTableNames, handleSQLException |
| Methods inherited from class org.opensubsystems.core.persist.db.DatabaseSchemaImpl |
|---|
getDependentSchemas, getJoinFromWhere, getName, getOwnerColumnNames, getSchemaPrefix, getVersion, isExistingIndex, isInDomain, upgrade, upgradeView |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.opensubsystems.core.persist.db.DatabaseSchema |
|---|
getDependentSchemas, getName, getVersion, isInDomain, upgrade |
| Field Detail |
|---|
public static final java.lang.String MAPPING_SCHEMA_NAME
public static final int MAPPING_SCHEMA_VERSION
public static final java.lang.String MAPPING_SCHEMA_COLUMN1
public static final java.lang.String MAPPING_SCHEMA_COLUMN2
public static final int MAPPING_CUSTOM_DATA_MAXLENGTH
protected java.lang.String m_strMapTableName
protected java.lang.Class m_schema1
protected java.lang.String m_strTableName1
protected java.lang.String m_strColumnName1
protected java.lang.Class m_schema2
protected java.lang.String m_strTableName2
protected java.lang.String m_strColumnName2
protected java.lang.String m_strConstraintBody
| Constructor Detail |
|---|
public MappingDatabaseSchema(java.lang.String strMapTableName,
java.lang.Class schema1,
java.lang.String strTableName1,
java.lang.String strColumnName1,
java.lang.Class schema2,
java.lang.String strTableName2,
java.lang.String strColumnName2)
throws org.opensubsystems.core.error.OSSException
strMapTableName - - table name for mapping tableschema1 - - schema name the table 1 was defined instrTableName1 - - name of the table 1strColumnName1 - - name of the column 1schema2 - - schema name the table 2 was defined instrTableName2 - - name of the table 2strColumnName2 - - name of the column 2
org.opensubsystems.core.error.OSSException - - an error has occured| Method Detail |
|---|
public void create(java.sql.Connection cntDBConnection,
java.lang.String strUserName)
throws java.sql.SQLException,
org.opensubsystems.core.error.OSSException
java.sql.SQLException
org.opensubsystems.core.error.OSSExceptionpublic MappedData insertMappedData(java.sql.Connection cntDBConnection, MappedData data) throws org.opensubsystems.core.error.OSSException
cntDBConnection - - database connectiondata - - MappedData to insert
org.opensubsystems.core.error.OSSException - - an error has occuredpublic MappedData updateMappedData(java.sql.Connection cntDBConnection, MappedData data) throws org.opensubsystems.core.error.OSSException
cntDBConnection - - database connectiondata - - MappedData to update
org.opensubsystems.core.error.OSSException - - an error has occured
public java.lang.String getInsertMappingRecord()
throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - exception during getting query
public java.lang.String getDeleteMappingRecord()
throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - exception during getting query
public java.lang.String geSelectMappingRecords()
throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - exception during getting query
public java.lang.String geSelectMappingMultipleRecords(java.lang.String strColumnIDs)
throws org.opensubsystems.core.error.OSSException
strColumnIDs - - string representation of column IDs separated by ','
org.opensubsystems.core.error.OSSException - - exception during getting query
public java.lang.String getSelectMappedDataById(int[] columns)
throws org.opensubsystems.core.error.OSSException
columns - - list of columns to retrieve
org.opensubsystems.core.error.OSSException - - an error has occuredpublic java.lang.String getDeleteMappedDataById()
public java.lang.StringBuffer getColumns(boolean specific,
int[] columns,
java.lang.Object[] prefixes,
java.lang.Object[] postfixes,
java.lang.StringBuffer buffer)
throws org.opensubsystems.core.error.OSSException
specific - - if true - table_name.table_column, if false only table_columncolumns - - specific array of columns codesprefixes - - specific array of prefixes to prepend before each column,
each prefix will be mapped with column and the same index
they will be directly prepended or appended to the column
name and therefore they need to contain any extra space if
necessary,
specify null, if no prefixes should be prependedpostfixes - - specific array of postfixes to prepend before each column,
each prefix will be mapped with column and the same index
they will be directly prepended or appended to the column
name and therefore they need to contain any extra space if
necessary,
specify null, if no prefixes should be prependedbuffer - - buffer to use for column codes construction, it may
already contain some value, if null, new one will be allocated
org.opensubsystems.core.error.OSSException - - error in columns find
protected void handleInsertMappedDataException(java.sql.SQLException exc)
throws org.opensubsystems.core.error.OSSException
exc - - exception which has occured
org.opensubsystems.core.error.OSSException - - more descriptive exception
protected void handleUpdateMappedDataException(java.sql.SQLException exc,
java.sql.Connection dbConnection,
MappedData data)
throws org.opensubsystems.core.error.OSSException
exc - - exception which has occureddbConnection - - database connectiondata - - data being updated
org.opensubsystems.core.error.OSSException - - more descriptive exception
protected java.lang.String constructSQL(java.lang.String strIDDefinition,
java.lang.String strColDataType,
java.lang.String strTextDataType,
java.lang.String strTmstpDataType,
java.lang.String strConstraintBody,
boolean bCascade,
boolean bPKConstraint)
strIDDefinition - - definition for ID columnstrColDataType - - datatype of the new columnstrTextDataType - - datatype of the text column (custom data)strTmstpDataType - - datatype of the timestamp columns
(creation and modification date)strConstraintBody - - body of the constraint namebCascade - - flag signaling if there will be added ON DELETE CASCADE
to foreign key constraint definitionbPKConstraint - - flag signaling if there will be defined primary key constraint
protected java.lang.String constructConstraintName()
protected MappingDatabaseSchema getDatabaseSpecificInstance() throws org.opensubsystems.core.error.OSSException
org.opensubsystems.core.error.OSSException - - an error has occured
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||