You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by mp...@apache.org on 2003/09/27 13:13:49 UTC
cvs commit: db-torque/src/generator/src/java/org/apache/torque/task TorqueSQLTask.java TorqueDataModelTask.java
mpoeschl 2003/09/27 04:13:49
Modified: src/generator/src/java/org/apache/torque/engine/database/model
ConstraintNameGenerator.java AppData.java
Database.java
src/generator/src/test/org/apache/torque/engine/database/model
NameFactoryTest.java TableTest.java
src/generator/src/test/org/apache/torque/engine/database
TestPackageHandling.java
src/generator/src/java/org/apache/torque/engine/database/transform
XmlToAppData.java SQLToAppData.java
src/generator/src/java/org/apache/torque/task
TorqueSQLTask.java TorqueDataModelTask.java
Log:
- use platform package instead of db.props when loading the db model from xml
- remove methods used to handle the db.props files
Revision Changes Path
1.3 +4 -9 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/ConstraintNameGenerator.java
Index: ConstraintNameGenerator.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/ConstraintNameGenerator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ConstraintNameGenerator.java 26 Jun 2003 06:59:56 -0000 1.2
+++ ConstraintNameGenerator.java 27 Sep 2003 11:13:48 -0000 1.3
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -97,8 +97,7 @@
int maxBodyLength = -1;
try
{
- int maxColumnNameLength =
- Integer.parseInt(db.getProperty("maxColumnNameLength"));
+ int maxColumnNameLength = db.getPlatform().getMaxColumnNameLength();
maxBodyLength = (maxColumnNameLength - namePostfix.length()
- constraintNbr.length() - 2);
@@ -107,10 +106,6 @@
log.debug("maxColumnNameLength=" + maxColumnNameLength
+ " maxBodyLength=" + maxBodyLength);
}
- }
- catch (EngineException e)
- {
- log.error(e.getMessage(), e);
}
catch (NumberFormatException maxLengthUnknown)
{
1.5 +6 -86 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/AppData.java
Index: AppData.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/AppData.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AppData.java 25 Jul 2003 16:40:30 -0000 1.4
+++ AppData.java 27 Sep 2003 11:13:48 -0000 1.5
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -54,20 +54,12 @@
* <http://www.apache.org/>.
*/
-import java.io.File;
-import java.io.FileInputStream;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
-import java.util.Properties;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.apache.torque.engine.EngineException;
import org.apache.torque.engine.database.transform.DTDResolver;
@@ -79,34 +71,22 @@
* @author <a href="mailto:leon@opticode.co.za>Leon Messerschmidt</a>
* @author <a href="mailto:jmcnally@collab.net>John McNally</a>
* @author <a href="mailto:dlr@finemaltcoding.com>Daniel Rall</a>
+ * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
* @version $Id$
*/
public class AppData
{
- /** Logging class from commons.logging */
- private static Log log = LogFactory.getLog(AppData.class);
-
/**
* The list of databases for this application.
*/
private List dbList = new ArrayList(5);
/**
- * The table of idiosyncrasies for various database types.
- */
- private Map idiosyncrasyTable = new HashMap(8);
-
- /**
* The type for our databases.
*/
private String databaseType;
/**
- * The base of the path to the properties file, including trailing slash.
- */
- private String basePropsFilePath;
-
- /**
* Name of the database. Only one database definition
* is allowed in one XML descriptor.
*/
@@ -123,72 +103,12 @@
* @param basePropsFilePath The base of the path to the properties
* file, including trailing slash.
*/
- public AppData(String databaseType, String basePropsFilePath)
+ public AppData(String databaseType)
{
- this.basePropsFilePath = basePropsFilePath;
this.databaseType = databaseType;
}
/**
- * Each database has its own list of idiosyncrasies which can be
- * configured by editting its <code>db.props</code> file.
- *
- * @param databaseType The type of database to retrieve the
- * properties of.
- * @return The idiosyncrasies of <code>databaseType</code>.
- * @exception EngineException Couldn't locate properties file.
- */
- protected Properties getIdiosyncrasies(String databaseType)
- throws EngineException
- {
- Properties idiosyncrasies
- = (Properties) idiosyncrasyTable.get(databaseType);
-
- // If we haven't yet loaded the properties and we have the
- // information to do so, proceed with loading.
- if (idiosyncrasies == null && basePropsFilePath != null
- && databaseType != null)
- {
- idiosyncrasies = new Properties();
- File propsFile = new File(basePropsFilePath + databaseType,
- "db.props");
- if (propsFile.exists())
- {
- try
- {
- idiosyncrasies.load(new FileInputStream(propsFile));
- }
- catch (Exception e)
- {
- log.error(e, e);
- }
- idiosyncrasyTable.put(databaseType, idiosyncrasies);
- }
- else
- {
- try
- {
- String path = '/' + basePropsFilePath + databaseType
- + "/db.props";
- idiosyncrasies.load(getClass().getResourceAsStream(path));
- }
- catch (Exception e)
- {
- log.error(e, e);
- }
- }
-
- if (idiosyncrasies.isEmpty())
- {
- throw new EngineException("Database-specific properties "
- + "file does not exist: "
- + propsFile.getAbsolutePath());
- }
- }
- return idiosyncrasies;
- }
-
- /**
* Set the name of the database.
*
* @param name of the database.
@@ -264,7 +184,7 @@
* @param name database name
* @return A Database object. If it does not exist it returns null
*/
- public Database getDatabase (String name)
+ public Database getDatabase(String name)
throws EngineException
{
doFinalInitialization();
1.7 +9 -13 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java
Index: Database.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Database.java 4 Aug 2003 05:30:29 -0000 1.6
+++ Database.java 27 Sep 2003 11:13:48 -0000 1.7
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -58,9 +58,10 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
-import java.util.Properties;
import org.apache.torque.engine.EngineException;
+import org.apache.torque.engine.platform.Platform;
+import org.apache.torque.engine.platform.PlatformFactory;
import org.xml.sax.Attributes;
@@ -360,18 +361,13 @@
}
/**
- * Returns the value of the named property from this database's
- * <code>db.props</code> file.
+ * Returns the Platform implementation for this database.
*
- * @param name The name of the property to retrieve the value of.
- * @return The value of the specified property.
- * @exception EngineException Couldn't access properties.
+ * @return a Platform implementation
*/
- protected String getProperty(String name)
- throws EngineException
+ protected Platform getPlatform()
{
- Properties p = getAppData().getIdiosyncrasies(databaseType);
- return (p == null ? null : p.getProperty(name));
+ return PlatformFactory.getPlatformFor(databaseType);
}
/**
1.2 +4 -4 db-torque/src/generator/src/test/org/apache/torque/engine/database/model/NameFactoryTest.java
Index: NameFactoryTest.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/model/NameFactoryTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NameFactoryTest.java 10 Feb 2003 13:21:36 -0000 1.1
+++ NameFactoryTest.java 27 Sep 2003 11:13:48 -0000 1.2
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -160,7 +160,7 @@
/** Sets up the Torque model. */
public void setUp()
{
- AppData appData = new AppData(DATABASE_TYPE, "src/templates/sql/base/");
+ AppData appData = new AppData(DATABASE_TYPE);
database = new Database();
database.setDatabaseType(DATABASE_TYPE);
appData.addDatabase(database);
1.2 +4 -4 db-torque/src/generator/src/test/org/apache/torque/engine/database/model/TableTest.java
Index: TableTest.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/model/TableTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TableTest.java 1 Aug 2003 07:52:09 -0000 1.1
+++ TableTest.java 27 Sep 2003 11:13:48 -0000 1.2
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -91,7 +91,7 @@
public void testIdMethodHandling()
throws Exception
{
- xmlToAppData = new XmlToAppData("mysql", "defaultpackage", null);
+ xmlToAppData = new XmlToAppData("mysql", "defaultpackage");
appData = xmlToAppData.parseFile(
"src/test/org/apache/torque/engine/database/model/tabletest-schema.xml");
Database db = appData.getDatabase("iddb");
1.4 +5 -5 db-torque/src/generator/src/test/org/apache/torque/engine/database/TestPackageHandling.java
Index: TestPackageHandling.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/TestPackageHandling.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestPackageHandling.java 1 Aug 2003 07:30:55 -0000 1.3
+++ TestPackageHandling.java 27 Sep 2003 11:13:48 -0000 1.4
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -94,7 +94,7 @@
public void testDefaultPackageName()
throws Exception
{
- xmlToAppData = new XmlToAppData("mysql", "defaultpackage", null);
+ xmlToAppData = new XmlToAppData("mysql", "defaultpackage");
appData = xmlToAppData.parseFile(
"src/test/org/apache/torque/engine/database/package-schema.xml");
Database db = appData.getDatabase("packagedb");
@@ -109,7 +109,7 @@
public void testDatabasePackageName()
throws Exception
{
- xmlToAppData = new XmlToAppData("mysql", "defaultpackage", null);
+ xmlToAppData = new XmlToAppData("mysql", "defaultpackage");
appData = xmlToAppData.parseFile(
"src/test/org/apache/torque/engine/database/package2-schema.xml");
Database db = appData.getDatabase("packagedb2");
1.9 +13 -17 db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java
Index: XmlToAppData.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XmlToAppData.java 25 Aug 2003 21:31:22 -0000 1.8
+++ XmlToAppData.java 27 Sep 2003 11:13:49 -0000 1.9
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -127,13 +127,10 @@
*
* @param databaseType The type of database for the application.
* @param defaultPackage the default java package used for the om
- * @param basePropsFilePath The base of the path to the properties
- * file, including trailing slash.
*/
- public XmlToAppData(String databaseType, String defaultPackage,
- String basePropsFilePath)
+ public XmlToAppData(String databaseType, String defaultPackage)
{
- app = new AppData(databaseType, basePropsFilePath);
+ app = new AppData(databaseType);
this.defaultPackage = defaultPackage;
firstPass = true;
}
@@ -218,16 +215,15 @@
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException
{
- try
- {
- return new DTDResolver().resolveEntity(publicId, systemId);
- }
- catch (Exception e)
- {
- throw new SAXException(e);
- }
+ try
+ {
+ return new DTDResolver().resolveEntity(publicId, systemId);
+ }
+ catch (Exception e)
+ {
+ throw new SAXException(e);
+ }
}
-
/**
* Handles opening elements of the xml file.
1.3 +6 -9 db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/SQLToAppData.java
Index: SQLToAppData.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/SQLToAppData.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SQLToAppData.java 18 Feb 2003 08:05:50 -0000 1.2
+++ SQLToAppData.java 27 Sep 2003 11:13:49 -0000 1.3
@@ -3,7 +3,7 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
- * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -88,7 +88,6 @@
private Database appDataDB;
private int count;
private String databaseType;
- private String basePropsFilePath;
/**
* Create a new class with an input Reader
@@ -109,12 +108,10 @@
* @param databaseType
* @param basePropsFilePath
*/
- public SQLToAppData(String sqlFile, String databaseType,
- String basePropsFilePath)
+ public SQLToAppData(String sqlFile, String databaseType)
{
this.sqlFile = sqlFile;
this.databaseType = databaseType;
- this.basePropsFilePath = basePropsFilePath;
}
/**
@@ -572,7 +569,7 @@
public AppData execute() throws IOException, ParseException
{
count = 0;
- appData = new AppData(databaseType, basePropsFilePath);
+ appData = new AppData(databaseType);
appDataDB = new Database();
appData.addDatabase(appDataDB);
1.3 +4 -5 db-torque/src/generator/src/java/org/apache/torque/task/TorqueSQLTask.java
Index: TorqueSQLTask.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/task/TorqueSQLTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TorqueSQLTask.java 25 Jul 2003 16:47:42 -0000 1.2
+++ TorqueSQLTask.java 27 Sep 2003 11:13:49 -0000 1.3
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -207,8 +207,7 @@
{
// Transform the XML database schema into
// data model object.
- XmlToAppData xmlParser = new XmlToAppData(getTargetDatabase(), null,
- getBasePathToDbProps());
+ XmlToAppData xmlParser = new XmlToAppData(getTargetDatabase(), null);
AppData ad = xmlParser.parseFile(getIdTableXMLFile());
ad.setName("idmodel");
1.3 +4 -5 db-torque/src/generator/src/java/org/apache/torque/task/TorqueDataModelTask.java
Index: TorqueDataModelTask.java
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/task/TorqueDataModelTask.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TorqueDataModelTask.java 25 Jul 2003 16:47:42 -0000 1.2
+++ TorqueDataModelTask.java 27 Sep 2003 11:13:49 -0000 1.3
@@ -26,12 +26,12 @@
* 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
+ * "Apache Torque" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
- * "Apache Turbine", nor may "Apache" appear in their name, without
+ * "Apache Torque", 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
@@ -315,7 +315,7 @@
// Transform the XML database schema into
// data model object.
xmlParser = new XmlToAppData(getTargetDatabase(),
- getTargetPackage(), getBasePathToDbProps());
+ getTargetPackage());
AppData ad = xmlParser.parseFile(xmlFile);
ad.setName(grokName(xmlFile));
dataModels.add(ad);
@@ -336,8 +336,7 @@
{
File f = new File(srcDir, dataModelFiles[j]);
xmlParser = new XmlToAppData(getTargetDatabase(),
- getTargetPackage(),
- getBasePathToDbProps());
+ getTargetPackage());
AppData ad = xmlParser.parseFile(f.toString());
ad.setName(grokName(f.toString()));
dataModels.add(ad);
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org