package ${package}.map; import java.util.*; import java.math.*; import org.apache.torque.Torque; import org.apache.torque.map.MapBuilder; import org.apache.torque.map.DatabaseMap; import org.apache.torque.map.TableMap; /** #if ($addTimeStamp) * This class was autogenerated by Torque on: * * [$now] * #end */ public class ${table.JavaName}MapBuilder implements MapBuilder { /** * The name of this class */ public static final String CLASS_NAME = "${package}.map.${table.JavaName}MapBuilder"; /** * Item * @deprecated use ${table.JavaName}Peer.TABLE_NAME constant */ public static String getTable( ) { return "$table.Name"; } #foreach ($col in $table.Columns) #set ( $tfc=$table.JavaName ) #set ( $cfc=$col.JavaName ) #set ( $cup=$col.Name.toUpperCase() ) /** * ${table.Name}.$cup * @deprecated use ${table.JavaName}Peer.${table.Name}.$cup constant */ public static String get${tfc}_${cfc}() { return "${table.Name}.$cup"; } #end /** * The database map. */ private DatabaseMap dbMap = null; /** * Tells us if this DatabaseMapBuilder is built so that we * don't have to re-build it every time. */ public boolean isBuilt() { if ( dbMap != null ) { return true; } return false; } /** * Gets the databasemap this map builder built. */ public DatabaseMap getDatabaseMap() { return this.dbMap; } /** * The doBuild() method builds the DatabaseMap */ public void doBuild() throws Exception { dbMap = Torque.getDatabaseMap("$table.Database.Name"); dbMap.addTable("$table.Name"); TableMap tMap = dbMap.getTable("$table.Name"); #if ($table.IdMethod == "native") tMap.setPrimaryKeyMethod(TableMap.NATIVE); #elseif ($table.IdMethod == "autoincrement") tMap.setPrimaryKeyMethod(TableMap.AUTO_INCREMENT); #elseif ($table.IdMethod == "sequence") tMap.setPrimaryKeyMethod(TableMap.SEQUENCE); #elseif ($table.IdMethod == "idbroker") tMap.setPrimaryKeyMethod(TableMap.ID_BROKER); #else tMap.setPrimaryKeyMethod("$table.IdMethod"); #end #if ($table.IdMethod == "idbroker") tMap.setPrimaryKeyMethodInfo(tMap.getName()); #elseif ($table.IdMethod == "sequence" || ($table.IdMethod == "native" && $dbprops.get("idMethod") == "sequence")) tMap.setPrimaryKeyMethodInfo("$table.SequenceName"); #elseif ($table.IdMethodParameters) // this might need upgrading based on what all the databases // need, but for now assume one parameter. #set ($imp = $table.IdMethodParameters.get(0) ) tMap.setPrimaryKeyMethodInfo("$imp.Value"); #end #foreach ($col in $table.Columns) #set ( $tfc=$table.JavaName ) #set ( $cfc=$col.JavaName ) #set ( $cup=$col.Name.toUpperCase() ) #if($col.isPrimaryKey()) #if($col.isForeignKey()) tMap.addForeignPrimaryKey ( "${table.Name}.$cup", $col.JavaObject , "$col.RelatedTableName" , "$col.RelatedColumnName" ); #else tMap.addPrimaryKey ( "${table.Name}.$cup", $col.JavaObject ); #end #else #if($col.isForeignKey()) tMap.addForeignKey ( "${table.Name}.$cup", $col.JavaObject , "$col.RelatedTableName" , "$col.RelatedColumnName" ); #else tMap.addColumn ( "${table.Name}.$cup", $col.JavaObject ); #end #end #end } }