You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2001/03/31 02:43:13 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/transform XmlToAppData.java
jmcnally 01/03/30 16:43:13
Modified: src/java/org/apache/turbine/torque/engine/database/transform
XmlToAppData.java
Log:
reformat: indentation, braces, break long lines.
Revision Changes Path
1.5 +104 -95 jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/transform/XmlToAppData.java
Index: XmlToAppData.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database/transform/XmlToAppData.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XmlToAppData.java 2001/03/31 00:36:42 1.4
+++ XmlToAppData.java 2001/03/31 00:43:12 1.5
@@ -76,7 +76,7 @@
* @author <a href="mailto:leon@opticode.co.za">Leon Messerschmidt</a>
* @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
* @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
- * @version $Id: XmlToAppData.java,v 1.4 2001/03/31 00:36:42 jmcnally Exp $
+ * @version $Id: XmlToAppData.java,v 1.5 2001/03/31 00:43:12 jmcnally Exp $
*/
public class XmlToAppData extends DefaultHandler
{
@@ -167,112 +167,121 @@
public void startElement(String uri, String localName, String rawName,
Attributes attributes)
{
-try
-{
- if(!firstPass)
- {
- if (rawName.equals("database"))
- {
- String s = attributes.getValue("name");
- if ( s == null )
- {
- s = TurbineDB.getDefaultDB();
- }
- currDB = app.getDatabase(s);
- }
- if (rawName.equals("table"))
+ try
{
- currTable = currDB.getTable(attributes.getValue("name"));
-
- // check schema integrity
- // if idMethod="autoincrement", make sure a column is
- // specified as autoIncrement="true"
- if ( currTable.getIdMethod().equals("autoincrement") )
+ if(!firstPass)
{
- Column[] columns = currTable.getColumns();
- boolean foundOne = false;
- for ( int i=0; i<columns.length && !foundOne; i++ )
+ if (rawName.equals("database"))
{
- foundOne = columns[i].isAutoIncrement();
+ String s = attributes.getValue("name");
+ if ( s == null )
+ {
+ s = TurbineDB.getDefaultDB();
+ }
+ currDB = app.getDatabase(s);
}
- if ( !foundOne )
+ if (rawName.equals("table"))
{
- errorMessage += "Table '" + currTable.getName() +
- "' is marked as autoincrement, but it does not " +
- "have a column which declared as the one to " +
- "auto increment (i.e. autoIncrement=\"true\")\n";
+ currTable = currDB.getTable(attributes.getValue("name"));
+
+ // check schema integrity
+ // if idMethod="autoincrement", make sure a column is
+ // specified as autoIncrement="true"
+ if ( currTable.getIdMethod().equals("autoincrement") )
+ {
+ Column[] columns = currTable.getColumns();
+ boolean foundOne = false;
+ for ( int i=0; i<columns.length && !foundOne; i++ )
+ {
+ foundOne = columns[i].isAutoIncrement();
+ }
+ if ( !foundOne )
+ {
+ errorMessage += "Table '" + currTable.getName() +
+ "' is marked as autoincrement, but it does not " +
+ "have a column which declared as the one to " +
+ "auto increment (i.e. autoIncrement=\"true\")\n";
+ }
+
+ }
}
-
+ else if (rawName.equals("foreign-key"))
+ {
+ foreignTable = currDB
+ .getTable(attributes.getValue("foreignTable"));
+ }
+ else if (rawName.equals("reference"))
+ {
+ ForeignKey fk = currTable
+ .getForeignKey(attributes.getValue("local"));
+ Vector referrers = foreignTable.getReferrers();
+ if (referrers == null || !referrers.contains(fk))
+ {
+ foreignTable.addReferrer(fk);
+ }
+ foreignTable.getColumn(attributes.getValue("foreign"))
+ .addReferrer(fk);
+
+ //check for foreign pk's
+ if (currTable.getColumn(attributes
+ .getValue("local")).isPrimaryKey())
+ {
+ currTable.setContainsForeignPK(true);
}
- }
- else if (rawName.equals("foreign-key"))
- {
- foreignTable = currDB.getTable(attributes.getValue("foreignTable"));
- }
- else if (rawName.equals("reference"))
- {
- ForeignKey fk = currTable.getForeignKey(attributes.getValue("local"));
- Vector referrers = foreignTable.getReferrers();
- if (referrers == null || !referrers.contains(fk))
- foreignTable.addReferrer(fk);
- foreignTable.getColumn(attributes.getValue("foreign"))
- .addReferrer(fk);
-
- //check for foreign pk's
- if (currTable.getColumn(attributes.getValue("local")).isPrimaryKey())
+ }
+ }
+ else
{
- currTable.setContainsForeignPK(true);
+ if (rawName.equals("database"))
+ {
+ currDB = app.addDatabase(attributes);
+ }
+ else if (rawName.equals("table"))
+ {
+ currTable = currDB.addTable(attributes);
+ }
+ else if (rawName.equals("column"))
+ {
+ currColumn = currTable.addColumn(attributes);
+ }
+ else if (rawName.equals("inheritance"))
+ {
+ currColumn.addInheritance(attributes);
+ }
+ else if (rawName.equals("foreign-key"))
+ {
+ currFK = currTable.addForeignKey(attributes);
+ }
+ else if (rawName.equals("reference"))
+ {
+ currFK.addReference(attributes);
+ }
+ else if (rawName.equals("index"))
+ {
+ currIndex = currTable.addIndex(attributes);
+ }
+ else if (rawName.equals("index-column"))
+ {
+ currIndex.addColumn(attributes);
+ }
+ else if (rawName.equals("unique"))
+ {
+ currUnique = currTable.addUnique(attributes);
+ }
+ else if (rawName.equals("unique-column"))
+ {
+ currUnique.addColumn(attributes);
+ }
+ else if (rawName.equals("id-method-parameter"))
+ {
+ currTable.addIdMethodParameter(attributes);
+ }
}
- }
- }
- else
- {
- if (rawName.equals("database"))
- {
- currDB = app.addDatabase(attributes);
- }
- else if (rawName.equals("table"))
- {
- currTable = currDB.addTable(attributes);
- }
- else if (rawName.equals("column"))
- {
- currColumn = currTable.addColumn(attributes);
}
- else if (rawName.equals("inheritance"))
+ catch(Exception e)
{
- currColumn.addInheritance(attributes);
- }
- else if (rawName.equals("foreign-key"))
- {
- currFK = currTable.addForeignKey(attributes);
- }
- else if (rawName.equals("reference"))
- {
- currFK.addReference(attributes);
- }
- else if (rawName.equals("index"))
- {
- currIndex = currTable.addIndex(attributes);
- }
- else if (rawName.equals("index-column"))
- {
- currIndex.addColumn(attributes);
- }
- else if (rawName.equals("unique"))
- {
- currUnique = currTable.addUnique(attributes);
- }
- else if (rawName.equals("unique-column"))
- {
- currUnique.addColumn(attributes);
- }
- else if (rawName.equals("id-method-parameter"))
- {
- currTable.addIdMethodParameter(attributes);
+ e.printStackTrace();
}
- }
-}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