You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2001/08/16 19:32:32 UTC
cvs commit: jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform XmlToAppData.java
dlr 01/08/16 10:32:32
Modified: src/java/org/apache/torque/engine/database/transform
XmlToAppData.java
Log:
* Added DEFAULT_DB_NAME and DEBUG constants.
* Formatting changes and FIXME note.
* Added endElement() callback to trigger heavy indexing when a table
is done being parsed.
Revision Changes Path
1.2 +48 -10 jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java
Index: XmlToAppData.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- XmlToAppData.java 2001/08/02 05:08:33 1.1
+++ XmlToAppData.java 2001/08/16 17:32:32 1.2
@@ -89,10 +89,18 @@
* @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
* @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
* @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
- * @version $Id: XmlToAppData.java,v 1.1 2001/08/02 05:08:33 jvanzyl Exp $
+ * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
+ * @version $Id: XmlToAppData.java,v 1.2 2001/08/16 17:32:32 dlr Exp $
*/
public class XmlToAppData extends DefaultHandler
{
+ private static final boolean DEBUG = false;
+
+ /**
+ * The name for the default database.
+ */
+ private static final String DEFAULT_DB_NAME = "default";
+
private AppData app;
private Database currDB;
private Table currTable;
@@ -152,7 +160,8 @@
}
catch (FileNotFoundException fnfe)
{
- throw new FileNotFoundException(new File(xmlFile).getAbsolutePath());
+ throw new FileNotFoundException
+ (new File(xmlFile).getAbsolutePath());
}
BufferedReader br = new BufferedReader (fr);
try
@@ -180,8 +189,6 @@
return app;
}
-
-
/**
* Handles opening elements of the xml file.
*/
@@ -190,18 +197,18 @@
{
try
{
- if(!firstPass)
+ if (!firstPass)
{
if (rawName.equals("database"))
{
String s = attributes.getValue("name");
- if ( s == null )
+ if (s == null)
{
//s = TurbineDB.getDefaultDB();
// !!Hard coding this for now it should
// be a property.
- s = "default";
+ s = DEFAULT_DB_NAME;
}
currDB = app.getDatabase(s);
}
@@ -212,14 +219,16 @@
// check schema integrity
// if idMethod="autoincrement", make sure a column is
// specified as autoIncrement="true"
+ // FIXME: Handle idMethod="native" via DB adapter.
if ( currTable.getIdMethod().equals("autoincrement") )
{
Column[] columns = currTable.getColumns();
boolean foundOne = false;
- for ( int i=0; i<columns.length && !foundOne; i++ )
+ for (int i = 0; i < columns.length && !foundOne; i++)
{
foundOne = columns[i].isAutoIncrement();
}
+
if ( !foundOne )
{
errorMessage += "Table '" + currTable.getName() +
@@ -227,7 +236,6 @@
"have a column which declared as the one to " +
"auto increment (i.e. autoIncrement=\"true\")\n";
}
-
}
}
else if (rawName.equals("foreign-key"))
@@ -333,7 +341,37 @@
}
}
}
- catch(Exception e)
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Handles closing elements of the xml file.
+ */
+ public void endElement(String uri, String localName, String rawName)
+ {
+ if (DEBUG)
+ {
+ System.out.println("endElement(" + uri + ", " + localName + ", " +
+ rawName + ") called");
+ }
+
+ try
+ {
+ if (firstPass)
+ {
+ if ("table".equals(rawName) && currTable != null)
+ {
+ // Heavy indexing must wait until after all columns
+ // composing a table's primary key have been parsed.
+ // TODO: Make this conditional.
+ currTable.doHeavyIndexing();
+ }
+ }
+ }
+ catch (Exception e)
{
e.printStackTrace();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org