org.apache.torque.task
Class TorqueDataModelTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.texen.ant.TexenTask
              extended by org.apache.torque.task.TorqueDataModelTask
Direct Known Subclasses:
KualiTorqueDataSQLTask, KualiTorqueSQLTask, TorqueDocumentationTask

public class TorqueDataModelTask
extends org.apache.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
protected  org.apache.velocity.context.Context context
          Velocity context which exposes our objects in the templates.
protected  Hashtable<String,String> databaseNames
          Hashtable containing the names of all the databases in our collection of schemas.
protected  Hashtable<String,String> dataModelDbMap
          Map of data model name to database name.
protected  List<Database> dataModels
          Data models that we collect.
protected  List<org.apache.tools.ant.types.FileSet> filesets
          Fileset of XML schemas which represent our data models.
protected  String sqldbmap
          Name of the properties file that maps an SQL file to a particular database.
protected  String xmlFile
          XML that describes the database model, this is transformed into the application model object.
 
Fields inherited from class org.apache.texen.ant.TexenTask
contextProperties, controlTemplate, inputEncoding, logFile, outputDirectory, outputEncoding, outputFile, resourceLoaderModificationCheckInterval, templatePath, useClasspath, useResourceLoaderCache
 
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).
protected  DatabaseParser getDatabaseParser()
          Return a SAX parser that implements the DatabaseParser interface
protected  Database getDataModel(File file)
          Parse a schema XML File into a Database object
 Hashtable<String,String> getDataModelDbMap()
          Return the data model to database name map.
protected  List<File> getDataModelFiles()
          Get the list of schema XML files from our filesets
 List<Database> getDataModels()
          Return the data models that have been processed.
 List<org.apache.tools.ant.types.FileSet> getFilesets()
           
protected  List<Database> getPopulatedDataModels()
          Parse schema XML files into Database objects
 String getSqlDbMap()
          Get the sqldbmap.
 String getTargetDatabase()
          Get the current target database.
 String getTargetPackage()
          Get the current target package.
 String getXmlFile()
          Get the xml schema describing the application model.
 org.apache.velocity.context.Context initControlContext()
          Set up the initial context for generating SQL
protected  void populateInitialContext(org.apache.velocity.context.Context context)
          Change type of "now" to java.util.Date
 void setContextProperties(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 setFilesets(List<org.apache.tools.ant.types.FileSet> filesets)
           
 void setSqlDbMap(String sqldbmap)
          Set the sqldbmap.
 void setTargetDatabase(String targetDatabase)
          Set the current target database.
 void setTargetPackage(String targetPackage)
          Set the current target package.
 void setXmlFile(String xmlFile)
          Set the xml schema describing the application model.
 
Methods inherited from class org.apache.texen.ant.TexenTask
cleanup, execute, getContextProperties, getControlTemplate, getLogFile, getOutputDirectory, getOutputFile, getTemplatePath, setControlTemplate, setInputEncoding, setLogFile, setOutputDirectory, setOutputEncoding, setOutputFile, setResourceLoaderModificationCheckInterval, setTemplatePath, setUseClasspath, setUseResourceLoaderCache
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
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 String xmlFile
XML that describes the database model, this is transformed into the application model object.


filesets

protected List<org.apache.tools.ant.types.FileSet> filesets
Fileset of XML schemas which represent our data models.


dataModels

protected List<Database> 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 Hashtable<String,String> 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 Hashtable<String,String> databaseNames
Hashtable containing the names of all the databases in our collection of schemas.


sqldbmap

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

Constructor Detail

TorqueDataModelTask

public TorqueDataModelTask()
Method Detail

setSqlDbMap

public void setSqlDbMap(String sqldbmap)
Set the sqldbmap.

Parameters:
sqldbmap - th db map

getSqlDbMap

public String getSqlDbMap()
Get the sqldbmap.

Returns:
String sqldbmap.

getDataModels

public List<Database> getDataModels()
Return the data models that have been processed.

Returns:
List data models

getDataModelDbMap

public Hashtable<String,String> getDataModelDbMap()
Return the data model to database name map.

Returns:
Hashtable data model name to database name map.

getXmlFile

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

Returns:
String xml schema file.

setXmlFile

public void setXmlFile(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 String getTargetDatabase()
Get the current target database.

Returns:
String target database(s)

setTargetDatabase

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


getTargetPackage

public String getTargetPackage()
Get the current target package.

Returns:
return target java package.

setTargetPackage

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


getDatabaseParser

protected DatabaseParser getDatabaseParser()
Return a SAX parser that implements the DatabaseParser interface


getDataModel

protected Database getDataModel(File file)
                         throws EngineException
Parse a schema XML File into a Database object

Throws:
EngineException

getDataModelFiles

protected List<File> getDataModelFiles()
Get the list of schema XML files from our filesets


getPopulatedDataModels

protected List<Database> getPopulatedDataModels()
                                         throws EngineException
Parse schema XML files into Database objects

Throws:
EngineException

initControlContext

public org.apache.velocity.context.Context initControlContext()
                                                       throws Exception
Set up the initial context for generating SQL

Overrides:
initControlContext in class org.apache.texen.ant.TexenTask
Returns:
the context
Throws:
Exception

populateInitialContext

protected void populateInitialContext(org.apache.velocity.context.Context context)
                               throws Exception
Change type of "now" to java.util.Date

Overrides:
populateInitialContext in class org.apache.texen.ant.TexenTask
Throws:
Exception
See Also:
org.apache.velocity.texen.ant.TexenTask#populateInitialContext(org.apache.velocity.context.Context)

setContextProperties

public void setContextProperties(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.

Overrides:
setContextProperties in class org.apache.texen.ant.TexenTask
Parameters:
file - the file to read the properties from

getFilesets

public List<org.apache.tools.ant.types.FileSet> getFilesets()

setFilesets

public void setFilesets(List<org.apache.tools.ant.types.FileSet> filesets)


Copyright © 2004-2013 The Kuali Foundation. All Rights Reserved.