org.apache.ibatis.abator.internal.rules
Class AbatorRules

java.lang.Object
  extended byorg.apache.ibatis.abator.internal.rules.AbatorRules
Direct Known Subclasses:
ConditionalModelRules, FlatModelRules, HierarchicalModelRules

public abstract class AbatorRules
extends java.lang.Object

This class centralizes all the rules related to code generation - including the methods and objects to create, and certain attributes related to those objects. See package JavaDoc for more information.

Author:
Jeff Butler

Field Summary
protected  ColumnDefinitions columnDefinitions
           
protected  TableConfiguration tableConfiguration
           
 
Constructor Summary
AbatorRules(TableConfiguration tableConfiguration, ColumnDefinitions columnDefinitions)
           
 
Method Summary
 FullyQualifiedJavaType calculateAllFieldsClass(JavaModelGenerator javaModelGenerator, FullyQualifiedTable table)
          Calculates the class that contains all fields.
abstract  boolean generateBaseRecordClass()
          Implements the rule for generating a base record.
 boolean generateBaseResultMap()
          Implements the rule for generating the result map without BLOBs.
 boolean generateCountByExample()
           
 boolean generateDeleteByExample()
          Implements the rule for generating the delete by example SQL Map element and DAO method.
 boolean generateDeleteByPrimaryKey()
          Implements the rule for generating the delete by primary key SQL Map element and DAO method.
 boolean generateExampleClass()
          Implements the rule for generating an example class.
 boolean generateInsert()
          Implements the rule for generating the insert SQL Map element and DAO method.
abstract  boolean generatePrimaryKeyClass()
          Implements the rule for determining whether to generate a primary key class.
abstract  boolean generateRecordWithBLOBsClass()
          Implements the rule for generating a record with BLOBs.
 boolean generateResultMapWithBLOBs()
          Implements the rule for generating the result map with BLOBs.
 boolean generateSelectByExampleWithBLOBs()
          Implements the rule for generating the select by example with BLOBs SQL Map element and DAO method.
 boolean generateSelectByExampleWithoutBLOBs()
          Implements the rule for generating the select by example without BLOBs SQL Map element and DAO method.
 boolean generateSelectByPrimaryKey()
          Implements the rule for generating the select by primary key SQL Map element and DAO method.
 boolean generateSQLExampleWhereClause()
          Implements the rule for generating the SQL example where clause element.
 boolean generateUpdateByExampleSelective()
           
 boolean generateUpdateByExampleWithBLOBs()
           
 boolean generateUpdateByExampleWithoutBLOBs()
           
 boolean generateUpdateByPrimaryKeySelective()
          Implements the rule for generating the update by primary key selective SQL Map element and DAO method.
 boolean generateUpdateByPrimaryKeyWithBLOBs()
          Implements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method.
 boolean generateUpdateByPrimaryKeyWithoutBLOBs()
          Implements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableConfiguration

protected TableConfiguration tableConfiguration

columnDefinitions

protected ColumnDefinitions columnDefinitions
Constructor Detail

AbatorRules

public AbatorRules(TableConfiguration tableConfiguration,
                   ColumnDefinitions columnDefinitions)
Method Detail

generateInsert

public boolean generateInsert()
Implements the rule for generating the insert SQL Map element and DAO method. If the insert statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

calculateAllFieldsClass

public FullyQualifiedJavaType calculateAllFieldsClass(JavaModelGenerator javaModelGenerator,
                                                      FullyQualifiedTable table)
Calculates the class that contains all fields. This class is used as the insert statement parameter, as well as the returned value from the select by primary key method. The actual class depends on how the domain model is generated.

Parameters:
javaModelGenerator -
table -
Returns:
the type of the class that holds all fields

generateUpdateByPrimaryKeyWithoutBLOBs

public boolean generateUpdateByPrimaryKeyWithoutBLOBs()
Implements the rule for generating the update by primary key without BLOBs SQL Map element and DAO method. If the table has a primary key as well as other non-BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateUpdateByPrimaryKeyWithBLOBs

public boolean generateUpdateByPrimaryKeyWithBLOBs()
Implements the rule for generating the update by primary key with BLOBs SQL Map element and DAO method. If the table has a primary key as well as other BLOB fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateUpdateByPrimaryKeySelective

public boolean generateUpdateByPrimaryKeySelective()
Implements the rule for generating the update by primary key selective SQL Map element and DAO method. If the table has a primary key as well as other fields, and the updateByPrimaryKey statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateDeleteByPrimaryKey

public boolean generateDeleteByPrimaryKey()
Implements the rule for generating the delete by primary key SQL Map element and DAO method. If the table has a primary key, and the deleteByPrimaryKey statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateDeleteByExample

public boolean generateDeleteByExample()
Implements the rule for generating the delete by example SQL Map element and DAO method. If the deleteByExample statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateBaseResultMap

public boolean generateBaseResultMap()
Implements the rule for generating the result map without BLOBs. If either select method is allowed, then generate the result map.

Returns:
true if the result map should be generated

generateResultMapWithBLOBs

public boolean generateResultMapWithBLOBs()
Implements the rule for generating the result map with BLOBs. If the table has BLOB columns, and either select method is allowed, then generate the result map.

Returns:
true if the result map should be generated

generateSQLExampleWhereClause

public boolean generateSQLExampleWhereClause()
Implements the rule for generating the SQL example where clause element. Generate the element if the selectByExample or deleteByExample or countByExample statements are allowed.

Returns:
true if the SQL where clause element should be generated

generateSelectByPrimaryKey

public boolean generateSelectByPrimaryKey()
Implements the rule for generating the select by primary key SQL Map element and DAO method. If the table has a primary key as well as other fields, and the selectByPrimaryKey statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateSelectByExampleWithoutBLOBs

public boolean generateSelectByExampleWithoutBLOBs()
Implements the rule for generating the select by example without BLOBs SQL Map element and DAO method. If the selectByExample statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateSelectByExampleWithBLOBs

public boolean generateSelectByExampleWithBLOBs()
Implements the rule for generating the select by example with BLOBs SQL Map element and DAO method. If the table has BLOB fields and the selectByExample statement is allowed, then generate the element and method.

Returns:
true if the element and method should be generated

generateExampleClass

public boolean generateExampleClass()
Implements the rule for generating an example class. The class should be generated if the selectByExample or deleteByExample or countByExample methods are allowed.

Returns:
true if the example class should be generated

generateCountByExample

public boolean generateCountByExample()

generateUpdateByExampleSelective

public boolean generateUpdateByExampleSelective()

generateUpdateByExampleWithoutBLOBs

public boolean generateUpdateByExampleWithoutBLOBs()

generateUpdateByExampleWithBLOBs

public boolean generateUpdateByExampleWithBLOBs()

generatePrimaryKeyClass

public abstract boolean generatePrimaryKeyClass()
Implements the rule for determining whether to generate a primary key class. If you return false from this method, and the table has primary key columns, then the primary key columns will be added to the base class.

Returns:
true if a seperate primary key class should be generated

generateBaseRecordClass

public abstract boolean generateBaseRecordClass()
Implements the rule for generating a base record.

Returns:
true if the class should be generated

generateRecordWithBLOBsClass

public abstract boolean generateRecordWithBLOBsClass()
Implements the rule for generating a record with BLOBs. If you return false from this method, and the table had BLOB columns, then the BLOB columns will be added to the base class.

Returns:
true if the record with BLOBs class should be generated