mpoeschl 02/04/17 11:23:27
Modified: src/java/org/apache/torque/task TorqueDataDumpTask.java
TorqueDataModelTask.java TorqueDataSQLTask.java
TorqueDocumentationTask.java
TorqueJDBCTransformTask.java TorqueSQLExec.java
TorqueSQLTask.java TorqueSQLTransformTask.java
Log:
cleanup the tasks
Revision Changes Path
1.8 +34 -37
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataDumpTask.java
Index: TorqueDataDumpTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataDumpTask.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TorqueDataDumpTask.java 11 Apr 2002 22:02:06 -0000 1.7
+++ TorqueDataDumpTask.java 17 Apr 2002 18:23:26 -0000 1.8
@@ -72,7 +72,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Fedor Karpelevitch</a>
* @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="[EMAIL PROTECTED]">Daniel Rall</a>
- * @version $Id: TorqueDataDumpTask.java,v 1.7 2002/04/11 22:02:06 mpoeschl Exp $
+ * @version $Id: TorqueDataDumpTask.java,v 1.8 2002/04/17 18:23:26 mpoeschl Exp $
*/
public class TorqueDataDumpTask extends TorqueDataModelTask
{
@@ -82,22 +82,22 @@
private String databaseName;
/**
- * Database URL used for JDBC connection.
+ * Database URL used for JDBC connection.
*/
private String databaseUrl;
/**
- * Database driver used for JDBC connection.
+ * Database driver used for JDBC connection.
*/
private String databaseDriver;
/**
- * Database user used for JDBC connection.
+ * Database user used for JDBC connection.
*/
private String databaseUser;
/**
- * Database password used for JDBC connection.
+ * Database password used for JDBC connection.
*/
private String databasePassword;
@@ -112,7 +112,7 @@
private Statement stmt;
/**
- * Get the database name to dump
+ * Get the database name to dump
*
* @return The DatabaseName value
*/
@@ -122,7 +122,7 @@
}
/**
- * Set the database name
+ * Set the database name
*
* @param v The new DatabaseName value
*/
@@ -132,7 +132,7 @@
}
/**
- * Get the database url
+ * Get the database url
*
* @return The DatabaseUrl value
*/
@@ -142,7 +142,7 @@
}
/**
- * Set the database url
+ * Set the database url
*
* @param v The new DatabaseUrl value
*/
@@ -152,7 +152,7 @@
}
/**
- * Get the database driver name
+ * Get the database driver name
*
* @return String database driver name
*/
@@ -162,7 +162,7 @@
}
/**
- * Set the database driver name
+ * Set the database driver name
*
* @param v The new DatabaseDriver value
*/
@@ -172,7 +172,7 @@
}
/**
- * Get the database user
+ * Get the database user
*
* @return String database user
*/
@@ -182,7 +182,7 @@
}
/**
- * Set the database user
+ * Set the database user
*
* @param v The new DatabaseUser value
*/
@@ -192,7 +192,7 @@
}
/**
- * Get the database password
+ * Get the database password
*
* @return String database password
*/
@@ -202,7 +202,7 @@
}
/**
- * Set the database password
+ * Set the database password
*
* @param v The new DatabasePassword value
*/
@@ -212,15 +212,15 @@
}
/**
- * Initializes initial context
+ * Initializes initial context
*
- * @return Description of the Returned Value
+ * @return the context
+ * @throws Exception
*/
- public Context initControlContext()
- throws Exception
+ public Context initControlContext() throws Exception
{
super.initControlContext();
-
+
context.put("dataset", "all");
StringBuffer buf = new StringBuffer("Database settings:\n")
@@ -256,10 +256,10 @@
}
/**
- * Closes <code>rs</code> and <code>conn</code>, overriding the
- * <code>cleanup()</code> hook method in <code>TexenTask</code>.
+ * Closes the db-connection, overriding the <code>cleanup()</code> hook
+ * method in <code>TexenTask</code>.
*
- * @exception Exception Database problem while closing resource.
+ * @throws Exception Database problem while closing resource.
*/
protected void cleanup() throws Exception
{
@@ -299,11 +299,10 @@
}
/**
- * Constructor for the TableTool object
+ * Constructor for the TableTool object
*
- * @param rs Description of Parameter
- * @exception SQLException Problem using database record set
- * cursor.
+ * @param qds Description of Parameter
+ * @throws Exception Problem using database record set cursor.
*/
protected TableTool(QueryDataSet qds) throws Exception
{
@@ -313,13 +312,11 @@
}
/**
- * Fetches an <code>Iterator</code> for the data in the named
- * table.
+ * Fetches an <code>Iterator</code> for the data in the named table.
*
* @param tableName Description of Parameter
* @return <code>Iterator</code> for the fetched data.
- * @exception SQLException Problem creating connection or
- * executing query.
+ * @throws Exception Problem creating connection or executing query.
*/
public TableTool fetch(String tableName) throws Exception
{
@@ -331,9 +328,9 @@
}
/**
- * Description of the Method
+ * check if there are more records in the QueryDataSet
*
- * @return Description of the Returned Value
+ * @return true if there are more records
*/
public boolean hasNext()
{
@@ -353,7 +350,7 @@
* load the next record from the QueryDataSet
*
* @return Description of the Returned Value
- * @exception NoSuchElementException Description of Exception
+ * @throws NoSuchElementException Description of Exception
*/
public Object next() throws NoSuchElementException
{
@@ -372,7 +369,7 @@
}
/**
- * Retruns the value for the column
+ * Returns the value for the column
*
* @param columnName name of the column
* @return value of the column or null if it doesn't exist
@@ -381,7 +378,7 @@
{
try
{
- return(this.curRec.getValue(columnName).asString());
+ return (this.curRec.getValue(columnName).asString());
}
catch (Exception se)
{
@@ -394,7 +391,7 @@
/**
* unsupported! always throws Exception
*
- * @exception UnsupportedOperationException
+ * @throws UnsupportedOperationException
*/
public void remove() throws UnsupportedOperationException
{
1.14 +44 -39
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataModelTask.java
Index: TorqueDataModelTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataModelTask.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- TorqueDataModelTask.java 17 Apr 2002 12:02:28 -0000 1.13
+++ TorqueDataModelTask.java 17 Apr 2002 18:23:26 -0000 1.14
@@ -90,7 +90,7 @@
* Fileset of XML schemas which represent our data models.
*/
protected Vector filesets = new Vector();
-
+
/**
* Data models that we collect. One from each XML schema file.
*/
@@ -109,7 +109,7 @@
* in a lot of cases they won't be.
*/
protected Hashtable dataModelDbMap;
-
+
/**
* Hashtable containing the names of all the databases
* in our collection of schemas.
@@ -118,7 +118,7 @@
//!! This is probably a crappy idea having the sql file -> db map
// here. I can't remember why I put it here at the moment ...
- // maybe I was going to map something else. It can probably
+ // maybe I was going to map something else. It can probably
// move into the SQL task.
/**
@@ -147,18 +147,18 @@
*/
private String targetPackage;
-
+
/**
* Set the sqldbmap.
*
- * @param sqldbmap th db map
+ * @param sqldbmap th db map
*/
public void setSqlDbMap(String sqldbmap)
{
//!! Make all these references files not strings.
this.sqldbmap = project.resolveFile(sqldbmap).toString();
}
-
+
/**
* Get the sqldbmap.
*
@@ -167,7 +167,7 @@
public String getSqlDbMap()
{
return sqldbmap;
- }
+ }
/**
* Return the data models that have been
@@ -178,7 +178,7 @@
public Vector getDataModels()
{
return dataModels;
- }
+ }
/**
* Return the data model to database name map.
@@ -188,7 +188,7 @@
public Hashtable getDataModelDbMap()
{
return dataModelDbMap;
- }
+ }
/**
* Get the xml schema describing the application model.
@@ -211,15 +211,17 @@
}
/**
- * Adds a set of files (nested fileset attribute).
+ * Adds a set of xml schema files (nested fileset attribute).
+ *
+ * @param set a Set of xml schema files
*/
- public void addFileset(FileSet set)
+ public void addFileset(FileSet set)
{
filesets.addElement(set);
}
/**
- * Get the current target package.
+ * Get the current target database.
*
* @return String target database(s)
*/
@@ -229,8 +231,7 @@
}
/**
- * Set the current target package. This is where
- * generated java classes will live.
+ * Set the current target database. (e.g. mysql, oracle, ..)
*
* @param v target database(s)
*/
@@ -244,7 +245,7 @@
*
* @return return target java package.
*/
- public String getTargetPackage ()
+ public String getTargetPackage()
{
return targetPackage;
}
@@ -255,61 +256,65 @@
*
* @param v target java package.
*/
- public void setTargetPackage (String v)
+ public void setTargetPackage(String v)
{
targetPackage = v;
}
-
+
/**
* The path to properties file containing db idiosyncrasies is
- * constructed by appending the "getTargetDatabase()/db.props
- * to this path.
+ * constructed by appending the "getTargetDatabase()/db.props to this path.
+ *
+ * @return basepath to db.props
*/
- public String getBasePathToDbProps()
+ public String getBasePathToDbProps()
{
return basePathToDbProps;
}
-
+
/**
* The path to properties file containing db idiosyncrasies is
* constructed by appending the "getTargetDatabase()/db.props
* to this path.
+ *
+ * @param v basepath to db.props
*/
- public void setBasePathToDbProps(String v)
+ public void setBasePathToDbProps(String v)
{
this.basePathToDbProps = v;
}
-
+
/**
- * Set up the initialial context for generating the SQL from the XML schema.
+ * Set up the initial context for generating the SQL from the XML schema.
*
- * @return Description of the Returned Value
+ * @return the context
+ * @throws Exception
*/
public Context initControlContext() throws Exception
{
XmlToAppData xmlParser;
-
+
if (xmlFile == null && filesets.isEmpty())
{
throw new BuildException("You must specify an XML schema or " +
"fileset of XML schemas!");
- }
+ }
if (xmlFile != null)
{
// Transform the XML database schema into
// data model object.
- xmlParser =
+ xmlParser =
new XmlToAppData(getTargetDatabase(), getBasePathToDbProps());
AppData ad = xmlParser.parseFile(xmlFile);
xmlParser.parseFile(xmlFile);
ad.setName(grokName(xmlFile));
dataModels.addElement(ad);
- }
- else
- {
+ }
+ else
+ {
// Deal with the filesets.
- for (int i = 0; i < filesets.size(); i++)
+ for (int i = 0; i < filesets.size(); i++)
{
FileSet fs = (FileSet) filesets.elementAt(i);
DirectoryScanner ds = fs.getDirectoryScanner(project);
@@ -321,7 +326,7 @@
for (int j = 0; j < dataModelFiles.length; j++)
{
File f = new File(srcDir, dataModelFiles[j]);
- xmlParser = new XmlToAppData(getTargetDatabase(),
+ xmlParser = new XmlToAppData(getTargetDatabase(),
getBasePathToDbProps());
AppData ad = xmlParser.parseFile(f.toString());
xmlParser.parseFile(f.toString());
@@ -330,11 +335,11 @@
}
}
}
-
+
Iterator i = dataModels.iterator();
databaseNames = new Hashtable();
- dataModelDbMap = new Hashtable();
-
+ dataModelDbMap = new Hashtable();
+
// Different datamodels may state the same database
// names, we just want the unique names of databases.
while (i.hasNext())
@@ -347,14 +352,14 @@
// Create a new Velocity context.
context = new VelocityContext();
-
+
// Place our set of data models into the context along
- // with the names of the databases as a convenience for now.
+ // with the names of the databases as a convenience for now.
context.put("dataModels", dataModels);
context.put("databaseNames", databaseNames);
context.put("targetDatabase", targetDatabase);
context.put("targetPackage", targetPackage);
-
+
return context;
}
1.9 +4 -4
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataSQLTask.java
Index: TorqueDataSQLTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDataSQLTask.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- TorqueDataSQLTask.java 11 Apr 2002 22:02:06 -0000 1.8
+++ TorqueDataSQLTask.java 17 Apr 2002 18:23:26 -0000 1.9
@@ -69,7 +69,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]"> Jason van Zyl </a>
* @author <a href="mailto:[EMAIL PROTECTED]"> John McNally </a>
* @author <a href="mailto:[EMAIL PROTECTED]"> Fedor Karpelevitch </a>
- * @version $Id: TorqueDataSQLTask.java,v 1.8 2002/04/11 22:02:06 mpoeschl Exp $
+ * @version $Id: TorqueDataSQLTask.java,v 1.9 2002/04/17 18:23:26 mpoeschl Exp $
*/
public class TorqueDataSQLTask extends TorqueDataModelTask
{
@@ -146,10 +146,10 @@
/**
* Set up the initialial context for generating the SQL from the XML schema.
*
- * @return Description of the Returned Value
+ * @return the context
+ * @throws Exception
*/
- public Context initControlContext()
- throws Exception
+ public Context initControlContext() throws Exception
{
super.initControlContext();
1.4 +4 -1
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDocumentationTask.java
Index: TorqueDocumentationTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueDocumentationTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TorqueDocumentationTask.java 16 Apr 2002 08:07:07 -0000 1.3
+++ TorqueDocumentationTask.java 17 Apr 2002 18:23:26 -0000 1.4
@@ -60,7 +60,7 @@
* An ant task for generating output by using Velocity
*
* @author <a href="mailto:[EMAIL PROTECTED]">Martin Poeschl</a>
- * @version $Id: TorqueDocumentationTask.java,v 1.3 2002/04/16 08:07:07 mpoeschl
Exp $
+ * @version $Id: TorqueDocumentationTask.java,v 1.4 2002/04/17 18:23:26 mpoeschl
Exp $
*/
public class TorqueDocumentationTask extends TorqueDataModelTask
{
@@ -89,6 +89,9 @@
/**
* Place our target package value into the context for use in the templates.
+ *
+ * @return the context
+ * @throws Exception
*/
public Context initControlContext() throws Exception
{
1.8 +17 -13
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueJDBCTransformTask.java
Index: TorqueJDBCTransformTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueJDBCTransformTask.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- TorqueJDBCTransformTask.java 11 Apr 2002 22:02:06 -0000 1.7
+++ TorqueJDBCTransformTask.java 17 Apr 2002 18:23:26 -0000 1.8
@@ -84,7 +84,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Fedor Karpelevitch</a>
- * @version $Id: TorqueJDBCTransformTask.java,v 1.7 2002/04/11 22:02:06 mpoeschl
Exp $
+ * @version $Id: TorqueJDBCTransformTask.java,v 1.8 2002/04/17 18:23:26 mpoeschl
Exp $
*/
public class TorqueJDBCTransformTask extends Task
{
@@ -168,6 +168,8 @@
/**
* Default constructor.
+ *
+ * @throws BuildException
*/
public void execute() throws BuildException
{
@@ -179,7 +181,7 @@
System.err.println("password : " + dbPassword);
System.err.println("schema : " + dbSchema);
- DocumentTypeImpl docType= new DocumentTypeImpl(null, "app-data", null,
+ DocumentTypeImpl docType = new DocumentTypeImpl(null, "app-data", null,
"http://jakarta.apache.org/turbine/dtd/database.dtd");
doc = new DocumentImpl(docType);
doc.appendChild(doc.createComment(" Autogenerated by JDBCToXMLSchema! "));
@@ -205,7 +207,7 @@
/**
* Generates an XML database schema from JDBC metadata.
*
- * @exception Exception, a generic exception.
+ * @throws Exception a generic exception.
*/
public void generateXML() throws Exception
{
@@ -325,7 +327,7 @@
column.setAttribute("primaryKey", "true");
}
- if (defValue!=null)
+ if (defValue != null)
{
// trim out parens & quotes out of def value.
// makes sense for MSSQL. not sure about others.
@@ -347,10 +349,10 @@
}
// Foreign keys for this table.
- for (Iterator l = forgnKeys.iterator(); l.hasNext();)
+ for (Iterator l = forgnKeys.iterator(); l.hasNext(); )
{
Object[] forKey = (Object[]) l.next();
- String foreignKeyTable = (String)forKey[0];
+ String foreignKeyTable = (String) forKey[0];
List refs = (List) forKey[1];
Element fk = doc.createElement("foreign-key");
fk.setAttribute("foreignTable", foreignKeyTable);
@@ -377,7 +379,7 @@
*
* @param dbMeta JDBC database metadata.
* @return The list of all the tables in a database.
- * @exception SQLException
+ * @throws SQLException
*/
public List getTableNames(DatabaseMetaData dbMeta)
throws SQLException
@@ -418,12 +420,12 @@
* element 3 => null type.
*
* @param dbMeta JDBC metadata.
- * @param tableName Table from which to retrieve column
- * information.
+ * @param tableName Table from which to retrieve column information.
* @return The list of columns in <code>tableName</code>.
+ * @throws SQLException
*/
public List getColumns(DatabaseMetaData dbMeta, String tableName)
- throws SQLException
+ throws SQLException
{
List columns = new Vector();
ResultSet columnSet = null;
@@ -464,9 +466,10 @@
* @param dbMeta JDBC metadata.
* @param tableName Table from which to retrieve PK information.
* @return A list of the primary key parts for <code>tableName</code>.
+ * @throws SQLException
*/
public List getPrimaryKeys(DatabaseMetaData dbMeta, String tableName)
- throws SQLException
+ throws SQLException
{
List pk = new Vector();
ResultSet parts = null;
@@ -494,6 +497,7 @@
* @param dbMeta JDBC metadata.
* @param tableName Table from which to retrieve FK information.
* @return A list of foreign keys in <code>tableName</code>.
+ * @throws SQLException
*/
public Collection getForeignKeys(DatabaseMetaData dbMeta, String tableName)
throws SQLException
@@ -511,7 +515,7 @@
{
fkName = foreignKeys.getString(3);
}
- Object[] fk = (Object[])fks.get(fkName);
+ Object[] fk = (Object[]) fks.get(fkName);
List refs;
if (fk == null)
{
@@ -523,7 +527,7 @@
}
else
{
- refs = (Vector)fk[1];
+ refs = (Vector) fk[1];
}
String[] ref = new String[2];
ref[0] = foreignKeys.getString(8); //local column
1.7 +41 -24
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLExec.java
Index: TorqueSQLExec.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLExec.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TorqueSQLExec.java 11 Apr 2002 22:02:07 -0000 1.6
+++ TorqueSQLExec.java 17 Apr 2002 18:23:26 -0000 1.7
@@ -1,6 +1,6 @@
package org.apache.torque.task;
-/*
+/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
@@ -99,7 +99,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Tim Stephenson</A>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</A>
* @author <a href="mailto:[EMAIL PROTECTED]">Martin Poeschl</a>
- * @version $Id: TorqueSQLExec.java,v 1.6 2002/04/11 22:02:07 mpoeschl Exp $
+ * @version $Id: TorqueSQLExec.java,v 1.7 2002/04/17 18:23:26 mpoeschl Exp $
*/
public class TorqueSQLExec extends Task
{
@@ -109,7 +109,7 @@
private AntClassLoader loader;
/**
- *
+ *
*/
static public class DelimiterType extends EnumeratedAttribute
{
@@ -226,6 +226,8 @@
/**
* Set the sqldbmap properties file.
+ *
+ * @param sqldbmap filename for the sqldbmap
*/
public void setSqlDbMap(String sqldbmap)
{
@@ -234,6 +236,8 @@
/**
* Get the sqldbmap properties file.
+ *
+ * @return filename for the sqldbmap
*/
public File getSqlDbMap()
{
@@ -241,8 +245,9 @@
}
/**
- * Set the src directory for the sql files
- * listed in the sqldbmap file.
+ * Set the src directory for the sql files listed in the sqldbmap file.
+ *
+ * @param srcDir sql source directory
*/
public void setSrcDir(String srcDir)
{
@@ -250,8 +255,9 @@
}
/**
- * Get the src directory for the sql files
- * listed in the sqldbmap file.
+ * Get the src directory for the sql files listed in the sqldbmap file.
+ *
+ * @return sql source directory
*/
public String getSrcDir()
{
@@ -260,6 +266,8 @@
/**
* Set the classpath for loading the driver.
+ *
+ * @param classpath
*/
public void setClasspath(Path classpath)
{
@@ -275,6 +283,8 @@
/**
* Create the classpath for loading the driver.
+ *
+ * @return the classpath
*/
public Path createClasspath()
{
@@ -287,6 +297,8 @@
/**
* Set the classpath for loading the driver using the classpath reference.
+ *
+ * @param r reference to the classpath
*/
public void setClasspathRef(Reference r)
{
@@ -295,6 +307,8 @@
/**
* Set the sql command to execute
+ *
+ * @param sql sql command to execute
*/
public void addText(String sql)
{
@@ -467,7 +481,7 @@
Hashtable h = new Hashtable();
TreeSet keys = new TreeSet(p.keySet());
- for (Iterator e = keys.iterator(); e.hasNext();)
+ for (Iterator e = keys.iterator(); e.hasNext(); )
{
String sqlfile = (String) e.next();
String database = p.getProperty(sqlfile);
@@ -504,7 +518,7 @@
{
String s = (String) j.next();
Transaction t = new Transaction();
- t.setSrc(new File(srcDir,s));
+ t.setSrc(new File(srcDir, s));
ts.addElement(t);
}
@@ -527,7 +541,7 @@
Class dc;
if (classpath != null)
{
- log( "Loading " + driver + " using AntClassLoader with classpath "
+ classpath,
+ log("Loading " + driver + " using AntClassLoader with classpath " +
classpath,
Project.MSG_VERBOSE );
loader = new AntClassLoader(project, classpath);
@@ -570,7 +584,7 @@
throw new SQLException("No suitable Driver for " + url);
}
- if (!isValidRdbms(conn))
+ if (!isValidRdbms(conn))
{
return;
}
@@ -582,14 +596,14 @@
{
if (output != null)
{
- log("Opening PrintStream to output file " + output,
+ log("Opening PrintStream to output file " + output,
Project.MSG_VERBOSE);
out = new PrintStream(new BufferedOutputStream(
new FileOutputStream(output)));
}
// Process all transactions
- for (Enumeration e = transactions.elements();
+ for (Enumeration e = transactions.elements();
e.hasMoreElements();)
{
((Transaction) e.nextElement()).runTransaction(out);
@@ -659,7 +673,7 @@
}
/**
- *
+ *
* @param reader
* @param out
* @throws SQLException
@@ -683,7 +697,7 @@
if (line.startsWith("//")) continue;
if (line.startsWith("--")) continue;
if (line.length() > 2 &&
- line.substring(0,3).equalsIgnoreCase("REM")) continue;
+ line.substring(0, 3).equalsIgnoreCase("REM")) continue;
sql += " " + line;
sql = sql.trim();
@@ -691,12 +705,15 @@
// SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it
- if (line.indexOf("--") >= 0) sql += "\n";
+ if (line.indexOf("--") >= 0)
+ {
+ sql += "\n";
+ }
- if (delimiterType.equals(DelimiterType.NORMAL)
- && sql.endsWith(delimiter)
- || delimiterType.equals(DelimiterType.ROW)
- && line.equals(delimiter))
+ if (delimiterType.equals(DelimiterType.NORMAL)
+ && sql.endsWith(delimiter)
+ || delimiterType.equals(DelimiterType.ROW)
+ && line.equals(delimiter))
{
log("SQL: " + sql, Project.MSG_VERBOSE);
execSQL(sql.substring(0, sql.length() - delimiter.length()),
@@ -738,7 +755,7 @@
log("RDBMS = " + theVendor, Project.MSG_VERBOSE);
if (theVendor == null || theVendor.indexOf(rdbms) < 0)
{
- log("Not the required RDBMS: "
+ log("Not the required RDBMS: "
+ rdbms, Project.MSG_VERBOSE);
return false;
}
@@ -750,10 +767,10 @@
.toLowerCase();
log("Version = " + theVersion, Project.MSG_VERBOSE);
- if (theVersion == null || !(theVersion.startsWith(version)
+ if (theVersion == null || !(theVersion.startsWith(version)
|| theVersion.indexOf(" " + version) >= 0))
{
- log("Not the required version: \"" + version + "\"",
+ log("Not the required version: \"" + version + "\"",
Project.MSG_VERBOSE);
return false;
}
@@ -916,7 +933,7 @@
log("Executing file: " + tSrcFile.getAbsolutePath(),
Project.MSG_INFO);
Reader reader = (encoding == null) ? new FileReader(tSrcFile)
- : new InputStreamReader(new FileInputStream(tSrcFile),
+ : new InputStreamReader(new FileInputStream(tSrcFile),
encoding);
runStatements(reader, out);
reader.close();
1.12 +44 -39
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLTask.java
Index: TorqueSQLTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLTask.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- TorqueSQLTask.java 10 Apr 2002 21:08:43 -0000 1.11
+++ TorqueSQLTask.java 17 Apr 2002 18:23:26 -0000 1.12
@@ -25,13 +25,13 @@
* 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
+ * 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 [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "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
@@ -60,7 +60,6 @@
import java.util.Properties;
import java.util.Iterator;
import org.apache.velocity.context.Context;
-import org.apache.velocity.VelocityContext;
import org.apache.torque.engine.database.transform.XmlToAppData;
import org.apache.torque.engine.database.model.AppData;
@@ -71,10 +70,9 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
* @author <a href="mailto:[EMAIL PROTECTED]>John McNally</a>
- * @version $Id: TorqueSQLTask.java,v 1.11 2002/04/10 21:08:43 dlr Exp $
+ * @version $Id: TorqueSQLTask.java,v 1.12 2002/04/17 18:23:26 mpoeschl Exp $
*/
-public class TorqueSQLTask
- extends TorqueDataModelTask
+public class TorqueSQLTask extends TorqueDataModelTask
{
// if the database is set than all generated sql files
// will be placed in the specified database, the database
@@ -82,33 +80,34 @@
private String database;
private String suffix = "";
-
+
private String idTableXMLFile = null;
-
+
public void setDatabase(String database)
{
this.database = database;
}
-
+
public String getDatabase()
{
return database;
- }
+ }
public void setSuffix(String suffix)
{
this.suffix = suffix;
}
-
+
public String getSuffix()
{
return suffix;
- }
+ }
/**
* Set the path to the xml schema file that defines the id-table, used
* by the idbroker method.
- * @param xml path to file.
+ *
+ * @param idXmlFile xml schema file
*/
public void setIdTableXMLFile(String idXmlFile)
{
@@ -117,56 +116,62 @@
/**
* Gets the id-table xml schema file path.
+ *
* @return Path to file.
*/
public String getIdTableXMLFile()
{
return idTableXMLFile;
}
-
- private void createSqlDbMap()
- throws Exception
+
+ /**
+ * create the sql -> database map.
+ *
+ * @throws Exception
+ */
+ private void createSqlDbMap() throws Exception
{
if (getSqlDbMap() == null)
{
return;
- }
-
+ }
+
// Produce the sql -> database map
Properties sqldbmap = new Properties();
-
+
// Check to see if the sqldbmap has already been created.
File file = new File(getSqlDbMap());
-
+
if (file.exists())
{
FileInputStream fis = new FileInputStream(file);
sqldbmap.load(fis);
fis.close();
}
-
+
Iterator i = getDataModelDbMap().keySet().iterator();
-
+
while (i.hasNext())
{
String dataModelName = (String) i.next();
String sqlFile = dataModelName + suffix + ".sql";
-
+
String databaseName;
-
+
if (getDatabase() == null)
{
databaseName = (String) getDataModelDbMap().get(dataModelName);
}
else
- {
+ {
databaseName = getDatabase();
}
-
- sqldbmap.setProperty(sqlFile,databaseName);
+
+ sqldbmap.setProperty(sqlFile, databaseName);
}
-
- sqldbmap.store(new FileOutputStream(getSqlDbMap()),"Sqlfile -> Database
map");
+
+ sqldbmap.store(new FileOutputStream(getSqlDbMap()),
+ "Sqlfile -> Database map");
}
/**
@@ -179,7 +184,7 @@
{
// Transform the XML database schema into
// data model object.
- XmlToAppData xmlParser = new XmlToAppData(getTargetDatabase(),
+ XmlToAppData xmlParser = new XmlToAppData(getTargetDatabase(),
getBasePathToDbProps());
AppData ad = xmlParser.parseFile(getIdTableXMLFile());
xmlParser.parseFile(getIdTableXMLFile());
@@ -189,14 +194,14 @@
/**
* Place our target database and target platform
- * values into the context for use in the
- * templates.
+ * values into the context for use in the templates.
+ *
+ * @return the context
+ * @throws Exception
*/
- public Context initControlContext()
- throws Exception
- {
+ public Context initControlContext() throws Exception
+ {
super.initControlContext();
- context.put("targetDatabase", getTargetDatabase());
createSqlDbMap();
// If the load path for the id broker table xml schema is
@@ -206,7 +211,7 @@
{
loadIdBrokerModel();
}
-
+
return context;
}
}
1.4 +2 -5
jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLTransformTask.java
Index: TorqueSQLTransformTask.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/task/TorqueSQLTransformTask.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TorqueSQLTransformTask.java 27 Oct 2001 19:04:38 -0000 1.3
+++ TorqueSQLTransformTask.java 17 Apr 2002 18:23:26 -0000 1.4
@@ -56,8 +56,6 @@
import java.io.BufferedWriter;
import java.io.FileWriter;
-import java.io.PrintStream;
-import java.io.Writer;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.torque.engine.database.model.AppData;
@@ -68,10 +66,9 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Leon Messerschmidt</a>
* @author <a href="[EMAIL PROTECTED]">Jason van Zyl</a>
- * @version $Id: TorqueSQLTransformTask.java,v 1.3 2001/10/27 19:04:38 jvanzyl Exp $
+ * @version $Id: TorqueSQLTransformTask.java,v 1.4 2002/04/17 18:23:26 mpoeschl Exp
$
*/
-public class TorqueSQLTransformTask
- extends Task
+public class TorqueSQLTransformTask extends Task
{
/**
* SQL input file.
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>