db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/generator/src/templates/ojb/model Manager.vm BaseManager.vm BaseObject.vm Object.vm Control.vm ExtensionObject.vm
Date Thu, 11 Sep 2003 06:42:13 GMT
mpoeschl    2003/09/10 23:42:13

  Modified:    src/generator/src/templates/ojb/model Object.vm Control.vm
  Added:       src/generator/src/templates/ojb/model Manager.vm
                        BaseManager.vm BaseObject.vm
  Removed:     src/generator/src/templates/ojb/model ExtensionObject.vm
  Log:
  reorganize templates and add Manager classes
  expect more changes before the next release!
  
  Revision  Changes    Path
  1.5       +14 -35    db-torque/src/generator/src/templates/ojb/model/Object.vm
  
  Index: Object.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/ojb/model/Object.vm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Object.vm	8 Sep 2003 22:01:50 -0000	1.4
  +++ Object.vm	11 Sep 2003 06:42:13 -0000	1.5
  @@ -1,47 +1,26 @@
  -package ${package};
  -
  -#if ($table.BaseClass)
  -    #set ($extendsBaseClass = "extends $table.BaseClass" )
  -#else
  -    #set ($extendsBaseClass = "" )
  +#set ($interface = "")
  +#if ($table.Interface)
  +  #set ($interface = ", $table.Interface")
   #end
   
  -import java.io.Serializable;
  -import java.util.Date;
  -import java.math.BigDecimal;
  +package $package;
  +
  +#if ($table.isAbstract())
  +  #set ($abstract = "abstract")
  +#end
   
   /**
  - * ${table.JavaName}
   #if ($addTimeStamp)
  - * This class was autogenerated by Torque on:
  + * The skeleton for this class was autogenerated by Torque on:
    *
    * [$now]
    *
   #end
  + * You should add additional methods to this class to meet the
  + * application requirements.  This class will only be generated as
  + * long as it does not already exist in the output directory.
    */
  -public class ${basePrefix}${table.JavaName}
  +public $!abstract class $table.JavaName
  +    extends ${package}.$basePrefix$table.JavaName
   {
  -  #foreach ($col in $table.Columns)
  -    private $col.JavaPrimitive $col.UncapitalisedJavaName;
  -  #end
  -
  -  #foreach ($col in $table.Columns)
  -
  -    /**
  -     * Get the $col.JavaName
  -     * @return $col.JavaPrimitive
  -     */
  -    public $col.JavaPrimitive get${col.JavaName}()
  -    {
  -        return $col.UncapitalisedJavaName;
  -    }
  -
  -    /**
  -     * Set the value of $cfc
  -     */
  -    public void set${col.JavaName}($col.JavaPrimitive v)
  -    {
  -        this.$col.UncapitalisedJavaName = v;
  -    }
  -  #end
   }
  
  
  
  1.5       +12 -2     db-torque/src/generator/src/templates/ojb/model/Control.vm
  
  Index: Control.vm
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/templates/ojb/model/Control.vm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Control.vm	8 Sep 2003 22:01:50 -0000	1.4
  +++ Control.vm	11 Sep 2003 06:42:13 -0000	1.5
  @@ -20,12 +20,22 @@
           #set ( $fname = "${firstcap}.java" )
           #set ( $path = "${strings.getPackageAsPath($package)}$fname" )
           #if (!$files.file($basePath,$path).exists())
  -          $generator.parse("ojb/model/ExtensionObject.vm",$path,"table",$tbl)
  +          $generator.parse("ojb/model/Object.vm",$path,"table",$tbl)
           #end
   
           #set ( $fname = "${basePrefix}${firstcap}.java" )
           #set ( $path = "${strings.getPackageAsPath($package)}$fname" )
  -        $generator.parse("ojb/model/Object.vm",$path,"table",$tbl)
  +        $generator.parse("ojb/model/BaseObject.vm",$path,"table",$tbl)
  +        
  +        #set ( $fname = "${firstcap}Manager.java" )
  +        #set ( $path = "${strings.getPackageAsPath($package)}$fname" )
  +        #if (!$files.file($basePath,$path).exists())
  +          $generator.parse("ojb/model/Manager.vm",$path,"table",$tbl)
  +        #end
  +        
  +        #set ( $fname = "${basePrefix}${firstcap}Manager.java" )
  +        #set ( $path = "${strings.getPackageAsPath($package)}$fname" )
  +        $generator.parse("ojb/model/BaseManager.vm",$path,"table",$tbl)
         #end
       #end
     #end
  
  
  
  1.1                  db-torque/src/generator/src/templates/ojb/model/Manager.vm
  
  Index: Manager.vm
  ===================================================================
  #set ($interface = "")
  #if ($table.Interface)
    #set ($interface = ", $table.Interface")
  #end
  
  package $package;
  
  /**
  #if ($addTimeStamp)
   * The skeleton for this class was autogenerated by Torque on:
   *
   * [$now]
   *
  #end
   * You should add additional methods to this class to meet the
   * application requirements.  This class will only be generated as
   * long as it does not already exist in the output directory.
   */
  public class ${table.JavaName}Manager extends $basePrefix$table.JavaName
  {
      /** singleton instance */
      private static ${table.JavaName}Manager singleton;
  
      /**
       * Private constructor
       */
      private ${table.JavaName}Manager() {
          super();
      }
      
      /**
       * Get instance.
       * 
       * @return a instance
       */
      public static ${table.JavaName}Manager getInstance() {
          if (singleton == null) {
              singleton = new ${table.JavaName}Manager();
          }
          return singleton;
      }
  
  }
  
  
  
  1.1                  db-torque/src/generator/src/templates/ojb/model/BaseManager.vm
  
  Index: BaseManager.vm
  ===================================================================
  package ${package};
  
  import java.util.Collection;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.apache.ojb.broker.*;
  import org.apache.ojb.broker.query.*;
  
  /**
   * ${basePrefix}${table.JavaName}Manager.
  #if ($addTimeStamp)
   * This class was autogenerated by Torque on:
   *
   * [$now]
   *
  #end
   */
  public class ${basePrefix}${table.JavaName}Manager
  {
      /** Logging class from commons.logging */
      private static Log log = LogFactory.getLog(${basePrefix}${table.JavaName}Manager.class);
           
  
      protected PersistenceBroker getBroker() { 
          return PersistenceBrokerFactory.defaultPersistenceBroker();
      }
  
      protected ${table.JavaName} getObjectByCriteria(Criteria crit) {
          PersistenceBroker broker = getBroker();
          Query query = new QueryByCriteria(${table.JavaName}.class, crit);
          ${table.JavaName} object = (${table.JavaName}) broker.getObjectByQuery(query);
          broker.close();
          return object;
      }
  
      protected Collection getCollectionByCriteria(Criteria crit) {
          PersistenceBroker broker = getBroker();
          Query query = new QueryByCriteria(${table.JavaName}.class, crit);
          Collection coll = broker.getCollectionByQuery(query);
          broker.close();
          return coll;
      }
  
      public void save(${table.JavaName} object) {
          PersistenceBroker broker = getBroker();
          try {
              broker.beginTransaction();
              broker.store(object);
              broker.commitTransaction();
          } catch (PersistenceBrokerException ex) {
              broker.abortTransaction();
              log.error("Error saving object", ex);
          } finally {
              broker.close();
          }
      }
      
      protected void save(PersistenceBroker broker, ${table.JavaName} object) {
          broker.store(object);
      }
  
      public void delete(${table.JavaName} object) {
          PersistenceBroker broker = getBroker();
          try {
              broker.beginTransaction();
              delete(broker, object);
              broker.commitTransaction();
          } catch (Throwable t) {
              broker.abortTransaction();
              log.error("could not delete object", t);
          } finally {
              broker.close();
          }
      }
      
      protected void delete(PersistenceBroker broker, ${table.JavaName} object) {
          broker.delete(object);
      }
  
  }
  
  
  
  1.1                  db-torque/src/generator/src/templates/ojb/model/BaseObject.vm
  
  Index: BaseObject.vm
  ===================================================================
  package ${package};
  
  #if ($table.BaseClass)
      #set ($extendsBaseClass = "extends $table.BaseClass" )
  #else
      #set ($extendsBaseClass = "" )
  #end
  
  import java.io.Serializable;
  import java.util.Date;
  import java.math.BigDecimal;
  
  /**
   * ${table.JavaName}
  #if ($addTimeStamp)
   * This class was autogenerated by Torque on:
   *
   * [$now]
   *
  #end
   */
  public class ${basePrefix}${table.JavaName}
  {
    #foreach ($col in $table.Columns)
      private $col.JavaPrimitive $col.UncapitalisedJavaName;
    #end
  
    #foreach ($col in $table.Columns)
  
      /**
       * Get the $col.JavaName
       * @return $col.JavaPrimitive
       */
      public $col.JavaPrimitive get${col.JavaName}()
      {
          return $col.UncapitalisedJavaName;
      }
  
      /**
       * Set the value of $cfc
       */
      public void set${col.JavaName}($col.JavaPrimitive v)
      {
          this.$col.UncapitalisedJavaName = v;
      }
    #end
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message