db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r419288 - /db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java
Date Wed, 05 Jul 2006 17:26:01 GMT
Author: tfischer
Date: Wed Jul  5 10:26:01 2006
New Revision: 419288

URL: http://svn.apache.org/viewvc?rev=419288&view=rev
Log:
New Mojo for the DataDump task

Added:
    db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java

Added: 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?rev=419288&view=auto
==============================================================================
--- db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java (added)
+++ db/torque/maven2-plugin/trunk/src/main/java/org/apache/torque/mojo/DataDumpMojo.java Wed
Jul  5 10:26:01 2006
@@ -0,0 +1,231 @@
+package org.apache.torque.mojo;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.torque.task.TorqueDataDumpTask;
+
+/**
+ * @author Raphael Pieroni (rafale_at_codehaus.org)
+ * @author <a href="fischer@seitenbau.de">Thomas Fischer</a> 
+ *
+ * @goal dataDump
+ * @phase generate-sources
+ */
+public class DataDumpMojo extends DataModelTaskMojo
+{
+    /** The context property for the name of the project. */
+    public static final String PROJECT_CONTEXT_PROPERTY
+        = "project";
+
+    // this is here in order do trick the Mojo Description Extractor 
+    // into setting the parameter outputDir, reportFile and 
+    // contextPropertiesPath.
+    /**
+     * @parameter property="outputDir" expression="${project.build.directory}/data/torque"
+     */
+    private String dummy;
+
+    /**
+     * @parameter property="reportFile" expression="../../torque/report.${project.artifact.artifactId}.data.generation"
+     */
+    private String dummy2;
+
+    /**
+     * @parameter property="contextPropertiesPath" expression="${project.build.directory}/torque/context.data.properties"
+     */
+    private String dummy3;
+
+    /**
+     * The fully qualified class name of the database driver.
+     * @parameter
+     * @required 
+     */
+    private String driver = null;
+
+    /** 
+     * The connect URL of the database.
+     * @parameter
+     * @required
+     */
+    private String url = null;
+
+    /** 
+     * The user name to connect to the database.
+     * @parameter
+     * @required
+     */
+    private String user = null;
+
+    /** 
+     * The password for the database user.
+     * @parameter 
+     */
+    private String password = null;
+
+    /**
+     * The name of the project, used as a prefix of the names
+     * of the generated files and the name of the datadtd.
+     * @parameter expression="torque"
+     */
+    private String projectName = null;
+
+    /**
+     * Creates a new SQLMojo object.
+     */
+    public DataDumpMojo()
+    {
+        super(new TorqueDataDumpTask());
+    }
+
+    /**
+     * Returns the path to the control template.
+     * 
+     * @return "data/Control.vm"
+     */
+    protected String getControlTemplate()
+    {
+        return "data/dump/Control.vm";
+    }
+
+    /**
+     * 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 context properties, useClasspath,
+     * the output directory, the control template, the schema Fileset,
+     * the target package and the target database are set. 
+     * 
+     * @throws MojoExecutionException if an error occurs when setting the Tasks
+     *         properties.
+     *         
+     * @see TexenTaskMojo#configureTask()
+     */
+    protected void configureTask() throws MojoExecutionException
+    {
+        super.configureTask();
+
+        TorqueDataDumpTask task 
+                = (TorqueDataDumpTask) super.getGeneratorTask();
+
+        task.setDatabaseDriver(driver);
+        
+        task.setDatabaseUrl(url);
+        
+        task.setDatabaseUser(user);
+        
+        task.setDatabasePassword(password);
+    }
+
+    /**
+     * Returns the fully qualified class name of the database driver.
+     *
+     * @return the fully qualified class name of the database driver.
+     */
+    public String getDriver()
+    {
+        return driver;
+    }
+
+    /**
+     * Sets the fully qualified class name of the database driver.
+     * 
+     * @param driver the fully qualified class name of the database driver.
+     */
+    public void setDriver(String driver)
+    {
+        this.driver = driver;
+    }
+
+    /**
+     * Returns the password of the database user.
+     * 
+     * @return the password of the database user.
+     */
+    public String getPassword()
+    {
+        return password;
+    }
+
+    /**
+     * Sets the password of the database user.
+     * 
+     * @param password the password of the database user.
+     */
+    public void setPassword(String password)
+    {
+        this.password = password;
+    }
+
+    /**
+     * Returns the connect URL to the database.
+     * 
+     * @return the connect URL to the database.
+     */
+    public String getUrl()
+    {
+        return url;
+    }
+
+    /**
+     * Sets the connect URL to the database.
+     * 
+     * @param url the connect URL to the database.
+     */
+    public void setUrl(String url)
+    {
+        this.url = url;
+    }
+
+    /**
+     * Returns the database user.
+     * 
+     * @return the userId of the database user.
+     */
+    public String getUser()
+    {
+        return user;
+    }
+
+    /**
+     * Sets the database user.
+     * 
+     * @param user the userId of the database user.
+     */
+    public void setUser(String user)
+    {
+        this.user = user;
+    }
+    
+    /**
+     * Returns the name of the project, which is used as prefix for the
+     * generated table names and 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
+     * generated table names and the name of the datadtd.
+     * 
+     * @param project the name of the project.
+     */
+    public void setProjectName(String projectName)
+    {
+        this.projectName = projectName;
+    }
+}
\ No newline at end of file



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