db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: jakarta-turbine-torque/src/test/org/apache/torque/engine/database package-schema.xml package2-schema.xml TestPackageHandling.java
Date Wed, 18 Dec 2002 13:56:05 GMT
mpoeschl    2002/12/18 05:56:04

  Modified:    src/templates/om ExtensionManager.vm ExtensionPeer.vm
                        BaseManager.vm ExtensionObject.vm Interface.vm
                        MultiExtendObject.vm Object.vm ObjectWithManager.vm
                        Peer.vm
               src/java/org/apache/torque/engine/database/model Table.java
               src/rttest test-schema.xml
               src/java/org/apache/torque/engine/database/transform
                        XmlToAppData.java
  Added:       src/test/org/apache/torque/engine/database
                        package-schema.xml package2-schema.xml
                        TestPackageHandling.java
  Log:
  move the handling of the package name from the templates to the model:
  changed:
  o XmlToAppData: set the default package for the database if it is not defined
  o Table: get packagename from Database
  o templates: to get the right package we just need to use $package
  o test-schema: add package to the db definition
  added:
  o TestPackageHandling - testcase for the handling of package names
  
  Revision  Changes    Path
  1.3       +3 -9      jakarta-turbine-torque/src/templates/om/ExtensionManager.vm
  
  Index: ExtensionManager.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/ExtensionManager.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExtensionManager.vm	13 Mar 2002 21:31:23 -0000	1.2
  +++ ExtensionManager.vm	18 Dec 2002 13:56:03 -0000	1.3
  @@ -7,12 +7,6 @@
      #set ($interfaceName = $table.Interface)
   #end
   
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package $package;
   
   #if ($table.isAbstract())
  @@ -23,8 +17,8 @@
   import org.apache.torque.TorqueException;
   import org.apache.torque.om.Persistent;
   
  -/** 
  - * This class manages $interfaceName objects.  
  +/**
  + * This class manages $interfaceName objects.
    * The skeleton for this class was autogenerated by Torque #if ($addTimeStamp)on:
    *
    * [$now]
  
  
  
  1.4       +2 -8      jakarta-turbine-torque/src/templates/om/ExtensionPeer.vm
  
  Index: ExtensionPeer.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/ExtensionPeer.vm,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExtensionPeer.vm	30 Jul 2002 05:31:55 -0000	1.3
  +++ ExtensionPeer.vm	18 Dec 2002 13:56:03 -0000	1.4
  @@ -1,12 +1,6 @@
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package ${package};
   
  -/** 
  +/**
   #if ($addTimeStamp)
    * The skeleton for this class was autogenerated by Torque on:
    *
  @@ -17,7 +11,7 @@
    *  application requirements.  This class will only be generated as
    *  long as it does not already exist in the output directory.
    */
  -public class ${table.JavaName}Peer 
  +public class ${table.JavaName}Peer
       extends ${package}.$basePrefix${table.JavaName}Peer
   {
   }
  
  
  
  1.15      +1 -7      jakarta-turbine-torque/src/templates/om/BaseManager.vm
  
  Index: BaseManager.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/BaseManager.vm,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- BaseManager.vm	24 Oct 2002 20:27:09 -0000	1.14
  +++ BaseManager.vm	18 Dec 2002 13:56:03 -0000	1.15
  @@ -7,12 +7,6 @@
      #set ($interfaceName = $table.Interface)
   #end
   
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package ${package};
   
   import java.util.Date;
  
  
  
  1.5       +2 -8      jakarta-turbine-torque/src/templates/om/ExtensionObject.vm
  
  Index: ExtensionObject.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/ExtensionObject.vm,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ExtensionObject.vm	13 Mar 2002 21:31:23 -0000	1.4
  +++ ExtensionObject.vm	18 Dec 2002 13:56:03 -0000	1.5
  @@ -3,12 +3,6 @@
       #set ($interface = ", $table.Interface")
   #end
   
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package $package;
   
   #if ($table.isAbstract())
  @@ -17,7 +11,7 @@
   
   import org.apache.torque.om.Persistent;
   
  -/** 
  +/**
   #if ($addTimeStamp)
    * The skeleton for this class was autogenerated by Torque on:
    *
  @@ -28,7 +22,7 @@
    * application requirements.  This class will only be generated as
    * long as it does not already exist in the output directory.
    */
  -public $!abstract class $table.JavaName 
  +public $!abstract class $table.JavaName
       extends ${package}.$basePrefix$table.JavaName
       implements Persistent$interface
   {
  
  
  
  1.2       +4 -10     jakarta-turbine-torque/src/templates/om/Interface.vm
  
  Index: Interface.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Interface.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Interface.vm	13 Mar 2002 21:31:23 -0000	1.1
  +++ Interface.vm	18 Dec 2002 13:56:03 -0000	1.2
  @@ -3,17 +3,11 @@
    * version $Id$
    *#
   
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package $package;
   
  -/** 
  - * This is an interface that should be filled with the public api of the 
  - * $table.JavaName objects.  
  +/**
  + * This is an interface that should be filled with the public api of the
  + * $table.JavaName objects.
    * The skeleton for this class was autogenerated by Torque #if ($addTimeStamp)on:
    *
    * [$now]
  
  
  
  1.3       +1 -7      jakarta-turbine-torque/src/templates/om/MultiExtendObject.vm
  
  Index: MultiExtendObject.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/MultiExtendObject.vm,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MultiExtendObject.vm	24 May 2002 23:44:08 -0000	1.2
  +++ MultiExtendObject.vm	18 Dec 2002 13:56:03 -0000	1.3
  @@ -1,9 +1,3 @@
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package $package;
   
   import java.util.*;
  @@ -17,7 +11,7 @@
       #set ($parent = $table.JavaName)
   #end
   
  -/** 
  +/**
   #if ($addTimeStamp)
    * The skeleton for this class was autogenerated by Torque on:
    *
  
  
  
  1.56      +0 -6      jakarta-turbine-torque/src/templates/om/Object.vm
  
  Index: Object.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Object.vm,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- Object.vm	11 Dec 2002 19:03:41 -0000	1.55
  +++ Object.vm	18 Dec 2002 13:56:03 -0000	1.56
  @@ -1,9 +1,3 @@
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package ${package};
   
   #if ($table.BaseClass == "")
  
  
  
  1.31      +0 -6      jakarta-turbine-torque/src/templates/om/ObjectWithManager.vm
  
  Index: ObjectWithManager.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/ObjectWithManager.vm,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- ObjectWithManager.vm	11 Dec 2002 19:03:41 -0000	1.30
  +++ ObjectWithManager.vm	18 Dec 2002 13:56:04 -0000	1.31
  @@ -1,9 +1,3 @@
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package ${package};
   
   #if ($table.BaseClass == "")
  
  
  
  1.47      +0 -6      jakarta-turbine-torque/src/templates/om/Peer.vm
  
  Index: Peer.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/templates/om/Peer.vm,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- Peer.vm	11 Dec 2002 19:03:41 -0000	1.46
  +++ Peer.vm	18 Dec 2002 13:56:04 -0000	1.47
  @@ -1,9 +1,3 @@
  -#set ($db = $table.Database)
  -#if ($db.Package)
  -    #set ($package = $db.Package)
  -#else
  -    #set ($package = $targetPackage)
  -#end
   package ${package};
   
   import java.math.BigDecimal;
  
  
  
  1.37      +11 -2     jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Table.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- Table.java	11 Dec 2002 19:14:01 -0000	1.36
  +++ Table.java	18 Dec 2002 13:56:04 -0000	1.37
  @@ -779,15 +779,24 @@
   
       /**
        * Get the value of package.
  +     *
        * @return value of package.
        */
       public String getPackage()
       {
  -        return pkg;
  +        if (pkg != null)
  +        {
  +            return pkg;
  +        }
  +        else
  +        {
  +            return this.getDatabase().getPackage();
  +        }
       }
   
       /**
        * Set the value of package.
  +     *
        * @param v  Value to assign to package.
        */
       public void setPackage(String v)
  
  
  
  1.7       +1 -1      jakarta-turbine-torque/src/rttest/test-schema.xml
  
  Index: test-schema.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/rttest/test-schema.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- test-schema.xml	9 Dec 2002 05:47:05 -0000	1.6
  +++ test-schema.xml	18 Dec 2002 13:56:04 -0000	1.7
  @@ -2,7 +2,7 @@
   <!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd">
   <!-- this schema is used to test problems users reported -->
   
  -<database name="@DATABASE_DEFAULT@" defaultIdMethod="idbroker">
  +<database name="@DATABASE_DEFAULT@" defaultIdMethod="idbroker" package="org.apache.torque.test">
     <!-- TRQS15 -->
     <table name="varchar_pk">
       <column name="test_key" required="true" primaryKey="true" type="VARCHAR" size="30"
/>
  
  
  
  1.17      +5 -1      jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java
  
  Index: XmlToAppData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- XmlToAppData.java	8 Oct 2002 18:17:06 -0000	1.16
  +++ XmlToAppData.java	18 Dec 2002 13:56:04 -0000	1.17
  @@ -227,6 +227,10 @@
                       else
                       {
                           currDB = app.addDatabase(attributes);
  +                        if (currDB.getPackage() == null)
  +                        {
  +                            currDB.setPackage(defaultPackage);
  +                        }
                       }
                   }
                   else if (rawName.equals("external-schema"))
  
  
  
  1.1                  jakarta-turbine-torque/src/test/org/apache/torque/engine/database/package-schema.xml
  
  Index: package-schema.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
  <!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd">
  
  <database name="packagedb" defaultIdMethod="idbroker">
    <table name="table_a">
      <column name="table_a_id" required="true" primaryKey="true" type="INTEGER" />
      <column name="col_a" type="CHAR" size="5" />
    </table>
  </database>
  
  
  
  
  1.1                  jakarta-turbine-torque/src/test/org/apache/torque/engine/database/package2-schema.xml
  
  Index: package2-schema.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
  <!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd">
  
  <database name="packagedb2" defaultIdMethod="idbroker" package="packagefromdb">
  
    <table name="table_a">
      <column name="table_a_id" required="true" primaryKey="true" type="INTEGER" />
      <column name="col_a" type="CHAR" size="5" />
    </table>
  </database>
  
  
  
  
  1.1                  jakarta-turbine-torque/src/test/org/apache/torque/engine/database/TestPackageHandling.java
  
  Index: TestPackageHandling.java
  ===================================================================
  package org.apache.torque.engine.database;
  
  import junit.framework.*;
  import org.apache.torque.engine.database.transform.*;
  import org.apache.torque.engine.database.model.*;
  
  public class TestPackageHandling extends TestCase
  {
      private XmlToAppData xmlToAppData = null;
      private AppData appData = null;
  
      public TestPackageHandling(String name)
      {
          super(name);
      }
  
      protected void setUp() throws Exception
      {
          super.setUp();
      }
  
      protected void tearDown() throws Exception
      {
          xmlToAppData = null;
          super.tearDown();
      }
  
      /**
       * test if the tables get the package name from the properties file
       */
      public void testDefaultPackageName()
      {
          xmlToAppData = new XmlToAppData("mysql", "defaultpackage", null);
          appData = xmlToAppData.parseFile(
              "src/test/org/apache/torque/engine/database/package-schema.xml");
          Database db = appData.getDatabase("packagedb");
          assertEquals("defaultpackage", db.getPackage());
          Table table = db.getTable("table_a");
          assertEquals("defaultpackage", table.getPackage());
      }
  
      /**
       * test if the tables get the package name from the database tag
       */
      public void testDatabasePackageName()
      {
          xmlToAppData = new XmlToAppData("mysql", "defaultpackage", null);
          appData = xmlToAppData.parseFile(
              "src/test/org/apache/torque/engine/database/package2-schema.xml");
          Database db = appData.getDatabase("packagedb2");
          assertEquals("packagefromdb", db.getPackage());
          Table table = db.getTable("table_a");
          assertEquals("packagefromdb", table.getPackage());
      }
  
  }
  
  
  

Mime
View raw message