mikeh       01/05/15 15:54:32

  Modified:    conf/torque/templates/om Peer.vm
  Log:
  final patch needed for input validation (next comes documentation)
  also some tab replacements with spaces
  
  Revision  Changes    Path
  1.57      +38 -7     jakarta-turbine/conf/torque/templates/om/Peer.vm
  
  Index: Peer.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/om/Peer.vm,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- Peer.vm   2001/05/15 01:29:29     1.56
  +++ Peer.vm   2001/05/15 22:54:27     1.57
  @@ -22,6 +22,7 @@
   import org.apache.turbine.util.db.map.*;
   import org.apache.turbine.util.db.pool.DBConnection;
   import org.apache.turbine.services.db.TurbineDB;
  +import org.apache.turbine.util.validation.InputValidator;
   
   // Local classes
   import ${package}.map.*;
  @@ -52,16 +53,46 @@
        */
       public static MapBuilder getMapBuilder()
       {
  -     return(mapBuilder);
  +       return(mapBuilder);
       }
   
  +#set ($doInputValidation = false)
   #foreach ($col in $table.Columns)
       #set ( $tfc=$table.JavaName )
       #set ( $cfc=$col.JavaName )
       #set ( $cup=$col.Name.toUpperCase() )
       /** the column name for the $cup field */
       public static final String $cup = mapBuilder.get${tfc}_${cfc}();
  +    #if ($col.InputValidator) 
  +       #set ($doInputValidation = true)
  +    #end
  +#end
  +
  +#if ($doInputValidation) 
  +    static {
  +              try {
  +          InputValidator tmp;
  +#foreach ($col in $table.Columns)
  +    #set ( $tfc=$table.JavaName )
  +    #set ( $cfc=$col.JavaName )
  +    #set ( $cup=$col.Name.toUpperCase() )
  +#if ($col.InputValidator) 
  +          tmp = setInputValidator($cup, "$col.InputValidator");
  +#if ($col.isNotNull()) 
  +          tmp.setAllowNullInput(false);
  +#else
  +          tmp.setAllowNullInput(true);
  +#end
  +#if ($col.Size) 
  +          tmp.setMaxSize($col.Size);
  +#end
  +#end
   #end
  +              }catch(Exception e){
  +                      Log.error(e);
  +              }
  +    }
  +#end
   
       /** number of columns for this peer */
       public static final int numColumns =  $table.NumColumns;
  @@ -844,7 +875,7 @@
               #set ( $cup=$col.Name.toUpperCase() )
               #if ($col.isPrimaryKey() && !$table.IdMethod.equals("none"))
           if ( !obj.isNew() )
  -         #end
  +           #end
               criteria.add( $cup, obj.get${cfc}() );
           #end
           return criteria;
  @@ -860,7 +891,7 @@
       {
           DBConnection db = null;
           $table.JavaName retVal = null;
  -     try
  +       try
           {
              db = TurbineDB.getConnection( mapBuilder.getDatabaseMap().getName() );
              retVal = retrieveByPK( pk, db );
  @@ -929,14 +960,14 @@
       {
           DBConnection db = null;
           $table.JavaName retVal = null;
  -     try
  +       try
           {
              db = TurbineDB.getConnection( mapBuilder.getDatabaseMap().getName() );
              retVal = retrieveByPK( 
              #set ( $comma = false )
              #foreach ($col in $table.PrimaryKeys)
  -           #set ( $clo=$col.Name.toLowerCase() )
  -           #if ($comma),#end $clo
  +         #set ( $clo=$col.Name.toLowerCase() )
  +         #if ($comma),#end $clo
                 #set ( $comma = true )
              #end
                  , db);
  @@ -947,7 +978,7 @@
                 TurbineDB.releaseConnection(db);
           }
           return(retVal);
  -    }        
  +    }   
   
   #set ( $comma = false )
       /** 
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to