org.apache.torque.task
Class TorqueDataModelTask

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

public class TorqueDataModelTask
extends 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  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.
private  String targetDatabase
          The target database(s) we are generating SQL for.
private  String targetPackage
          Target Java package to place the generated files in.
protected  String xmlFile
          XML that describes the database model, this is transformed into the application model object.
 
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.
private  String grokName(String xmlFile)
          Gets a name to use for the application's data model.
 Context initControlContext()
          Set up the initial context for generating SQL
protected  void populateInitialContext(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 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 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.


targetDatabase

private String targetDatabase
The target database(s) we are generating SQL for.


targetPackage

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

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 Context initControlContext()
                           throws Exception
Set up the initial context for generating SQL

Returns:
the context
Throws:
Exception

populateInitialContext

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

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

grokName

private String grokName(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(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

getFilesets

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

setFilesets

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


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