db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r580875 - in /db/torque: maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/IdTableInitSqlMojo.java maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java site/trunk/xdocs/changes.xml test/trunk/test-project/pom.xml
Date Mon, 01 Oct 2007 07:25:14 GMT
Author: tfischer
Date: Mon Oct  1 00:25:08 2007
New Revision: 580875

URL: http://svn.apache.org/viewvc?rev=580875&view=rev
Log:
- Added the id-table-init-sql goal to the maven2 plugin
- the suffix parameter in the sql goal in the maven2 plugin now works.
Fixes TORQUE-101. Thanks to Marc Kannegiesser for the patch.

Added:
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/IdTableInitSqlMojo.java
Modified:
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java
    db/torque/site/trunk/xdocs/changes.xml
    db/torque/test/trunk/test-project/pom.xml

Added: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/IdTableInitSqlMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/IdTableInitSqlMojo.java?rev=580875&view=auto
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/IdTableInitSqlMojo.java
(added)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/IdTableInitSqlMojo.java
Mon Oct  1 00:25:08 2007
@@ -0,0 +1,189 @@
+package org.apache.torque.mojo;
+
+/*
+ * 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.
+ */
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.torque.task.TorqueSQLTask;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Generates SQL for creating the database from the schema.xml files.
+ *
+ * @author Raphael Pieroni (rafale_at_codehaus.org)
+ * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
+ * @author <a href="kannegiesser@synyx.de">Marc Kannegiesser</a>
+ *
+ * @goal id-table-init-sql
+ * @phase generate-sources
+ */
+public class IdTableInitSqlMojo extends SqlMojo
+{
+    public static final String INITIALID_CONTEXT_PROPERTY
+            = "initialID";
+    public static final String INITIALIDVALUE_CONTEXT_PROPERTY
+            = "initialIDValue";
+    public static final String INITIALIDSTEP_CONTEXT_PROPERTY
+            = "initialIDStep";
+
+    // The following dummies trick the Mojo Description Extractor
+    // into setting the correct default values for
+    // reportFile and contextPropertiesPath
+    /**
+     * The location where the report file will be generated.
+     *
+     * @parameter property="reportFile"
+     *            expression="../../torque/report.${project.artifact.artifactId}.idtable-init-sql.generation"
+     */
+    private String dummy2;
+
+    /**
+     * The location where the context property file for velocity will be
+     * generated.
+     *
+     * @parameter property="contextPropertiesPath"
+     *            expression="${project.build.directory}/torque/context.idtable-init-sql.properties"
+     */
+    private String dummy3;
+
+    /**
+     * The initial ID of the idtables
+     *
+     * @parameter expression="101"
+     */
+    private String initialID;
+
+    /**
+     * The initial IDValue of the idtable
+     *
+     * @parameter expression="1000"
+     */
+    private String initialIDValue;
+
+    /**
+     * The initial ID Step of the idtable
+     *
+     * @parameter expression="10"
+     */
+    private String initialIDStep;
+
+    /**
+     * Creates a new IdTableInitSqlMojo object.
+     */
+    public IdTableInitSqlMojo()
+    {
+    }
+
+    /**
+     * Sets the initial id of the idtables
+     *
+     * @param initialID The initial of the idtables
+     */
+    public void setInitialID(String initialID)
+    {
+        this.initialID = initialID;
+    }
+
+    /**
+     * Returns the initial id of the idtable
+     *
+     * @return initialID The initial ID of the idtables
+     */
+    public String getInitialID()
+    {
+        return this.initialID;
+    }
+
+
+
+    /**
+     * Sets the initial id value of the idtables
+     *
+     * @param initialIDValue The initial id value of the tables
+     */
+    public void setInitialIDValue(String initialIDValue)
+    {
+        this.initialIDValue = initialIDValue;
+    }
+
+    /**
+     * Returns the initial id value of the idtables
+     *
+     * @return initialIDValue the initial id value of the idtables
+     */
+    public String getInitialIDValue()
+    {
+        return this.initialIDValue;
+    }
+
+
+
+    /**
+     * Sets the initial id step of the idtables
+     *
+     * @param initialIDStep The initial id step of the tables
+     */
+    public void setInitialIDStep(String initialIDStep)
+    {
+        this.initialIDStep = initialIDStep;
+    }
+
+    /**
+     * Returns the initial id step of the idtables
+     *
+     * @return initialIDStep the initial id step of the idtables
+     */
+    public String getInitialIDStep()
+    {
+        return this.initialIDStep;
+    }
+
+    /**
+     * Returns the context properties for the Texen task.
+     *
+     * @return The PropertiesConfiguration containing all context properties,
+     *         not null.
+     */
+    protected PropertiesConfiguration getMojoContextProperties()
+    {
+      PropertiesConfiguration configuration = super.getMojoContextProperties();
+      configuration.addProperty(
+               INITIALID_CONTEXT_PROPERTY,
+               initialID);
+
+      configuration.addProperty(
+               INITIALIDVALUE_CONTEXT_PROPERTY,
+               initialIDValue);
+
+      configuration.addProperty(
+               INITIALIDSTEP_CONTEXT_PROPERTY,
+               initialIDStep);
+        return configuration;
+    }
+
+    /**
+     * Returns the path to the control template.
+     *
+     * @return "sql/id-table/Control.vm"
+     */
+    protected String getControlTemplate()
+    {
+        return "sql/id-table/Control.vm";
+    }
+}

