org.apache.torque.task
Class TorqueDataModelTask

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended byorg.apache.velocity.texen.ant.TexenTask
              extended byorg.apache.torque.task.TorqueDataModelTask
Direct Known Subclasses:
TorqueDataDumpTask, TorqueDataSQLTask, TorqueDocumentationTask, TorqueSQLTask

public class TorqueDataModelTask
extends org.apache.velocity.texen.ant.TexenTask

A base torque task that uses either a single XML schema representing a data model, or a <fileset> of XML schemas. We are making the assumption that an XML schema representing a data model contains tables for a single database.

Author:
Jason van Zyl, Daniel Rall

Field Summary
private  java.lang.String basePathToDbProps
          The path to properties file containing db idiosyncrasies is constructed by appending the "getTargetDatabase()/db.props to this path.
protected  org.apache.velocity.context.Context context
          Velocity context which exposes our objects in the templates.
protected  java.util.Hashtable databaseNames
          Hashtable containing the names of all the databases in our collection of schemas.
protected  java.util.Hashtable dataModelDbMap
          Map of data model name to database name.
protected  java.util.List dataModels
          Data models that we collect.
protected  java.util.List filesets
          Fileset of XML schemas which represent our data models.
protected  java.lang.String sqldbmap
          Name of the properties file that maps an SQL file to a particular database.
private  java.lang.String targetDatabase
          The target database(s) we are generating SQL for.
private  java.lang.String targetPackage
          Target Java package to place the generated files in.
protected  java.lang.String xmlFile
          XML that describes the database model, this is transformed into the application model object.
 
Fields inherited from class org.apache.velocity.texen.ant.TexenTask
contextProperties, controlTemplate, inputEncoding, outputDirectory, outputEncoding, outputFile, templatePath, useClasspath
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
TorqueDataModelTask()
           
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet set)
          Adds a set of xml schema files (nested fileset attribute).
 java.lang.String getBasePathToDbProps()
          The path to properties file containing db idiosyncrasies is constructed by appending the "getTargetDatabase()/db.props to this path.
 java.util.Hashtable getDataModelDbMap()
          Return the data model to database name map.
 java.util.List getDataModels()
          Return the data models that have been processed.
 java.lang.String getSqlDbMap()
          Get the sqldbmap.
 java.lang.String getTargetDatabase()
          Get the current target database.
 java.lang.String getTargetPackage()
          Get the current target package.
 java.lang.String getXmlFile()
          Get the xml schema describing the application model.
private  java.lang.String grokName(java.lang.String xmlFile)
          Gets a name to use for the application's data model.
 org.apache.velocity.context.Context initControlContext()
          Set up the initial context for generating the SQL from the XML schema.
 void setBasePathToDbProps(java.lang.String v)
          The path to properties file containing db idiosyncrasies is constructed by appending the "getTargetDatabase()/db.props to this path.
 void setContextProperties(java.lang.String file)
          Override Texen's context properties to map the torque.xxx properties (including defaults set by the org/apache/torque/defaults.properties) to just xxx.
 void setSqlDbMap(java.lang.String sqldbmap)
          Set the sqldbmap.
 void setTargetDatabase(java.lang.String v)
          Set the current target database.
 void setTargetPackage(java.lang.String v)
          Set the current target package.
 void setXmlFile(java.lang.String xmlFile)
          Set the xml schema describing the application model.
 
Methods inherited from class org.apache.velocity.texen.ant.TexenTask
cleanup, execute, getContextProperties, getControlTemplate, getOutputDirectory, getOutputFile, getTemplatePath, populateInitialContext, setControlTemplate, setInputEncoding, setOutputDirectory, setOutputEncoding, setOutputFile, setTemplatePath, setUseClasspath
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlFile

protected java.lang.String xmlFile
XML that describes the database model, this is transformed into the application model object.


filesets

protected java.util.List filesets
Fileset of XML schemas which represent our data models.


dataModels

protected java.util.List dataModels
Data models that we collect. One from each XML schema file.


context

protected org.apache.velocity.context.Context context
Velocity context which exposes our objects in the templates.


dataModelDbMap

protected java.util.Hashtable dataModelDbMap
Map of data model name to database name. Should probably stick to the convention of them being the same but I know right now in a lot of cases they won't be.


databaseNames

protected java.util.Hashtable databaseNames
Hashtable containing the names of all the databases in our collection of schemas.


sqldbmap

protected java.lang.String sqldbmap
Name of the properties file that maps an SQL file to a particular database.


basePathToDbProps

private java.lang.String basePathToDbProps
The path to properties file containing db idiosyncrasies is constructed by appending the "getTargetDatabase()/db.props to this path.


targetDatabase

private java.lang.String targetDatabase
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.


targetPackage

private java.lang.String targetPackage
Target Java package to place the generated files in.

Constructor Detail

TorqueDataModelTask

public TorqueDataModelTask()
Method Detail

setSqlDbMap

public void setSqlDbMap(java.lang.String sqldbmap)
Set the sqldbmap.

Parameters:
sqldbmap - th db map

getSqlDbMap

public java.lang.String getSqlDbMap()
Get the sqldbmap.

Returns:
String sqldbmap.

getDataModels

public java.util.List getDataModels()
Return the data models that have been processed.

Returns:
List data models

getDataModelDbMap

public java.util.Hashtable getDataModelDbMap()
Return the data model to database name map.

Returns:
Hashtable data model name to database name map.

getXmlFile

public java.lang.String getXmlFile()
Get the xml schema describing the application model.

Returns:
String xml schema file.

setXmlFile

public void setXmlFile(java.lang.String xmlFile)
Set the xml schema describing the application model.

Parameters:
xmlFile - The new XmlFile value

addFileset

public void addFileset(org.apache.tools.ant.types.FileSet set)
Adds a set of xml schema files (nested fileset attribute).

Parameters:
set - a Set of xml schema files

getTargetDatabase

public java.lang.String getTargetDatabase()
Get the current target database.

Returns:
String target database(s)

setTargetDatabase

public void setTargetDatabase(java.lang.String v)
Set the current target database. (e.g. mysql, oracle, ..)

Parameters:
v - target database(s)

getTargetPackage

public java.lang.String getTargetPackage()
Get the current target package.

Returns:
return target java package.

setTargetPackage

public void setTargetPackage(java.lang.String v)
Set the current target package. This is where generated java classes will live.

Parameters:
v - target java package.

getBasePathToDbProps

public java.lang.String getBasePathToDbProps()
The path to properties file containing db idiosyncrasies is constructed by appending the "getTargetDatabase()/db.props to this path.

Returns:
basepath to db.props

setBasePathToDbProps

public void setBasePathToDbProps(java.lang.String v)
The path to properties file containing db idiosyncrasies is constructed by appending the "getTargetDatabase()/db.props to this path.

Parameters:
v - basepath to db.props

initControlContext

public org.apache.velocity.context.Context initControlContext()
                                                       throws java.lang.Exception
Set up the initial context for generating the SQL from the XML schema.

Returns:
the context
Throws:
java.lang.Exception

grokName

private java.lang.String grokName(java.lang.String xmlFile)
Gets a name to use for the application's data model.

Parameters:
xmlFile - The path to the XML file housing the data model.
Returns:
The name to use for the AppData.

setContextProperties

public void setContextProperties(java.lang.String file)
Override Texen's context properties to map the torque.xxx properties (including defaults set by the org/apache/torque/defaults.properties) to just xxx.

Also, move xxx.yyy properties to xxxYyy as Velocity doesn't like the xxx.yyy syntax.

Parameters:
file - the file to read the properties from


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.