db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r535555 - in /db/torque: maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/ site/trunk/xdocs/ test/trunk/test-project/
Date Sat, 05 May 2007 18:28:51 GMT
Author: tfischer
Date: Sat May  5 11:28:50 2007
New Revision: 535555

URL: http://svn.apache.org/viewvc?view=rev&rev=535555
Log:
- Changed the maven2 plugin's datadump goal to accept only a single schema xml. Multiple schema
xmls produced illegal output. 
- Fixed the maven2 plugin's datasql goal to do the same as the ant and maven1 datasql task.
No idea what it did before, but it was not anything useful.
- Added a datadtd goal to the maven2 plugin.
- updated the test project to prove that the three goals work as expected.

Added:
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDtdMojo.java
Modified:
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataSqlMojo.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/DataDtdMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDtdMojo.java?view=auto&rev=535555
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDtdMojo.java (added)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDtdMojo.java Sat
May  5 11:28:50 2007
@@ -0,0 +1,178 @@
+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.maven.plugin.MojoExecutionException;
+import org.apache.torque.task.TorqueDataModelTask;
+
+/**
+ * Generates a data dtd from schema files.
+ *
+ * @author Raphael Pieroni (rafale_at_codehaus.org)
+ * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
+ *
+ * @goal datadtd
+ * @phase generate-sources
+ */
+public class DataDtdMojo extends DataModelTaskMojo
+{
+    /** The context property for the name of the project. */
+    public static final String PROJECT_CONTEXT_PROPERTY = "project";
+
+    // The following three dummies trick the Mojo Description Extractor
+    // into setting the correct default values for
+    // outputDir, reportFile and contextPropertiesPath
+    /**
+     * The directory in which the SQL will be generated.
+     *
+     * @parameter property="outputDir"
+     *            expression="${project.build.directory}/data/torque"
+     */
+    private String dummy;
+
+    /**
+     * The location where the report file will be generated, 
+     * relative to outputDir.
+     *
+     * @parameter property="reportFile"
+     *            expression="../../torque/report.${project.artifact.artifactId}.datadtd.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.datadtd.properties"
+     */
+    private String dummy3;
+
+    /**
+     * The name of the project, used as a prefix of the name of the datadtd.
+     *
+     * @parameter expression="torque"
+     */
+    private String projectName = null;
+
+    /**
+     * The name of the xml file to process. Only one xml file can be processed
+     * at a time.
+     * Overrides the settings schemaIncludes and schemaExcludes
+     *
+     * @parameter
+     * @required
+     */
+    private String xmlFile = null;
+
+    /**
+     * Creates a new SQLMojo object.
+     */
+    public DataDtdMojo()
+    {
+        super(new TorqueDataModelTask());
+    }
+
+    /**
+     * Returns the context properties for the Texen task.
+     *
+     * @return The PropertiesConfiguration containing all context properties,
+     *         not null.
+     */
+    protected PropertiesConfiguration getMojoContextProperties()
+    {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty(PROJECT_CONTEXT_PROPERTY, projectName);
+        return configuration;
+    }
+
+    /**
+     * Configures the Texen task which is wrapped by this mojo.
+     * In this implementation, the xml file is set in addition to the
+     * properties set by DataModelTaskMojo#configureTask().
+     *
+     * @throws MojoExecutionException if an error occurs when setting the Tasks
+     *         properties.
+     *
+     * @see DataModelTaskMojo#configureTask()
+     */
+    protected void configureTask() throws MojoExecutionException
+    {
+        super.configureTask();
+
+        TorqueDataModelTask task
+                = (TorqueDataModelTask) super.getGeneratorTask();
+
+        task.setXmlFile(xmlFile);
+    }
+
+    /**
+     * Returns the path to the control template.
+     *
+     * @return "sql/Control.vm"
+     */
+    protected String getControlTemplate()
+    {
+        return "data/Control.vm";
+    }
+
+    /**
+     * Returns the name of the project, which is used as prefix for the name
+     * of the datadtd.
+     *
+     * @return the name of the project.
+     */
+    public String getProjectName()
+    {
+        return projectName;
+    }
+
+    /**
+     * Sets the name of the project, which is used as prefix for the
+     * name of the datadtd.
+     *
+     * @param project the name of the project.
+     */
+    public void setProjectName(String projectName)
+    {
+        this.projectName = projectName;
+    }
+
+    /**
+     * Returns the name of the xml file to process.
+     *
+     * @return the name of the xml file to process.
+     */
+    public String getXmlFile()
+    {
+        return xmlFile;
+    }
+
+    /**
+     * Sets the name of the xml file to process.
+     *
+     * @param project the name of the xml file to process.
+     */
+    public void setXmlFile(String xmlFile)
+    {
+        this.xmlFile = xmlFile;
+    }
+}

