org.apache.ibatis.abator.internal.sqlmap
Class SqlMapGeneratorIterateImpl

java.lang.Object
  extended by org.apache.ibatis.abator.internal.sqlmap.SqlMapGeneratorIterateImpl
All Implemented Interfaces:
SqlMapGenerator
Direct Known Subclasses:
SqlMapGeneratorLegacyImpl

public class SqlMapGeneratorIterateImpl
extends java.lang.Object
implements SqlMapGenerator

Author:
Jeff Butler

Field Summary
protected  AbatorContext abatorContext
           
protected  JavaModelGenerator javaModelGenerator
          This is the java model generator associated with the current generation context.
protected  java.util.Properties properties
          Contains any properties passed in from the SqlMap configuration element.
protected  java.lang.String targetPackage
          This is the target package from the SqlMap configuration element
protected  java.lang.String targetProject
          This is the target project from the SqlMap configuration element
protected  java.util.List warnings
           
 
Constructor Summary
SqlMapGeneratorIterateImpl()
          Constructs an instance of SqlMapGeneratorDefaultImpl
 
Method Summary
 void addConfigurationProperties(java.util.Properties properties)
          Adds properties for this instance from any properties configured in the SqlMapGeneratorConfiguration.
protected  void afterGenerationHook(IntrospectedTable introspectedTable, Document generatedDocument)
          Override this method to provide any extra Elements needed in the generated XML.
protected  XmlElement getBaseResultMapElement(IntrospectedTable introspectedTable)
          This method should return an XmlElement which is the result map (without any BLOBs if they exist in the table).
