You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/09/25 21:33:18 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/torque TorqueCreateDatabase.java TorqueSQLTask.java

jvanzyl     01/09/25 12:33:18

  Modified:    src/java/org/apache/turbine/torque TorqueCreateDatabase.java
                        TorqueSQLTask.java
  Log:
  - using the data model as the source of info for creating the
    databases for an application. previously using the project name
    which is very limiting as it doesn't take into consideration
    multi-database apps.
  
  Revision  Changes    Path
  1.2       +49 -31    jakarta-turbine-2/src/java/org/apache/turbine/torque/TorqueCreateDatabase.java
  
  Index: TorqueCreateDatabase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/torque/TorqueCreateDatabase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueCreateDatabase.java	2001/08/16 05:09:29	1.1
  +++ TorqueCreateDatabase.java	2001/09/25 19:33:18	1.2
  @@ -58,16 +58,31 @@
   import org.apache.velocity.VelocityContext;
   import org.apache.velocity.texen.ant.TexenTask;
   
  +import org.apache.turbine.torque.engine.database.model.AppData;
  +import org.apache.turbine.torque.engine.database.transform.XmlToAppData;
  +
   /**
    * An extended Texen task used for generating simple scripts
    * for creating databases on various platforms.
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: TorqueCreateDatabase.java,v 1.1 2001/08/16 05:09:29 jvanzyl Exp $
  + * @version $Id: TorqueCreateDatabase.java,v 1.2 2001/09/25 19:33:18 jvanzyl Exp $
    */
  -public class TorqueCreateDatabase extends TexenTask
  +public class TorqueCreateDatabase 
  +    extends TexenTask
   {
       /**
  +     * Application model. In this case a database model.
  +     */
  +    private AppData app;
  +
  +    /**
  +     * XML that describes the database model, this is transformed
  +     * into the application model object.
  +     */
  +    private String xmlFile;
  +
  +    /**
        * The target database vendor: MySQL, Oracle.
        */
       private String targetDatabase;
  @@ -80,11 +95,6 @@
       private String targetPlatform;
   
       /**
  -     * Name of the database to create.
  -     */
  -    private String databaseName;
  -
  -    /**
        * Database user.
        */
       private String databaseUser;
  @@ -100,6 +110,28 @@
       private String databaseHost;
   
       /**
  +     * Get the xml schema describing the application
  +     * model.
  +     *
  +     * @return String xml schema file.
  +     */
  +    public String getXmlFile ()
  +    {
  +        return xmlFile;
  +    }
  +
  +    /**
  +     * Set the xml schema describing the application
  +     * model.
  +     *
  +     * @param String xml schema file.
  +     */
  +    public void setXmlFile(String v)
  +    {
  +        xmlFile = v;
  +    }
  +
  +    /**
        * Get the target database.
        *
        * @return String target database.
  @@ -140,26 +172,6 @@
       }
   
       /**
  -     * Get the database name.
  -     *
  -     * @return String database name.
  -     */
  -    public String getDatabaseName ()
  -    {
  -        return databaseName;
  -    }
  -
  -    /**
  -     * Set the database name.
  -     *
  -     * @param String database name.
  -     */
  -    public void setDatabaseName (String v)
  -    {
  -        databaseName = v;
  -    }
  -
  -    /**
        * Get the database user.
        *
        * @return String target platform.
  @@ -226,13 +238,19 @@
        */
       public Context initControlContext()
       {
  -        /*
  -         * Create a new Velocity context.
  -         */
  +        // Create a new Velocity context.
           Context context = new VelocityContext();
  +        
  +        // Transform the XML database schema into an
  +        // object that represents our model.
  +        XmlToAppData xmlParser = new XmlToAppData();
  +        app = xmlParser.parseFile(xmlFile);
  +
  +        // Place our model in the context.
  +        context.put("appData", app);
  +
           context.put("targetDatabase", targetDatabase);
           context.put("targetPlatform", targetPlatform);
  -        context.put("databaseName", databaseName);
           context.put("databaseUser", databaseUser);
           context.put("databasePassword", databasePassword);
           context.put("databaseHost", databaseHost);
  
  
  
  1.2       +7 -16     jakarta-turbine-2/src/java/org/apache/turbine/torque/TorqueSQLTask.java
  
  Index: TorqueSQLTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/torque/TorqueSQLTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TorqueSQLTask.java	2001/08/16 05:09:31	1.1
  +++ TorqueSQLTask.java	2001/09/25 19:33:18	1.2
  @@ -54,8 +54,6 @@
    * <http://www.apache.org/>.
    */
   
  -import java.util.Date;
  -
   import org.apache.velocity.context.Context;
   import org.apache.velocity.VelocityContext;
   import org.apache.velocity.texen.ant.TexenTask;
  @@ -69,7 +67,7 @@
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: TorqueSQLTask.java,v 1.1 2001/08/16 05:09:31 jvanzyl Exp $
  + * @version $Id: TorqueSQLTask.java,v 1.2 2001/09/25 19:33:18 jvanzyl Exp $
    */
   public class TorqueSQLTask extends TexenTask
   {
  @@ -141,26 +139,19 @@
        */
       public Context initControlContext()
       {
  -        /*
  -         * Create a new Velocity context.
  -         */
  +
  +        // Create a new Velocity context.
           Context context = new VelocityContext();
           
  -        /*
  -         * Transform the XML database schema into an
  -         * object that represents our model.
  -         */
  +        // Transform the XML database schema into an
  +        // object that represents our model.
           XmlToAppData xmlParser = new XmlToAppData();
           app = xmlParser.parseFile(xmlFile);
           
  -        /*
  -         * Place our model in the context.
  -         */
  +        // Place our model in the context.
           context.put("appData", app);
   
  -        /*
  -         * Place the target database in the context.
  -         */
  +        // Place the target database in the context.
           context.put("targetDatabase", targetDatabase);
           
           return context;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org