Modified: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java?view=diff&rev=535555&r1=535554&r2=535555
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java (original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java Sat
May  5 11:28:50 2007
@@ -107,6 +107,16 @@
     private String projectName = null;
 
     /**
+     * The name of the xml file to process. Only one xml file can be processed
+     * at a time.
+     * Overrides the settings schemaIncludes and schemaExcludes
+     *
+     * @parameter
+     * @required
+     */
+    private String xmlFile = null;
+
+    /**
      * Creates a new SQLMojo object.
      */
     public DataDumpMojo()
@@ -141,7 +151,7 @@
      * 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 and the target database are set.
+     * the target package, the target database and the xml file are set.
      *
      * @throws MojoExecutionException if an error occurs when setting the Tasks
      *         properties.
@@ -156,12 +166,10 @@
                 = (TorqueDataDumpTask) super.getGeneratorTask();
 
         task.setDatabaseDriver(driver);
-
         task.setDatabaseUrl(url);
-
         task.setDatabaseUser(user);
-
         task.setDatabasePassword(password);
+        task.setXmlFile(xmlFile);
     }
 
     /**
@@ -264,5 +272,25 @@
     public void setProjectName(String projectName)
     {
         this.projectName = projectName;
+    }
+
+    /**
+     * Returns the name of the xml file to process.
+     *
+     * @return the name of the xml file to process.
+     */
+    public String getXmlFile()
+    {
+        return xmlFile;
+    }
+
+    /**
+     * Sets the name of the xml file to process.
+     *
+     * @param project the name of the xml file to process.
+     */
+    public void setXmlFile(String xmlFile)
+    {
+        this.xmlFile = xmlFile;
     }
 }

Modified: db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataSqlMojo.java
URL: http://svn.apache.org/viewvc/db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataSqlMojo.java?view=diff&rev=535555&r1=535554&r2=535555
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataSqlMojo.java (original)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataSqlMojo.java Sat
May  5 11:28:50 2007
@@ -20,7 +20,8 @@
  */
 
 import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.torque.task.TorqueSQLTask;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.torque.task.TorqueDataSQLTask;
 
 /**
  * Generates SQL for populating the database from data.xml files.
@@ -45,10 +46,10 @@
     private String dummy;
 
     /**
-     * The location where the report file will be generated.
+     * The location where the sql file will be generated.
      *
      * @parameter property="reportFile"
-     *            expression="../../torque/report.${project.artifact.artifactId}.datasql.generation"
+     *            expression="${project.artifact.artifactId}-data.sql"
      */
     private String dummy2;
 
