You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by mp...@apache.org on 2001/12/18 22:47:54 UTC

cvs commit: jakarta-turbine-torque/src/templates/doc/anakia datamodel.vm table.vm

mpoeschl    01/12/18 13:47:54

  Modified:    src/conf build-torque.xml build.properties build.xml
  Added:       src/java/org/apache/torque/task TorqueDocumentationTask.java
               src/templates/doc Control.vm
               src/templates/doc/html datamodel.vm table.vm
               src/templates/doc/anakia datamodel.vm table.vm
  Log:
  initial version of the TorqueDocumentationTask
  
  Revision  Changes    Path
  1.14      +35 -0     jakarta-turbine-torque/src/conf/build-torque.xml
  
  Index: build-torque.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build-torque.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- build-torque.xml	2001/12/06 22:48:04	1.13
  +++ build-torque.xml	2001/12/18 21:47:53	1.14
  @@ -78,6 +78,41 @@
     </target>
   
     <!-- ================================================================ -->
  +  <!-- G E N E R A T E   D O C S                                        -->
  +  <!-- ================================================================ -->
  +
  +  <target
  +    name="project-doc"
  +    description="==> generates documentation for your datamodel">
  +
  +    <echo message="+------------------------------------------+"/>
  +    <echo message="|                                          |"/>
  +    <echo message="| Generating docs for YOUR datamodel!      |"/>
  +    <echo message="| Woo hoo!                                 |"/>
  +    <echo message="|                                          |"/>
  +    <echo message="+------------------------------------------+"/>
  +
  +    <taskdef
  +      name="torque-doc"
  +      classname="org.apache.torque.task.TorqueDocumentationTask">
  +      <classpath refid="torque-classpath"/>
  +    </taskdef>
  +
  +    <torque-doc
  +      contextProperties="${build.properties}"
  +      controlTemplate="${DocControlTemplate}"
  +      outputDirectory="${torque.home}/${outputDirectory}/doc"
  +      outputFormat="html"
  +      templatePath="${templatePath}"
  +      sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
  +      outputFile="report.${project}.doc.generation">
  +      <fileset dir="${torque.home}/${schemaDirectory}">
  +        <include name="*-schema.xml"/>
  +      </fileset>
  +    </torque-doc>
  +  </target>
  +
  +  <!-- ================================================================ -->
     <!-- C R E A T E  T A R G E T  D A T A B A S E                        -->
     <!-- ================================================================ -->
     <!-- Create the target database by executing a generated script       -->
  
  
  
  1.8       +1 -0      jakarta-turbine-torque/src/conf/build.properties
  
  Index: build.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- build.properties	2001/11/01 02:23:01	1.7
  +++ build.properties	2001/12/18 21:47:53	1.8
  @@ -120,6 +120,7 @@
   DataDTDControlTemplate = data/Control.vm
   DataDumpControlTemplate = data/dump/Control.vm
   DataSQLControlTemplate = sql/load/Control.vm
  +DocControlTemplate = doc/Control.vm
   
   # -------------------------------------------------------------------
   # 
  
  
  
  1.21      +35 -0     jakarta-turbine-torque/src/conf/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/conf/build.xml,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- build.xml	2001/12/06 22:48:04	1.20
  +++ build.xml	2001/12/18 21:47:53	1.21
  @@ -78,6 +78,41 @@
     </target>
   
     <!-- ================================================================ -->
  +  <!-- G E N E R A T E   D O C S                                        -->
  +  <!-- ================================================================ -->
  +
  +  <target
  +    name="project-doc"
  +    description="==> generates documentation for your datamodel">
  +
  +    <echo message="+------------------------------------------+"/>
  +    <echo message="|                                          |"/>
  +    <echo message="| Generating docs for YOUR datamodel!      |"/>
  +    <echo message="| Woo hoo!                                 |"/>
  +    <echo message="|                                          |"/>
  +    <echo message="+------------------------------------------+"/>
  +
  +    <taskdef
  +      name="torque-doc"
  +      classname="org.apache.torque.task.TorqueDocumentationTask">
  +      <classpath refid="torque-classpath"/>
  +    </taskdef>
  +
  +    <torque-doc
  +      contextProperties="${build.properties}"
  +      controlTemplate="${DocControlTemplate}"
  +      outputDirectory="${torque.home}/${outputDirectory}/doc"
  +      outputFormat="html"
  +      templatePath="${templatePath}"
  +      sqldbmap="${torque.home}/${outputDirectory}/sql/sqldb.map"
  +      outputFile="report.${project}.doc.generation">
  +      <fileset dir="${torque.home}/${schemaDirectory}">
  +        <include name="*-schema.xml"/>
  +      </fileset>
  +    </torque-doc>
  +  </target>
  +
  +  <!-- ================================================================ -->
     <!-- C R E A T E  T A R G E T  D A T A B A S E                        -->
     <!-- ================================================================ -->
     <!-- Create the target database by executing a generated script       -->
  
  
  
  1.1                  jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDocumentationTask.java
  
  Index: TorqueDocumentationTask.java
  ===================================================================
  package org.apache.torque.task;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Turbine" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import org.apache.velocity.context.Context;
  import org.apache.velocity.VelocityContext;
  
  /**
   * An ant task for generating output by using Velocity
   *
   * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
   * @version $Id: TorqueDocumentationTask.java,v 1.1 2001/12/18 21:47:53 mpoeschl Exp $
   */
  public class TorqueDocumentationTask extends TorqueDataModelTask
  {
  
      /**
       * The target database(s) we are generating SQL
       * for. Right now we can only deal with a single
       * target, but we will support multiple targets
       * soon.
       */
      private String targetDatabase;
  
      private String outputFormat;
  
  
      /**
       * Get the current target package.
       *
       * @return String target database(s)
       */
      public String getTargetDatabase()
      {
          return targetDatabase;
      }
  
      /**
       * Set the current target package.  This is where
       * generated java classes will live.
       *
       * @param v target database(s)
       */
      public void setTargetDatabase(String v)
      {
          targetDatabase = v;
      }
  
      /**
       * Get the current output format.
       *
       * @return the current output format
       */
      public String getOutputFormat()
      {
          return outputFormat;
      }
  
      /**
       * Set the current output format.
       *
       * @param v output format
       */
      public void setOutputFormat(String v)
      {
          outputFormat = v;
      }
  
      /**
       * Place our target package value
       * into the context for use in the templates.
       */
      public Context initControlContext()
          throws Exception
      {
          super.initControlContext();
          context.put("targetDatabase", targetDatabase);
          context.put("outputFormat", outputFormat);
          return context;
      }
  }
  
  
  
  1.1                  jakarta-turbine-torque/src/templates/doc/Control.vm
  
  Index: Control.vm
  ===================================================================
  #set ( $basepath = $generator.OutputPath)
  
  #foreach ($dataModel in $dataModels)
  
    #set ( $outFile = "${dataModel.name}.html" )
  
    File to be created: $outFile
  
    $generator.parse("doc/$outputFormat/datamodel.vm",$outFile,"dataModel",$dataModel)
  #end
  
  
  
  1.1                  jakarta-turbine-torque/src/templates/doc/html/datamodel.vm
  
  Index: datamodel.vm
  ===================================================================
  #set ( $database = $dataModel.database )
  <html>
  <header>
    <title>$dataModel.name</title>
  </header>
  
  <body>
    <table border="1">
      <tr>
        <th>Table Name</th>
        <th>OM Class</th>
        <th>Description</th>
      <tr>
    #foreach ($tbl in $database.tables)
      <tr>
        <td>$tbl.Name</td>
        <td>$tbl.JavaName</td>
        <td>$!tbl.Description</td>
      </tr>
    #end
    </table>
  
    #foreach ($tbl in $database.tables)
      $generator.parse("doc/html/table.vm",$outFile,"table",$tbl)
    #end
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-turbine-torque/src/templates/doc/html/table.vm
  
  Index: table.vm
  ===================================================================
  
  <h2>$table.Name</h2>
  
  <table border="1">
    <tr>
      <th>Name</th>
      <th>Type</th>
      <th>Size</th>
      <th>Default</th>
      <th>JavaName</th>
      <th>PK</th>
      <th>FK</th>
      <th>not null</th>
    </tr>
  #foreach ($col in $table.Columns)
    <tr>
      <td>$col.Name</td>
      <td>$col.Type</td>
      <td>$col.printSize()</td>
      <td>$col.DefaultValue</td>
      <td>$col.JavaName</td>
      <td>$col.isPrimaryKey()</td>
      <td>$col.isForeignKey()</td>
      <td>$col.isNotNull()</td>
    </tr>
  #end
  </table>
  
  
  
  1.1                  jakarta-turbine-torque/src/templates/doc/anakia/datamodel.vm
  
  Index: datamodel.vm
  ===================================================================
  #set ( $database = $dataModel.database )
  <?xml version="1.0"?>
  
  <document>
    <properties>
      <title>$dataModel.name</title>
    </properties>
  
    <body>
  
    <section name="$dataModel.name">
    <table border="1">
      <tr>
        <th>Table Name</th>
        <th>OM Class</th>
        <th>Description</th>
      <tr>
    #foreach ($tbl in $database.tables)
      <tr>
        <td>$tbl.Name</td>
        <td>$tbl.JavaName</td>
        <td>$!tbl.Description</td>
      </tr>
    #end
    </table>
  
    #foreach ($tbl in $database.tables)
      $generator.parse("doc/html/table.vm",$outFile,"table",$tbl)
    #end
  
    </section>
  </body>
  </document>
  
  
  
  1.1                  jakarta-turbine-torque/src/templates/doc/anakia/table.vm
  
  Index: table.vm
  ===================================================================
  
  <h2>$table.Name</h2>
  
  <table border="1">
    <tr>
      <th>Name</th>
      <th>Type</th>
      <th>Size</th>
      <th>Default</th>
      <th>JavaName</th>
      <th>PK</th>
      <th>FK</th>
      <th>not null</th>
    </tr>
  #foreach ($col in $table.Columns)
    <tr>
      <td>$col.Name</td>
      <td>$col.Type</td>
      <td>$col.printSize()</td>
      <td>$col.DefaultValue</td>
      <td>$col.JavaName</td>
      <td>$col.isPrimaryKey()</td>
      <td>$col.isForeignKey()</td>
      <td>$col.isNotNull()</td>
    </tr>
  #end
  </table>
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>