|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jaxme.js.pattern.VersionGenerator
The VersionGenerator is able to clone a version of a row in a database. That is nothing special. A simple INSERT does the same.
The difference is that the VersionGenerator is able to clone rows in other tables referencing the cloned table as well, updating the references, and clone and update rows referencing these cloned and updated rows, and so on.
In other words: The VersionGenerator derives a new version of a complex object stored in the database.
The VersionGenerator operates on a list of tables. This list must not contain forward or self references. In other words: Under no circumstances may a table in the list contain a foreign key referencing another table, which follows later.
Nested Class Summary | |
static interface |
VersionGenerator.ColumnUpdater
The ColumnUpdater is able to update one or more columns in a table. |
static class |
VersionGenerator.TableInfo
This class is used internally to maintain the informations on the tables being cloned. |
Constructor Summary | |
VersionGenerator()
|
Method Summary | |
void |
addTable(Table pTable,
VersionGenerator.ColumnUpdater pUpdater)
Adds a new table to the list of tables. |
protected void |
getApplyCacheData(JavaMethod pMethod,
VersionGenerator.TableInfo pTableInfo,
ColumnSet pColumnSet,
DirectAccessible pRow,
DirectAccessible pData)
Updates a row by reading the values from an instance of the inner class CacheData. |
protected JavaInnerClass |
getCacheDataClass(JavaSource pSource)
Generates the innner class CacheData. |
protected LocalJavaField |
getCacheDataClassInstance(JavaMethod pMethod,
VersionGenerator.TableInfo pTableInfo,
ColumnSet pColumnSet,
DirectAccessible pValues)
Creates an instance of the inner class CacheData by reading the key from the given row. |
protected JavaQName |
getCacheDataClassName(JavaQName pQName)
Returns the name of the inner class CacheData. |
JavaMethod |
getCloneMethod(JavaSource pSource)
Creates a method for updating one row in the head table. |
protected JavaMethod |
getInnerInsertRowMethod(JavaSource pSource,
VersionGenerator.TableInfo pTableInfo)
Creates a method for cloning one row from the given table. |
protected JavaMethod |
getInsertRowMethod(JavaSource pSource,
VersionGenerator.TableInfo pTableInfo)
Creates a method for cloning one row from the given table. |
protected java.lang.String |
getInsertRowMethodName(VersionGenerator.TableInfo pTableInfo)
Returns the name of the method for cloning one row from the given table. |
protected JavaMethod |
getPublicCloneMethod(JavaSource pSource)
Actually creates the public "clone" method. |
protected void |
getSelectRowsCode(JavaMethod pMethod,
VersionGenerator.TableInfo pTableInfo,
ColumnSet pColumnSet,
DirectAccessible pConn,
DirectAccessible pMap,
DirectAccessible pValues,
boolean pReturnValue)
Generates code for reading all rows matching the given key. |
protected void |
initLogging(JavaSource pSource)
Creates the code for initialization of the logging framework. |
boolean |
isGeneratingLogging()
Returns whether the generator is creating logging statements. |
protected void |
logEntering(JavaMethod pMethod,
java.lang.Object pValues)
Creates code for logging the entrance into a method with fine level. |
protected void |
logExiting(JavaMethod pMethod,
java.lang.Object pValues)
Creates code for logging the exit from a method with fine level. |
protected void |
logFinest(JavaMethod pMethod,
java.lang.Object pMsg,
java.lang.Object pValues)
Creates code for logging a message with finest level. |
protected void |
logFinestEntering(JavaMethod pMethod,
java.lang.Object pValues)
Creates code for logging the entrance into a method with finest level. |
protected void |
logFinestExiting(JavaMethod pMethod,
java.lang.Object pValues)
Creates code for logging the exit from a method with fine level. |
void |
setGeneratingLogging(boolean pGeneratingLogging)
Sets whether the generator is creating logging statements. |
protected void |
setPreparedStatementValue(JavaMethod pMethod,
Column pColumn,
java.lang.Object pStmt,
java.lang.Object pParamNum,
java.lang.Object pValue)
Generates code for setting a PreparedStatement's parameter. |
protected void |
setResultSetValue(JavaMethod pMethod,
Column pColumn,
DirectAccessible pResultSet,
int pColumnNum,
java.lang.Object pTarget)
Generates code for reading a ResultSet's column. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public VersionGenerator()
Method Detail |
public boolean isGeneratingLogging()
Returns whether the generator is creating logging statements. By default no logging statements are created.
The default
implementation creates logging statements suitable for the JaxMe logging
package. To change this, create a subclass and overwrite the following
methods: logEntering(JavaMethod, Object)
,
logExiting(JavaMethod, Object)
, logFinest(JavaMethod, Object, Object)
,
logFinestEntering(JavaMethod, Object)
, and
logFinestExiting(JavaMethod, Object)
.
setGeneratingLogging(boolean)
public void setGeneratingLogging(boolean pGeneratingLogging)
Sets whether the generator is creating logging statements. By default no logging statements are created.
The default
implementation creates logging statements suitable for the JaxMe logging
package. To change this, create a subclass and overwrite the following
methods: logEntering(JavaMethod, Object)
,
logExiting(JavaMethod, Object)
, logFinest(JavaMethod, Object, Object)
,
logFinestEntering(JavaMethod, Object)
, and
logFinestExiting(JavaMethod, Object)
.
isGeneratingLogging()
protected void initLogging(JavaSource pSource)
Creates the code for initialization of the logging framework.
The default implementation generates code creating an instance of
Logger
.
protected void logEntering(JavaMethod pMethod, java.lang.Object pValues)
Creates code for logging the entrance into a method with fine level.
Note: The method should consider the isGeneratingLogging()
value.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly nullprotected void logFinestEntering(JavaMethod pMethod, java.lang.Object pValues)
Creates code for logging the entrance into a method with finest level.
Note: The method should consider the isGeneratingLogging()
value.
Implementation note: The default implementation is
equivalent to logFinest(pMethod, "->", pValues)
.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly nullprotected void logExiting(JavaMethod pMethod, java.lang.Object pValues)
Creates code for logging the exit from a method with fine level.
Note: The method should consider the isGeneratingLogging()
value.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly nullprotected void logFinestExiting(JavaMethod pMethod, java.lang.Object pValues)
Creates code for logging the exit from a method with fine level.
Note: The method should consider the isGeneratingLogging()
value.
Implementation note: The default implementation is
equivalent to logFinest(pMethod, "<-", pValues)
.
pMethod
- The method in which a logging statement should be insertedpValues
- An array of additional values, possibly nullprotected void logFinest(JavaMethod pMethod, java.lang.Object pMsg, java.lang.Object pValues)
Creates code for logging a message with finest level.
Note: The method should consider the isGeneratingLogging()
value.
pMethod
- The method in which a logging statement should be insertedpMsg
- The message being loggedpValues
- An array of additional values, possibly nullpublic void addTable(Table pTable, VersionGenerator.ColumnUpdater pUpdater)
pTable
- The table being clonedpUpdater
- The column updater to use for changing the
updated columns.protected JavaQName getCacheDataClassName(JavaQName pQName)
Returns the name of the inner class CacheData.
protected JavaInnerClass getCacheDataClass(JavaSource pSource)
Generates the innner class CacheData.
protected void setResultSetValue(JavaMethod pMethod, Column pColumn, DirectAccessible pResultSet, int pColumnNum, java.lang.Object pTarget)
Generates code for reading a ResultSet's column.
protected void setPreparedStatementValue(JavaMethod pMethod, Column pColumn, java.lang.Object pStmt, java.lang.Object pParamNum, java.lang.Object pValue)
Generates code for setting a PreparedStatement's parameter.
protected void getSelectRowsCode(JavaMethod pMethod, VersionGenerator.TableInfo pTableInfo, ColumnSet pColumnSet, DirectAccessible pConn, DirectAccessible pMap, DirectAccessible pValues, boolean pReturnValue)
Generates code for reading all rows matching the given key.
protected java.lang.String getInsertRowMethodName(VersionGenerator.TableInfo pTableInfo)
Returns the name of the method for cloning one row from the given table.
protected LocalJavaField getCacheDataClassInstance(JavaMethod pMethod, VersionGenerator.TableInfo pTableInfo, ColumnSet pColumnSet, DirectAccessible pValues)
Creates an instance of the inner class CacheData by reading the key from the given row.
protected void getApplyCacheData(JavaMethod pMethod, VersionGenerator.TableInfo pTableInfo, ColumnSet pColumnSet, DirectAccessible pRow, DirectAccessible pData)
Updates a row by reading the values from an instance of the inner class CacheData.
protected JavaMethod getInsertRowMethod(JavaSource pSource, VersionGenerator.TableInfo pTableInfo)
Creates a method for cloning one row from the given table.
protected JavaMethod getInnerInsertRowMethod(JavaSource pSource, VersionGenerator.TableInfo pTableInfo)
Creates a method for cloning one row from the given table.
protected JavaMethod getPublicCloneMethod(JavaSource pSource)
Actually creates the public "clone" method.
public JavaMethod getCloneMethod(JavaSource pSource)
Creates a method for updating one row in the head table.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |