db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r499556 - in /db/torque: generator/trunk/src/conf/ generator/trunk/xdocs/ maven-plugin/trunk/ maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/ maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/ site/trunk/xdocs/ templates/tr...
Date Wed, 24 Jan 2007 20:23:58 GMT
Author: tfischer
Date: Wed Jan 24 12:23:57 2007
New Revision: 499556

URL: http://svn.apache.org/viewvc?view=rev&rev=499556
Log:
The base classes and the non-base-classes can now be generated into two different directories.
In the maven 2 plugin, the default behaviour is to generate the base classes into a subdirectory
of target and the non-base classes in a subdirectory of src.
In maven 1 and ant, the default is to use the same directory for both the base and non-base
classes.

Added:
    db/torque/templates/trunk/src/templates/om/ControlBase.vm
Modified:
    db/torque/generator/trunk/src/conf/build-torque.xml
    db/torque/generator/trunk/src/conf/default.properties
    db/torque/generator/trunk/xdocs/properties-reference.xml
    db/torque/maven-plugin/trunk/plugin.jelly
    db/torque/maven-plugin/trunk/plugin.properties
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/OMMojo.java
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
    db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
    db/torque/site/trunk/xdocs/changes.xml
    db/torque/templates/trunk/src/templates/om/Control.vm
    db/torque/test/trunk/test-project/maven.xml
    db/torque/test/trunk/test-project/project.properties

Modified: db/torque/generator/trunk/src/conf/build-torque.xml
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/src/conf/build-torque.xml?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/generator/trunk/src/conf/build-torque.xml (original)
+++ db/torque/generator/trunk/src/conf/build-torque.xml Wed Jan 24 12:23:57 2007
@@ -551,6 +551,19 @@
         excludes="${torque.schema.om.excludes}"
       />
     </torque-data-model>
+    <torque-data-model
+      contextProperties="${torque.contextProperties}"
+      controlTemplate="${torque.template.om.base}"
+      outputDirectory="${torque.java.base.dir}"
+      outputFile="report.${torque.project}.om.base.generation"
+      targetDatabase="${torque.database}"
+      targetPackage="${torque.targetPackage}"
+      useClasspath="${torque.useClasspath}">
+      <fileset dir="${torque.schema.dir}"
+        includes="${torque.schema.om.includes}"
+        excludes="${torque.schema.om.excludes}"
+      />
+    </torque-data-model>
   </target>
 
   <target name="om-template" unless="torque.internal.useClasspath">
@@ -559,6 +572,19 @@
       controlTemplate="${torque.template.om}"
       outputDirectory="${torque.java.dir}"
       outputFile="report.${torque.project}.om.generation"
+      targetDatabase="${torque.database}"
+      targetPackage="${torque.targetPackage}"
+      templatePath="${torque.templatePath}">
+      <fileset dir="${torque.schema.dir}"
+        includes="${torque.schema.om.includes}"
+        excludes="${torque.schema.om.excludes}"
+      />
+    </torque-data-model>
+    <torque-data-model
+      contextProperties="${torque.contextProperties}"
+      controlTemplate="${torque.template.om.base}"
+      outputDirectory="${torque.java.base.dir}"
+      outputFile="report.${torque.project}.om.base.generation"
       targetDatabase="${torque.database}"
       targetPackage="${torque.targetPackage}"
       templatePath="${torque.templatePath}">

Modified: db/torque/generator/trunk/src/conf/default.properties
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/src/conf/default.properties?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/generator/trunk/src/conf/default.properties (original)
+++ db/torque/generator/trunk/src/conf/default.properties Wed Jan 24 12:23:57 2007
@@ -58,6 +58,7 @@
 
 torque.doc.dir = ${torque.output.dir}/doc
 torque.java.dir = ${torque.output.dir}/java
+torque.java.base.dir = ${torque.java.dir}
 torque.javadoc.dir = ${torque.output.dir}/javadoc
 torque.ojb.dir = ${torque.output.dir}/ojb
 torque.sql.dir = ${torque.output.dir}/sql
@@ -143,6 +144,7 @@
 
 torque.template.sql = sql/base/Control.vm
 torque.template.om = om/Control.vm
+torque.template.om.base = om/ControlBase.vm
 torque.template.idTable = sql/id-table/Control.vm
 torque.template.dataDtd = data/Control.vm
 torque.template.dataDump = data/dump/Control.vm

Modified: db/torque/generator/trunk/xdocs/properties-reference.xml
URL: http://svn.apache.org/viewvc/db/torque/generator/trunk/xdocs/properties-reference.xml?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/generator/trunk/xdocs/properties-reference.xml (original)
+++ db/torque/generator/trunk/xdocs/properties-reference.xml Wed Jan 24 12:23:57 2007
@@ -182,7 +182,12 @@
     <tr>
       <td><code>torque.java.dir</code></td>
       <td><code>${maven.src.dir}/java</code></td>
-      <td>The directory to place all of the generated Java code in.</td>
+      <td>The directory to place the generated non-base Java code in.</td>
+    </tr>
+    <tr>
+      <td><code>torque.java.base.dir</code></td>
+      <td><code>${torque.java.dir}/java</code></td>
+      <td>The directory to place the generated base Java code in.</td>
     </tr>
     <tr>
       <td><code>torque.sql.dir</code></td>

Modified: db/torque/maven-plugin/trunk/plugin.jelly
URL: http://svn.apache.org/viewvc/db/torque/maven-plugin/trunk/plugin.jelly?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/maven-plugin/trunk/plugin.jelly (original)
+++ db/torque/maven-plugin/trunk/plugin.jelly Wed Jan 24 12:23:57 2007
@@ -280,6 +280,7 @@
 
     <j:choose>
       <j:when test="${torque.useClasspath}">
+        <echo>Generating Non-Base Classes</echo>
         <torque-data-model
           contextProperties="${torque.contextProperties}"
           controlTemplate="${torque.template.om}"
@@ -293,13 +294,42 @@
             excludes="${torque.schema.om.excludes}"
           />
         </torque-data-model>
+        <echo>Generating Base Classes</echo>
+        <torque-data-model
+          contextProperties="${torque.contextProperties}"
+          controlTemplate="${torque.template.om.base}"
+          outputDirectory="${torque.java.base.dir}"
+          outputFile="report.${torque.project}.om.base.generation"
+          targetDatabase="${torque.database}"
+          targetPackage="${torque.targetPackage}"
+          useClasspath="${torque.useClasspath}">
+          <fileset dir="${torque.schema.dir}"
+            includes="${torque.schema.om.includes}"
+            excludes="${torque.schema.om.excludes}"
+          />
+        </torque-data-model>
       </j:when>
       <j:otherwise>
+        <echo>Generating Non-Base Classes</echo>
         <torque-data-model
           contextProperties="${torque.contextProperties}"
           controlTemplate="${torque.template.om}"
           outputDirectory="${torque.java.dir}"
           outputFile="report.${torque.project}.om.generation"
+          targetDatabase="${torque.database}"
+          targetPackage="${torque.targetPackage}"
+          templatePath="${torque.templatePath}">
+          <fileset dir="${torque.schema.dir}"
+            includes="${torque.schema.om.includes}"
+            excludes="${torque.schema.om.excludes}"
+          />
+        </torque-data-model>
+        <echo>Generating Base Classes</echo>
+        <torque-data-model
+          contextProperties="${torque.contextProperties}"
+          controlTemplate="${torque.template.om.base}"
+          outputDirectory="${torque.java.base.dir}"
+          outputFile="report.${torque.project}.om.base.generation"
           targetDatabase="${torque.database}"
           targetPackage="${torque.targetPackage}"
           templatePath="${torque.templatePath}">

Modified: db/torque/maven-plugin/trunk/plugin.properties
URL: http://svn.apache.org/viewvc/db/torque/maven-plugin/trunk/plugin.properties?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/maven-plugin/trunk/plugin.properties (original)
+++ db/torque/maven-plugin/trunk/plugin.properties Wed Jan 24 12:23:57 2007
@@ -62,6 +62,7 @@
 
 torque.doc.dir = ${torque.output.dir}/doc/schema
 torque.java.dir = ${maven.src.dir}/java
+torque.java.base.dir = ${torque.java.dir}
 torque.ojb.dir = ${maven.src.dir}/ojb
 torque.sql.dir = ${torque.output.dir}/sql
 torque.omzip.dir = ${torque.output.dir}
@@ -174,6 +175,7 @@
 
 SQLControlTemplate = sql/base/Control.vm
 OMControlTemplate = om/Control.vm
+OMControlBaseTemplate = om/ControlBase.vm
 idTableControlTemplate = sql/id-table/Control.vm
 DataDTDControlTemplate = data/Control.vm
 DataDumpControlTemplate = data/dump/Control.vm
@@ -182,6 +184,7 @@
 
 torque.template.sql = ${SQLControlTemplate}
 torque.template.om = ${OMControlTemplate}
+torque.template.om.base = ${OMControlBaseTemplate}
 torque.template.idTable = ${idTableControlTemplate}
 torque.template.dataDtd = ${DataDTDControlTemplate}
 torque.template.dataDump = ${DataDumpControlTemplate}

Modified: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/OMMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/OMMojo.java?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/OMMojo.java (original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/OMMojo.java Wed Jan
24 12:23:57 2007
@@ -24,6 +24,7 @@
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.tools.ant.BuildException;
+import org.apache.torque.task.TorqueDataModelTask;
 
 /**
  * Generates the sources for the persistence classes from the schema.xml files.
@@ -41,19 +42,20 @@
     // into setting the correct default values for
     // outputDir, reportFile and contextPropertiesPath
     /**
-     * The directory in which the sources for the persistence classes will be
-     * generated.
+     * The directory in which the sources for the non-base persistence classes
+     * will be generated.
      *
      * @parameter property="outputDir"
-     *            expression="${project.build.directory}/generated-sources/torque"
+     *            expression="${project.build.sourceDirectory}/../generated-java"
      */
     private String dummy;
 
     /**
-     * The location where the report file will be generated.
+     * The location where the report file for the non-base persistence classes 
+     * will be generated.
      *
      * @parameter property="reportFile"
-     *            expression="../../torque/report.${project.artifact.artifactId}.om.generation"
+     *            expression="../../../target/torque/report.${project.artifact.artifactId}.om.generation"
      */
     private String dummy2;
 
@@ -67,6 +69,22 @@
     private String dummy3;
 
     /**
+     * The directory where the sources for the base persistence classes
+     * will be generated. 
+     *
+     * @parameter expression="${project.build.directory}/generated-sources/torque"
+     */
+    private String baseOutputDir;
+
+    /**
+     * The location where the report file for the base persistence classes
+     * will be generated.
+     *
+     * @parameter expression="../../torque/report.${project.artifact.artifactId}.om.base.generation"
+     */
+    private String baseReportFile;
+
+    /**
      * The context property for the target package.
      */
     public static final String TARGET_PACKAGE_CONTEXT_PROPERTY
@@ -409,6 +427,11 @@
     private boolean enableJava5Features;
 
     /**
+     * The control template which should be used by the Texen task. 
+     */
+    private String controlTemplate;
+
+    /**
      * Creates a new TorqueOMMojo object.
      */
     public OMMojo()
@@ -417,7 +440,7 @@
 
     /**
      * Generates the OM classes for a Torque project and adds them to
-     * the comile sources of the project.
+     * the compile sources of the project.
      *
      * @throws MojoExecutionException If an error occurs during generation.
      *
@@ -426,17 +449,50 @@
      */
     public void execute() throws MojoExecutionException
     {
+        // generate non-base classes
+        controlTemplate = "om/Control.vm";
         super.execute();
-
+        String outputDir = super.getOutputDir();
+        String reportFile = super.getReportFile();
         try
         {
-            File outputDirectory = new File(super.getOutputDir());
-            getLog().info ("torque java sources generated into: "
+            File outputDirectory = new File(outputDir);
+            getLog().info ("torque non-base java sources generated into: "
                     + outputDirectory.getAbsolutePath());
 
             if (getProject() != null)
             {
-                getProject().addCompileSourceRoot(outputDirectory.getPath());
+                getProject().addCompileSourceRoot(
+                        outputDirectory.getPath());
+            }
+        }
+        catch (BuildException e)
+        {
+            getLog().error(e.getMessage());
+            throw new MojoExecutionException(e.getMessage(), e);
+        }
+
+        // generate base classes
+        // reset texen task (for an unknown reason, the old texen task will
+        // append the already generated output to the already generated files
+        super.setGeneratorTask(new TorqueDataModelTask());
+        controlTemplate = "om/ControlBase.vm";
+        super.setOutputDir(baseOutputDir);
+        super.setReportFile(baseReportFile);
+        super.execute();
+        super.setOutputDir(outputDir);
+        super.setReportFile(reportFile);
+        
+        try
+        {
+            File baseOutputDirectory = new File(baseOutputDir);
+            getLog().info ("torque base java sources generated into: "
+                    + baseOutputDirectory.getAbsolutePath());
+
+            if (getProject() != null)
+            {
+                getProject().addCompileSourceRoot(
+                        baseOutputDirectory.getPath());
             }
         }
         catch (BuildException e)
@@ -449,11 +505,11 @@
     /**
      * Returns the path to the control template.
      *
-     * @return "om/Control.vm"
+     * @return the path to the current control template.
      */
     protected String getControlTemplate()
     {
-        return "om/Control.vm";
+        return controlTemplate;
     }
 
     /**
@@ -1050,5 +1106,53 @@
     public void setUseManagers(boolean useManagers)
     {
         this.useManagers = useManagers;
+    }
+
+    /**
+     * Returns where the sources for the persistence base classes
+     * will be generated.
+     *
+     * @return where the sources for the persistence base classes
+     *          will be generated.
+     */
+    public String getBaseOutputDir()
+    {
+        return baseOutputDir;
+    }
+
+    /**
+     * Sets where the sources for the persistence base classes
+     * will be generated.
+     *
+     * @param baseOutputDir where the sources for the persistence base classes
+     *         will be generated.
+     */
+    public void setBaseOutputDir(String baseOutputDir)
+    {
+        this.baseOutputDir = baseOutputDir;
+    }
+
+    /**
+     * Returns the location where the report file for the base persistence
+     * classes will be generated.
+     *
+     * @return the location where the report file for the base persistence
+     *          classes will be generated.
+     */
+    public String getBaseReportFile()
+    {
+        return baseReportFile;
+    }
+
+    /**
+     * Sets the location where the report file for the base persistence
+     * classes will be generated.
+     *
+     * @param baseReportFile the location where the report file for the
+     *         base persistence classes will be generated.
+     */
+    public void setBaseReportFile(String baseReportFile)
+    {
+        this.baseReportFile = baseReportFile;
     }
 }

Modified: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
(original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/TexenTaskMojo.java
Wed Jan 24 12:23:57 2007
@@ -106,6 +106,15 @@
      */
     public TexenTaskMojo(TexenTask generatorTask)
     {
+        setGeneratorTask(generatorTask);
+    }
+    
+    /**
+     * Sets the Texen task.
+     * @param generatorTask the Texen task to be used in this Mojo.
+     */
+    protected void setGeneratorTask(TexenTask generatorTask)
+    {
         if (generatorTask == null)
         {
             throw new IllegalArgumentException("generatorTask is null");

Modified: db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
(original)
+++ db/torque/maven2-plugin/trunk/src/test/java/org/apache/torque/mojo/TorqueOMMojoTest.java
Wed Jan 24 12:23:57 2007
@@ -75,13 +75,17 @@
         instance.setProject(mavenProject);
 
         instance.setOutputDir(
-                mavenProject.getBuild().getDirectory()
-                    + "/generated-sources/torque");
+                mavenProject.getBuild().getSourceDirectory());
 
         instance.setContextPropertiesPath(
                 mavenProject.getBuild().getDirectory()
                     + "/torque/context.om.properties");
 
+        instance.setBaseOutputDir(
+                mavenProject.getBuild().getDirectory()
+                    + "/generated-sources/torque");
+
+
         instance.setSchemaDir(
                 mavenProject.getBasedir() + "/src/main/torque/schema");
 
@@ -97,10 +101,15 @@
 
         instance.setSchemaExcludes("id-table-schema.xml");
 
-        instance.setReportFile("../../torque/torque."
+        instance.setReportFile("../../../target/torque/torque."
                 + mavenProject.getArtifact().getArtifactId()
                 + "."
                 + "om.generation");
+
+        instance.setBaseReportFile("../../torque/torque."
+                + mavenProject.getArtifact().getArtifactId()
+                + "."
+                + "om.base.generation");
 
         instance.execute();
 

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Wed Jan 24 12:23:57 2007
@@ -32,6 +32,12 @@
   <body>
 
   <release version="3.3" date="in SVN">
+    <action type="add" dev="tfischer">
+      The maven 2 plugin generates the non-base classes into a different
+      directory than the base classes. This behaviour can also be configured for
+      maven 1 and ant by setting the property torque.java.base.dir to another
+      directory than torque.java.dir.
+    </action>
     <action type="fix" dev="tfischer" due-to="Jeffrey D. Brekke">
       Fixed the lifecycle integration and dependency resolution of the om goal
       in the maven 2 plugin.

Modified: db/torque/templates/trunk/src/templates/om/Control.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/Control.vm?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/templates/trunk/src/templates/om/Control.vm (original)
+++ db/torque/templates/trunk/src/templates/om/Control.vm Wed Jan 24 12:23:57 2007
@@ -80,24 +80,15 @@
 
     Peers generated in package $packagePeer
     Objects generated in package $packageObject
-    Maps generated in package $packageMap
     Managers generated in package $packageManager
     Beans generated in package $packageBean
 
-    BasePeers generated in package $packageBasePeer
-    BaseObjects generated in package $packageBaseObject
-    BaseManagers generated in package $packageBaseManager
-    BaseBeans generated in package $packageBaseBean
-
     #set ( $path = $strings.getPackageAsPath($packagePeer) )
     $files.mkdir("$outputDirectory/$path")
 
     #set ( $path = $strings.getPackageAsPath($packageObject) )
     $files.mkdir("$outputDirectory/$path")
 
-    #set ( $path = $strings.getPackageAsPath($packageMap) )
-    $files.mkdir("$outputDirectory/$path")
-
     #if ($useManagers)
       #set ( $path = $strings.getPackageAsPath($packageManager) )
       $files.mkdir("$outputDirectory/$path")
@@ -108,34 +99,6 @@
       $files.mkdir("$outputDirectory/$path")
     #end
 
-    #set ( $path = $strings.getPackageAsPath($packageBasePeer) )
-    $files.mkdir("$outputDirectory/$path")
-
-    #set ( $path = $strings.getPackageAsPath($packageBaseObject) )
-    $files.mkdir("$outputDirectory/$path")
-
-    #if ($useManagers)
-      #set ( $path = $strings.getPackageAsPath($packageBaseManager) )
-      $files.mkdir("$outputDirectory/$path")
-    #end
-
-    #if ($generateBeans)
-      #set ( $path = $strings.getPackageAsPath($packageBaseBean) )
-      $files.mkdir("$outputDirectory/$path")
-    #end
-
-	#if ( !$mapDBNames.contains( $database.Name ) )
-## Adding new database entry for $database.Name	
-	  #set ( $retVal = $mapDBNames.add( $database.Name ) )
-	  #set ( $retVal = $mapDatabases.add( $database ) )
-	  #set ( $builderArray = [] ) 
-	  #set ( $retVal = $mapDBMapBuilders.add( $builderArray ) )
-	#else
-## Using existing database entry for $database.Name
-	  #set ( $dbIndex = $mapDBinfo.indexOf( $database.Name ) )
-	  #set ( $builderArray = $mapDBMapBuilders.get( $dbIndex ) )
-	#end
-	
 	#foreach ($tbl in $database.Tables)
 	  #if ( !$tbl.isAlias() && !$tbl.isForReferenceOnly() )
 ## Adding new table Peer = "${packagePeer}.${tbl.JavaName}Peer"
@@ -150,26 +113,12 @@
         $!tbl.setCorrectGetters($!correctGetters)
         #set ( $firstcap=$tbl.JavaName )
 
-        #set ( $fname = "$basePrefix${firstcap}Peer.java" )
-        #set ( $path = "${strings.getPackageAsPath($packageBasePeer)}$fname" )
-        $generator.parse("om/Peer.vm",$path,"table",$tbl)
-
-        #if (!$tbl.isAlias())
-          #set ( $fname = "${firstcap}MapBuilder.java" )
-          #set ( $path = "${strings.getPackageAsPath($packageMap)}$fname" )
-          $generator.parse("om/MapBuilder.vm",$path,"table",$tbl)
-        #end
-
         #if ($useManagers && $tbl.PrimaryKey.size() > 0)
           #set ($interfaceName = $table.JavaName)
           #if ($table.Interface)
             #set ($interfaceName = $table.Interface)
           #end
 
-          #set ( $fname = "${basePrefix}${interfaceName}Manager.java" )
-          #set ( $path = "${strings.getPackageAsPath($packageBaseManager)}$fname" )
-          $generator.parse("om/BaseManager.vm",$path,"table",$tbl)
-
           #set ( $fname = "${interfaceName}Manager.java" )
           #set ( $path = "${strings.getPackageAsPath($packageManager)}$fname" )
           #if (!$files.file($basePath,$path).exists())
@@ -177,16 +126,6 @@
           #end
         #end
 
-        #if ($useManagers)
-          #set ( $fname = "${basePrefix}${firstcap}.java" )
-          #set ( $path = "${strings.getPackageAsPath($packageBaseObject)}$fname" )
-          $generator.parse("om/ObjectWithManager.vm",$path,"table",$tbl)
-        #else
-          #set ( $fname = "${basePrefix}${firstcap}.java" )
-          #set ( $path = "${strings.getPackageAsPath($packageBaseObject)}$fname" )
-          $generator.parse("om/Object.vm",$path,"table",$tbl)
-        #end
-
         #set ( $fname = "${firstcap}.java" )
         #set ( $path = "${strings.getPackageAsPath($packageObject)}$fname" )
         #if (!$files.file($basePath,$path).exists())
@@ -199,22 +138,6 @@
           $generator.parse("om/ExtensionPeer.vm",$path,"table",$tbl)
         #end
 
-#*
-        #if ($tbl.Interface)
-          #set ( $fname = "${tbl.Interface}.java" )
-          #set ( $path = "${strings.getPackageAsPath($packageObject)}$fname" )
-          #if (!$files.file($basePath,$path).exists())
-            $generator.parse("om/Interface.vm",$path,"table",$tbl)
-          #end
-        #end
-*#
-
-        #if ($generateBeans)
-          #set ( $fname = "${basePrefix}${firstcap}${beanSuffix}.java" )
-          #set ( $path = "${strings.getPackageAsPath($packageBaseBean)}$fname" )
-          $generator.parse("om/bean/Bean.vm",$path,"table",$tbl)
-        #end
-
         #if ($generateBeans)
           #set ( $fname = "${firstcap}${beanSuffix}.java" )
           #set ( $path = "${strings.getPackageAsPath($packageBean)}$fname" )
@@ -245,38 +168,4 @@
         #end
       #end
     #end
-#end
-
-#foreach ( $dbName in $mapDBNames )
-	#set ( $dbIndex = $mapDBNames.indexOf( $dbName ) )
-	#set ( $peerNames = $mapDBMapBuilders.get( $dbIndex ) )
-	#set ( $database = $mapDatabases.get( $dbIndex ) )
-
-    #if ($database.Package)
-      #set ($package = $database.Package)
-    #else
-      #set ($package = $targetPackage)
-    #end
-
-    #if ($subpackageMap)
-      #set ($packageMap = "${package}.${subpackageMap}")
-    #else
-      #set ($packageMap = "${package}")
-    #end
-
-    #set ( $fname = "${database.JavaName}MapInit.java" )
-    #set ( $path = "${strings.getPackageAsPath($packageMap)}$fname" )
-    $generator.parse("om/DatabaseMapInit.vm", $path, "database", $database)
-
-## Hard coded linkage package that must match one used by runtime DatabaseMap.initialize()
-	#set ( $packageLinkage = "org.apache.torque.linkage" );
-	#set ( $path = $strings.getPackageAsPath($packageLinkage) )
-    $files.mkdir("$outputDirectory/$path")
-	
-    #set ( $fname = "${database.StandardJavaName}MapInit.java" )
-    #set ( $path = "$strings.getPackageAsPath($packageLinkage)$fname" )
-    #if (!$files.file($basePath,$path).exists())
-      $generator.parse("om/DatabaseMapInitLinkageObject.vm", $path, "database", $database)
-    #end
-
 #end

Added: db/torque/templates/trunk/src/templates/om/ControlBase.vm
URL: http://svn.apache.org/viewvc/db/torque/templates/trunk/src/templates/om/ControlBase.vm?view=auto&rev=499556
==============================================================================
--- db/torque/templates/trunk/src/templates/om/ControlBase.vm (added)
+++ db/torque/templates/trunk/src/templates/om/ControlBase.vm Wed Jan 24 12:23:57 2007
@@ -0,0 +1,211 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+#set ($basePath = $generator.OutputPath)
+
+targetdatabase = $targetDatabase
+
+correctGetters = $!correctGetters
+
+#set ( $mapDBNames = [] )       ## Collect unique DB names across all external-schemas
+#set ( $mapDatabases = [] )     ## Collect the first database object across all external-schemas
+#set ( $mapDBMapBuilders = [] ) ## Collect all table map builders across all external-schemas
+
+#foreach ($database in $dataModels)
+
+    #if ($database.Package)
+      #set ($package = $database.Package)
+    #else
+      #set ($package = $targetPackage)
+    #end
+
+    #if ($subpackagePeer)
+      #set ($packagePeer = "${package}.${subpackagePeer}")
+    #else
+      #set ($packagePeer = "${package}")
+    #end
+
+    #if ($subpackageObject)
+      #set ($packageObject = "${package}.${subpackageObject}")
+    #else
+      #set ($packageObject = "${package}")
+    #end
+
+    #if ($subpackageMap)
+      #set ($packageMap = "${package}.${subpackageMap}")
+    #else
+      #set ($packageMap = "${package}")
+    #end
+
+    #if ($subpackageManager)
+      #set ($packageManager = "${package}.${subpackageManager}")
+    #else
+      #set ($packageManager = "${package}")
+    #end
+
+    #if ($subpackageBean)
+      #set ($packageBean = "${package}.${subpackageBean}")
+    #else
+      #set ($packageBean = "${package}")
+    #end
+
+    #if ($subpackageBase)
+      #set ($packageBasePeer = "${package}.${subpackageBase}")
+      #set ($packageBaseObject = "${package}.${subpackageBase}")
+      #set ($packageBaseManager = "${package}.${subpackageBase}")
+    #else
+      #set ($packageBasePeer = "${package}")
+      #set ($packageBaseObject = "${package}")
+      #set ($packageBaseManager = "${package}")
+    #end
+
+    #if ($subpackageBaseBean)
+      #set ($packageBaseBean = "${package}.${subpackageBaseBean}")
+    #else
+      #set ($packageBaseBean = "${package}")
+    #end
+
+    BasePeers generated in package $packageBasePeer
+    BaseObjects generated in package $packageBaseObject
+    BaseManagers generated in package $packageBaseManager
+    BaseBeans generated in package $packageBaseBean
+    Maps generated in package $packageMap
+
+    #set ( $path = $strings.getPackageAsPath($packageBasePeer) )
+    $files.mkdir("$outputDirectory/$path")
+
+    #set ( $path = $strings.getPackageAsPath($packageBaseObject) )
+    $files.mkdir("$outputDirectory/$path")
+
+    #set ( $path = $strings.getPackageAsPath($packageMap) )
+    $files.mkdir("$outputDirectory/$path")
+
+    #if ($useManagers)
+      #set ( $path = $strings.getPackageAsPath($packageBaseManager) )
+      $files.mkdir("$outputDirectory/$path")
+    #end
+
+    #if ($generateBeans)
+      #set ( $path = $strings.getPackageAsPath($packageBaseBean) )
+      $files.mkdir("$outputDirectory/$path")
+    #end
+
+	#if ( !$mapDBNames.contains( $database.Name ) )
+## Adding new database entry for $database.Name	
+	  #set ( $retVal = $mapDBNames.add( $database.Name ) )
+	  #set ( $retVal = $mapDatabases.add( $database ) )
+	  #set ( $builderArray = [] ) 
+	  #set ( $retVal = $mapDBMapBuilders.add( $builderArray ) )
+	#else
+## Using existing database entry for $database.Name
+	  #set ( $dbIndex = $mapDBinfo.indexOf( $database.Name ) )
+	  #set ( $builderArray = $mapDBMapBuilders.get( $dbIndex ) )
+	#end
+	
+	#foreach ($tbl in $database.Tables)
+	  #if ( !$tbl.isAlias() && !$tbl.isForReferenceOnly() )
+## Adding new table Peer = "${packagePeer}.${tbl.JavaName}Peer"
+	    #set ($retVar = $builderArray.add("${packagePeer}.${tbl.JavaName}Peer") )
+	  #end
+	#end
+
+    #foreach ($tbl in $database.Tables)
+      #if (!$tbl.isForReferenceOnly())
+        $tbl.Name
+
+        $!tbl.setCorrectGetters($!correctGetters)
+        #set ( $firstcap=$tbl.JavaName )
+
+        #set ( $fname = "$basePrefix${firstcap}Peer.java" )
+        #set ( $path = "${strings.getPackageAsPath($packageBasePeer)}$fname" )
+        $generator.parse("om/Peer.vm",$path,"table",$tbl)
+
+        #if (!$tbl.isAlias())
+          #set ( $fname = "${firstcap}MapBuilder.java" )
+          #set ( $path = "${strings.getPackageAsPath($packageMap)}$fname" )
+          $generator.parse("om/MapBuilder.vm",$path,"table",$tbl)
+        #end
+
+        #if ($useManagers && $tbl.PrimaryKey.size() > 0)
+          #set ($interfaceName = $table.JavaName)
+          #if ($table.Interface)
+            #set ($interfaceName = $table.Interface)
+          #end
+
+          #set ( $fname = "${basePrefix}${interfaceName}Manager.java" )
+          #set ( $path = "${strings.getPackageAsPath($packageBaseManager)}$fname" )
+          $generator.parse("om/BaseManager.vm",$path,"table",$tbl)
+
+          #set ( $fname = "${interfaceName}Manager.java" )
+          #set ( $path = "${strings.getPackageAsPath($packageManager)}$fname" )
+          #if (!$files.file($basePath,$path).exists())
+            $generator.parse("om/ExtensionManager.vm",$path,"table",$tbl)
+          #end
+        #end
+
+        #if ($useManagers)
+          #set ( $fname = "${basePrefix}${firstcap}.java" )
+          #set ( $path = "${strings.getPackageAsPath($packageBaseObject)}$fname" )
+          $generator.parse("om/ObjectWithManager.vm",$path,"table",$tbl)
+        #else
+          #set ( $fname = "${basePrefix}${firstcap}.java" )
+          #set ( $path = "${strings.getPackageAsPath($packageBaseObject)}$fname" )
+          $generator.parse("om/Object.vm",$path,"table",$tbl)
+        #end
+
+        #if ($generateBeans)
+          #set ( $fname = "${basePrefix}${firstcap}${beanSuffix}.java" )
+          #set ( $path = "${strings.getPackageAsPath($packageBaseBean)}$fname" )
+          $generator.parse("om/bean/Bean.vm",$path,"table",$tbl)
+        #end
+
+      #end
+    #end
+#end
+
+#foreach ( $dbName in $mapDBNames )
+	#set ( $dbIndex = $mapDBNames.indexOf( $dbName ) )
+	#set ( $peerNames = $mapDBMapBuilders.get( $dbIndex ) )
+	#set ( $database = $mapDatabases.get( $dbIndex ) )
+
+    #if ($database.Package)
+      #set ($package = $database.Package)
+    #else
+      #set ($package = $targetPackage)
+    #end
+
+    #if ($subpackageMap)
+      #set ($packageMap = "${package}.${subpackageMap}")
+    #else
+      #set ($packageMap = "${package}")
+    #end
+
+    #set ( $fname = "${database.JavaName}MapInit.java" )
+    #set ( $path = "${strings.getPackageAsPath($packageMap)}$fname" )
+    $generator.parse("om/DatabaseMapInit.vm", $path, "database", $database)
+
+## Hard coded linkage package that must match one used by runtime DatabaseMap.initialize()
+	#set ( $packageLinkage = "org.apache.torque.linkage" );
+	#set ( $path = $strings.getPackageAsPath($packageLinkage) )
+    $files.mkdir("$outputDirectory/$path")
+	
+    #set ( $fname = "${database.StandardJavaName}MapInit.java" )
+    #set ( $path = "$strings.getPackageAsPath($packageLinkage)$fname" )
+    #if (!$files.file($basePath,$path).exists())
+      $generator.parse("om/DatabaseMapInitLinkageObject.vm", $path, "database", $database)
+    #end
+
+#end

Modified: db/torque/test/trunk/test-project/maven.xml
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/maven.xml?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/test/trunk/test-project/maven.xml (original)
+++ db/torque/test/trunk/test-project/maven.xml Wed Jan 24 12:23:57 2007
@@ -71,6 +71,8 @@
     <attainGoal name="torque:om"/>
 
     <mkdir dir="${torque.test.compile.dir}" />
+
+    <echo>Compiling sources in ${torque.test.src.dir}</echo>
     <javac
       debug="${torque.compile.debug}"
       deprecation="${torque.compile.deprecation}"
@@ -80,18 +82,39 @@
       <classpath refid="maven.dependency.classpath"/>
     </javac>
 
-    <javac
-      debug="${torque.compile.debug}"
-      deprecation="${torque.compile.deprecation}"
-      destdir="${torque.test.compile.dir}"
-      optimize="${torque.compile.optimize}"
-      srcdir="${torque.java.dir}">
-      <classpath>
-        <pathelement location="${torque.test.compile.dir}"/>
-        <path refid="maven.dependency.classpath"/>
-      </classpath>
-    </javac>
+    <j:set var="javaDir" value="${torque.java.dir}"/>
+    <j:set var="javaBaseDir" value="${torque.java.base.dir}"/>
+    <j:if test="${javaDir != javaBaseDir}">
+      <echo>Compiling sources in ${torque.java.base.dir} and ${torque.java.dir}</echo>
+      <javac
+        debug="${torque.compile.debug}"
+        deprecation="${torque.compile.deprecation}"
+        destdir="${torque.test.compile.dir}"
+        optimize="${torque.compile.optimize}">
+        <classpath>
+          <pathelement location="${torque.test.compile.dir}"/>
+          <path refid="maven.dependency.classpath"/>
+        </classpath>
+      	<src path="${torque.java.base.dir}" />
+      	<src path="${torque.java.dir}" />      	
+      </javac>
+    </j:if>
+    <j:if test="${javaDir == javaBaseDir}">
+    <echo>Compiling sources in ${torque.java.dir}</echo>
+      <javac
+        debug="${torque.compile.debug}"
+        deprecation="${torque.compile.deprecation}"
+        destdir="${torque.test.compile.dir}"
+        optimize="${torque.compile.optimize}"
+        srcdir="${torque.java.dir}">
+        <classpath>
+          <pathelement location="${torque.test.compile.dir}"/>
+          <path refid="maven.dependency.classpath"/>
+        </classpath>
+      </javac>
+    </j:if>
 
+    <echo>Compiling sources in ${torque.test.junit.src.dir}</echo>
     <javac
       debug="${torque.compile.debug}"
       deprecation="${torque.compile.deprecation}"

Modified: db/torque/test/trunk/test-project/project.properties
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/project.properties?view=diff&rev=499556&r1=499555&r2=499556
==============================================================================
--- db/torque/test/trunk/test-project/project.properties (original)
+++ db/torque/test/trunk/test-project/project.properties Wed Jan 24 12:23:57 2007
@@ -39,6 +39,8 @@
 # The java classes are generated in the target to remove them vith a simple 
 # "maven clean"
 torque.java.dir=target/java
+# for testing to generate the base classes in another directory
+#torque.java.base.dir=target/java-base
 
 # The generator should read the schema files from the target directory
 # where some tokens have been replaced by the torque-test:prepare task 



---------------------------------------------------------------------
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