Modified: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java?rev=580875&r1=580874&r2=580875&view=diff
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java (original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/SqlMojo.java Mon Oct
 1 00:25:08 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.torque.task.TorqueSQLTask;
 
 /**
@@ -27,6 +28,7 @@
  *
  * @author Raphael Pieroni (rafale_at_codehaus.org)
  * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
+ * @author <a href="kannegiesser@synyx.de">Marc Kannegiesser</a>
  *
  * @goal sql
  * @phase generate-sources
@@ -149,4 +151,30 @@
     {
         return "sql/base/Control.vm";
     }
+
+    /**
+      * Configures the Texen task which is wrapped by this mojo.
+      * In this implementation, the context properties, useClasspath,
+      * the output directory, the control template, the schema Fileset,
+      * the target package, the target database  and the suffix are set.
+      *
+      * @throws MojoExecutionException if an error occurs when setting the Tasks
+      *         properties.
+      *
+      * @see TexenTaskMojo#configureTask()
+      */
+     protected void configureTask() throws MojoExecutionException
+     {  
+         super.configureTask();
+         
+         TorqueSQLTask task
+                 = (TorqueSQLTask) super.getGeneratorTask();
+       
+         if (suffix != null)
+         {  
+             getLog().debug("Adding suffix: " + suffix );
+             task.setSuffix(suffix);
+         }
+     
+     }
 }

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?rev=580875&r1=580874&r2=580875&view=diff
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Mon Oct  1 00:25:08 2007
@@ -31,6 +31,12 @@
 
   <body>
   <release version="3.3-RC3" date="in SVN">
+    <action type="add" dev="tfischer" issue="TORQUE-101" due-to="Marc Kannegiesser">
+      Implemented the goal id-broker-init-sql in the Maven2 plugin.
+    </action>
+    <action type="fix" dev="tfischer" due-to="Marc Kannegiesser">
+      The suffix parameter to the Maven2-plugin's sql task now works.
+    </action>
     <action type="add" dev="tfischer" issue="TORQUE-99" due-to="Tobias Hilka">
       Added copy(..) and add<ForeignKey>(..) methods with a connection 
       parameter.

Modified: db/torque/test/trunk/test-project/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/pom.xml?rev=580875&r1=580874&r2=580875&view=diff
==============================================================================
--- db/torque/test/trunk/test-project/pom.xml (original)
+++ db/torque/test/trunk/test-project/pom.xml Mon Oct  1 00:25:08 2007
@@ -160,6 +160,7 @@
               <goal>sql</goal>
               <goal>sqlExec</goal>
               <goal>documentation</goal>
+              <goal>id-table-init-sql</goal>
             </goals>
           </execution>
           <execution>



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