protected  XmlElement getByExampleWhereClauseFragment(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the example where clause SQL fragment (an sql fragment).
protected  XmlElement getCountByExample(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the count by example statement.
 java.lang.String getCountByExampleStatementId()
           
protected  XmlElement getDeleteByExample(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the delete by example statement.
 java.lang.String getDeleteByExampleStatementId()
           
protected  XmlElement getDeleteByPrimaryKey(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the delete by primary key statement.
 java.lang.String getDeleteByPrimaryKeyStatementId()
           
protected  java.lang.String getExampleWhereClauseId()
          Calculates the name of the example where clause element.
 java.util.List getGeneratedXMLFiles(IntrospectedTable introspectedTable, ProgressCallback callback)
           
protected  XmlElement getInsertElement(IntrospectedTable introspectedTable)
          This method should return an XmlElement which the insert statement.
 java.lang.String getInsertStatementId()
           
protected  java.lang.String getResultMapName(FullyQualifiedTable table)
          Calculates the name of the result map.
protected  XmlElement getResultMapWithBLOBsElement(IntrospectedTable introspectedTable)
          This method should return an XmlElement which is the result map (with any BLOBs if they exist in the table).
protected  XmlElement getSelectByExample(IntrospectedTable introspectedTable)
          This method should an XmlElement for the select by example statement that returns all fields in the table (except BLOB fields).
 java.lang.String getSelectByExampleStatementId()
           
protected  XmlElement getSelectByExampleWithBLOBs(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the select by example statement that returns all fields in the table (including BLOB fields).
 java.lang.String getSelectByExampleWithBLOBsStatementId()
           
protected  XmlElement getSelectByPrimaryKey(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the select by primary key statement.
 java.lang.String getSelectByPrimaryKeyStatementId()
           
protected  XmlElement getSelectKey(ColumnDefinition columnDefinition, GeneratedKey generatedKey)
          This method should return an XmlElement for the select key used to automatically generate keys.
protected  GeneratedXmlFile getSqlMap(IntrospectedTable introspectedTable)
          Creates the default implementation of the Sql Map
protected  XmlElement getSqlMapElement(IntrospectedTable introspectedTable)
          Creates the sqlMap element (the root element, and all child elements).
protected  java.lang.String getSqlMapFileName(FullyQualifiedTable table)
          Calculates a file name for the current table.
 java.lang.String getSqlMapNamespace(FullyQualifiedTable table)
           
protected  java.lang.String getSqlMapPackage(FullyQualifiedTable table)
          Calculates the package for the current table.
protected  XmlElement getUpdateByExampleSelective(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the update by example statement that updates all fields in the table - but only if the field is not null in the parameter object.
 java.lang.String getUpdateByExampleSelectiveStatementId()
           
 java.lang.String getUpdateByExampleStatementId()
           
protected  XmlElement getUpdateByExampleWithBLOBs(IntrospectedTable introspectedTable)
           
 java.lang.String getUpdateByExampleWithBLOBsStatementId()
           
protected  XmlElement getUpdateByExampleWithoutBLOBs(IntrospectedTable introspectedTable)
           
protected  XmlElement getUpdateByPrimaryKeySelective(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the update by primary key statement that updates all fields in the table - but only if the field is not null in the parameter object.
 java.lang.String getUpdateByPrimaryKeySelectiveStatementId()
           
 java.lang.String getUpdateByPrimaryKeyStatementId()
           
protected  XmlElement getUpdateByPrimaryKeyWithBLOBs(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the update by primary key statement that updates all fields in the table (including BLOB fields).
 java.lang.String getUpdateByPrimaryKeyWithBLOBsStatementId()
           
protected  XmlElement getUpdateByPrimaryKeyWithoutBLOBs(IntrospectedTable introspectedTable)
          This method should return an XmlElement for the update by primary key statement that updates all fields in the table (excluding BLOB fields).
 void setAbatorContext(AbatorContext abatorContext)
          Sets the instance of the AbatorConfiguration object associated with this instance.
 void setJavaModelGenerator(JavaModelGenerator javaModelGenerator)
           
 void setTargetPackage(java.lang.String targetPackage)
           
 void setTargetProject(java.lang.String targetProject)
           
 void setWarnings(java.util.List warnings)
          Abator will supply a list to this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

warnings

protected java.util.List warnings

abatorContext

protected AbatorContext abatorContext

properties

protected java.util.Properties properties
Contains any properties passed in from the SqlMap configuration element.


targetPackage

protected java.lang.String targetPackage
This is the target package from the SqlMap configuration element


targetProject

protected java.lang.String targetProject
This is the target project from the SqlMap configuration element


javaModelGenerator

protected JavaModelGenerator javaModelGenerator
This is the java model generator associated with the current generation context. Methods in this interface can be used to determine the appropriate result and parameter class names.

Constructor Detail

SqlMapGeneratorIterateImpl

public SqlMapGeneratorIterateImpl()
Constructs an instance of SqlMapGeneratorDefaultImpl

Method Detail

addConfigurationProperties

public void addConfigurationProperties(java.util.Properties properties)
Description copied from interface: SqlMapGenerator
Adds properties for this instance from any properties configured in the SqlMapGeneratorConfiguration. This method will be called before any of the get methods.

Specified by:
addConfigurationProperties in interface SqlMapGenerator
Parameters:
properties - All properties from the configuration

setTargetPackage

public void setTargetPackage(java.lang.String targetPackage)
Specified by:
setTargetPackage in interface SqlMapGenerator

setJavaModelGenerator

public void setJavaModelGenerator(JavaModelGenerator javaModelGenerator)
Specified by:
setJavaModelGenerator in interface SqlMapGenerator

getGeneratedXMLFiles

public java.util.List getGeneratedXMLFiles(IntrospectedTable introspectedTable,
                                           ProgressCallback callback)
Specified by:
getGeneratedXMLFiles in interface SqlMapGenerator

getSqlMap

protected GeneratedXmlFile getSqlMap(IntrospectedTable introspectedTable)
Creates the default implementation of the Sql Map

Parameters:
introspectedTable -
Returns:
A GeneratedXMLFile for the current table

getSqlMapElement

protected XmlElement getSqlMapElement(IntrospectedTable introspectedTable)
Creates the sqlMap element (the root element, and all child elements).

Parameters:
introspectedTable -
Returns:
the sqlMap element including all child elements

afterGenerationHook

protected void afterGenerationHook(IntrospectedTable introspectedTable,
                                   Document generatedDocument)
Override this method to provide any extra Elements needed in the generated XML.

Parameters:
generatedDocument - the generated document

getBaseResultMapElement

protected XmlElement getBaseResultMapElement(IntrospectedTable introspectedTable)
This method should return an XmlElement which is the result map (without any BLOBs if they exist in the table).

Parameters:
introspectedTable -
Returns:
the resultMap element

getResultMapWithBLOBsElement

protected XmlElement getResultMapWithBLOBsElement(IntrospectedTable introspectedTable)
This method should return an XmlElement which is the result map (with any BLOBs if they exist in the table). Typically this result map extends the base result map.

Parameters:
introspectedTable -
Returns:
the resultMap element

getInsertElement

protected XmlElement getInsertElement(IntrospectedTable introspectedTable)
This method should return an XmlElement which the insert statement.

Parameters:
introspectedTable -
Returns:
the insert element

getUpdateByPrimaryKeyWithBLOBs

protected XmlElement getUpdateByPrimaryKeyWithBLOBs(IntrospectedTable introspectedTable)
This method should return an XmlElement for the update by primary key statement that updates all fields in the table (including BLOB fields).

Parameters:
introspectedTable -
Returns:
the update element

getUpdateByPrimaryKeyWithoutBLOBs

protected XmlElement getUpdateByPrimaryKeyWithoutBLOBs(IntrospectedTable introspectedTable)
This method should return an XmlElement for the update by primary key statement that updates all fields in the table (excluding BLOB fields).

Parameters:
introspectedTable -
Returns:
the update element

getDeleteByPrimaryKey

protected XmlElement getDeleteByPrimaryKey(IntrospectedTable introspectedTable)
This method should return an XmlElement for the delete by primary key statement.

Parameters:
introspectedTable -
Returns:
the delete element

getDeleteByExample

protected XmlElement getDeleteByExample(IntrospectedTable introspectedTable)
This method should return an XmlElement for the delete by example statement. This statement uses the "by example" SQL fragment

Parameters:
introspectedTable -
Returns:
the delete by example element

getCountByExample

protected XmlElement getCountByExample(IntrospectedTable introspectedTable)
This method should return an XmlElement for the count by example statement. This statement uses the "by example" SQL fragment

Parameters:
introspectedTable -
Returns:
the count by example element

getSelectByPrimaryKey

protected XmlElement getSelectByPrimaryKey(IntrospectedTable introspectedTable)
This method should return an XmlElement for the select by primary key statement. The statement should include all fields in the table, including BLOB fields.

Parameters:
introspectedTable -
Returns:
the select by primary key element

getSelectKey

protected XmlElement getSelectKey(ColumnDefinition columnDefinition,
                                  GeneratedKey generatedKey)
This method should return an XmlElement for the select key used to automatically generate keys.

Parameters:
columnDefinition - the column related to the select key statement
generatedKey - the generated key for the current table
Returns:
the selectKey element

getSqlMapNamespace

public java.lang.String getSqlMapNamespace(FullyQualifiedTable table)
Specified by:
getSqlMapNamespace in interface SqlMapGenerator

getResultMapName

protected java.lang.String getResultMapName(FullyQualifiedTable table)
Calculates the name of the result map. Typically this is the String "abatorgenerated_XXXXResult" where XXXX is the name of the domain object related to this table. The prefix "abatorgenerated_" is important because it allows Abator to regenerate this element on subsequent runs.

Parameters:
table - the current table
Returns:
the name of the result map

getSqlMapFileName

protected java.lang.String getSqlMapFileName(FullyQualifiedTable table)
Calculates a file name for the current table. Typically the name is "XXXX_SqlMap.xml" where XXXX is the fully qualified table name (delimited with underscores).

Parameters:
table - the current table
Returns:
tha name of the SqlMap file

getDeleteByPrimaryKeyStatementId

public java.lang.String getDeleteByPrimaryKeyStatementId()
Specified by:
getDeleteByPrimaryKeyStatementId in interface SqlMapGenerator

getDeleteByExampleStatementId

public java.lang.String getDeleteByExampleStatementId()
Specified by:
getDeleteByExampleStatementId in interface SqlMapGenerator

getCountByExampleStatementId

public java.lang.String getCountByExampleStatementId()
Specified by:
getCountByExampleStatementId in interface SqlMapGenerator

getInsertStatementId

public java.lang.String getInsertStatementId()
Specified by:
getInsertStatementId in interface SqlMapGenerator

getSelectByPrimaryKeyStatementId

public java.lang.String getSelectByPrimaryKeyStatementId()
Specified by:
getSelectByPrimaryKeyStatementId in interface SqlMapGenerator

getSelectByExampleStatementId

public java.lang.String getSelectByExampleStatementId()
Specified by:
getSelectByExampleStatementId in interface SqlMapGenerator

getSelectByExampleWithBLOBsStatementId

public java.lang.String getSelectByExampleWithBLOBsStatementId()
Specified by:
getSelectByExampleWithBLOBsStatementId in interface SqlMapGenerator

getUpdateByPrimaryKeyWithBLOBsStatementId

public java.lang.String getUpdateByPrimaryKeyWithBLOBsStatementId()
Specified by:
getUpdateByPrimaryKeyWithBLOBsStatementId in interface SqlMapGenerator

getUpdateByPrimaryKeyStatementId

public java.lang.String getUpdateByPrimaryKeyStatementId()
Specified by:
getUpdateByPrimaryKeyStatementId in interface SqlMapGenerator

getUpdateByPrimaryKeySelectiveStatementId

public java.lang.String getUpdateByPrimaryKeySelectiveStatementId()
Specified by:
getUpdateByPrimaryKeySelectiveStatementId in interface SqlMapGenerator

getUpdateByExampleSelectiveStatementId

public java.lang.String getUpdateByExampleSelectiveStatementId()
Specified by:
getUpdateByExampleSelectiveStatementId in interface SqlMapGenerator

getSqlMapPackage

protected java.lang.String getSqlMapPackage(FullyQualifiedTable table)
Calculates the package for the current table.

Parameters:
table - the current table
Returns:
the package for the SqlMap for the current table

getExampleWhereClauseId

protected java.lang.String getExampleWhereClauseId()
Calculates the name of the example where clause element.

Returns:
the name of the example where clause element

getByExampleWhereClauseFragment

protected XmlElement getByExampleWhereClauseFragment(IntrospectedTable introspectedTable)
This method should return an XmlElement for the example where clause SQL fragment (an sql fragment).

Parameters:
introspectedTable -
Returns:
the SQL element

getSelectByExample

protected XmlElement getSelectByExample(IntrospectedTable introspectedTable)
This method should an XmlElement for the select by example statement that returns all fields in the table (except BLOB fields).

Parameters:
introspectedTable -
Returns:
the select element

getSelectByExampleWithBLOBs

protected XmlElement getSelectByExampleWithBLOBs(IntrospectedTable introspectedTable)
This method should return an XmlElement for the select by example statement that returns all fields in the table (including BLOB fields).

Parameters:
introspectedTable -
Returns:
the select element

setTargetProject

public void setTargetProject(java.lang.String targetProject)
Specified by:
setTargetProject in interface SqlMapGenerator

setWarnings

public void setWarnings(java.util.List warnings)
Description copied from interface: SqlMapGenerator
Abator will supply a list to this method. The implementation class may add strings to the list that will be treated as warning messages and displayed to the user. The concept of a warning is that code generation can continue, but that the results may not be what is expected.

Specified by:
setWarnings in interface SqlMapGenerator

getUpdateByPrimaryKeySelective

protected XmlElement getUpdateByPrimaryKeySelective(IntrospectedTable introspectedTable)
This method should return an XmlElement for the update by primary key statement that updates all fields in the table - but only if the field is not null in the parameter object.

Parameters:
introspectedTable -
Returns:
the update element

setAbatorContext

public void setAbatorContext(AbatorContext abatorContext)
Description copied from interface: SqlMapGenerator
Sets the instance of the AbatorConfiguration object associated with this instance. This method will be called before any of the get methods.

Specified by:
setAbatorContext in interface SqlMapGenerator
Parameters:
abatorContext - The current AbatorContext

getUpdateByExampleSelective

protected XmlElement getUpdateByExampleSelective(IntrospectedTable introspectedTable)
This method should return an XmlElement for the update by example statement that updates all fields in the table - but only if the field is not null in the parameter object.

Parameters:
introspectedTable -
Returns:
the update element

getUpdateByExampleWithBLOBs

protected XmlElement getUpdateByExampleWithBLOBs(IntrospectedTable introspectedTable)

getUpdateByExampleWithoutBLOBs

protected XmlElement getUpdateByExampleWithoutBLOBs(IntrospectedTable introspectedTable)

getUpdateByExampleStatementId

public java.lang.String getUpdateByExampleStatementId()
Specified by:
getUpdateByExampleStatementId in interface SqlMapGenerator

getUpdateByExampleWithBLOBsStatementId

public java.lang.String getUpdateByExampleWithBLOBsStatementId()
Specified by:
getUpdateByExampleWithBLOBsStatementId in interface SqlMapGenerator