@@ -62,11 +63,27 @@
     private String dummy3;
 
     /**
+     * The data Xml file to process.
+     *
+     * @parameter
+     * @required
+     */
+    private String dataXmlFile;
+
+    /**
+     * The data dtd file for the data xml file to process.
+     *
+     * @parameter
+     * @required
+     */
+    private String dataDtd;
+
+    /**
      * Creates a new SQLMojo object.
      */
     public DataSqlMojo()
     {
-        super(new TorqueSQLTask());
+        super(new TorqueDataSQLTask());
     }
 
     /**
@@ -82,6 +99,27 @@
     }
 
     /**
+     * Configures the Texen task which is wrapped by this mojo.
+     * In addition to the prioerties set by DataModelTaskMojo#configureTask(),
+     * the properties dataXmlFile and dataDTD are set.
+     *
+     * @throws MojoExecutionException if an error occurs when setting the Tasks
+     *         properties.
+     *
+     * @see DataModelTaskMojo#configureTask()
+     */
+    protected void configureTask() throws MojoExecutionException
+    {
+        super.configureTask();
+
+        TorqueDataSQLTask task
+                = (TorqueDataSQLTask) super.getGeneratorTask();
+
+        task.setDataXmlFile(dataXmlFile);
+        task.setDataDTD(dataDtd);
+    }
+
+    /**
      * Returns the path to the control template.
      *
      * @return "sql/load/Control.vm"
@@ -89,5 +127,45 @@
     protected String getControlTemplate()
     {
         return "sql/load/Control.vm";
+    }
+
+    /**
+     * Returns the data dtd file for the data xml file.
+     *
+     * @return the data dtd file for the data xml file.
+     */
+    public String getDataDtd()
+    {
+        return dataDtd;
+    }
+
+    /**
+     * Sets the data dtd file for the data xml file.
+     *
+     * @param dataDtd the data dtd file for the data xml file.
+     */
+    public void setDataDtd(String dataDtd)
+    {
+        this.dataDtd = dataDtd;
+    }
+
+    /**
+     * Returns the data xml file which should be processed.
+     *
+     * @return the data xml file which should be processed.
+     */
+    public String getDataXmlFile()
+    {
+        return dataXmlFile;
+    }
+
+    /**
+     * Sets the data xml file which should be processed.
+     *
+     * @param dataXmlFile the data xml file which should be processed.
+     */
+    public void setDataXmlFile(String dataXmlFile)
+    {
+        this.dataXmlFile = dataXmlFile;
     }
 }

Modified: db/torque/site/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/changes.xml?view=diff&rev=535555&r1=535554&r2=535555
==============================================================================
--- db/torque/site/trunk/xdocs/changes.xml (original)
+++ db/torque/site/trunk/xdocs/changes.xml Sat May  5 11:28:50 2007
@@ -31,6 +31,17 @@
 
   <body>
   <release version="3.3-RC3" date="in SVN">
+    <action type="fix" dev="tfischer">
+      Changed the maven2 plugin's datadump goal to accept only a single schema
+      xml. Multiple schema xmls produced illegal output. 
+    </action>
+    <action type="fix" dev="tfischer">
+      Fixed the maven2 plugin's datasql goal to do the same as the ant and
+      maven1 datasql task. 
+    </action>
+    <action type="add" dev="tfischer">
+      Added a datadtd goal to the maven2 plugin.
+    </action>
     <action type="change" dev="tfischer">
       changed the artifact id of some maven2 artifacts:
       <ul>
@@ -47,7 +58,7 @@
       This change only affects maven2 users.
     </action>
     <action type="change" dev="tfischer">
-      changed the group id of the maven2 artifacts from
+      Changed the group id of the maven2 artifacts from
       org.apache.db.torque to org.apache.torque.
       This change only affects maven2 users.
     </action>

Modified: db/torque/test/trunk/test-project/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/pom.xml?view=diff&rev=535555&r1=535554&r2=535555
==============================================================================
--- db/torque/test/trunk/test-project/pom.xml (original)
+++ db/torque/test/trunk/test-project/pom.xml Sat May  5 11:28:50 2007
@@ -148,20 +148,34 @@
           <driver>${torque.driver}</driver>
           <url>${torque.database.url}</url>
           <user>${torque.database.user}</user>
-          <password>${torque.database.password}</password>
+          <password>${torque.database.password}</password>
+          <projectName>bookstore</projectName>
         </configuration>
         <executions>
           <execution>
-            <phase>generate-sources</phase>
+            <phase>generate-sources</phase>
+            <id>om</id>
             <goals>
               <goal>om</goal>
               <goal>sql</goal>
               <goal>sqlExec</goal>
               <goal>documentation</goal>
-              <goal>datadump</goal>
-              <goal>datasql</goal>
             </goals>
           </execution>
+          <execution>
+            <phase>test</phase>
+            <id>data</id>
+            <goals>
+              <goal>datadtd</goal>
+              <goal>datadump</goal>
+              <goal>datasql</goal>
+            </goals>
+            <configuration>
+              <xmlFile>target/torque/test/schema/bookstore-schema.xml</xmlFile>
+              <dataXmlFile>target/data/torque/bookstore-bookstore-all-data.xml</dataXmlFile>
+              <dataDtd>target/data/torque/bookstore-data.dtd</dataDtd>
+            </configuration>
+          </execution>
         </executions>
         <dependencies>
           <dependency>



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