Daniel Rall wrote:
>"Byron Foster" <[EMAIL PROTECTED]> writes:
>
>
>You're right -- I misread the diff.
>
>>for the attribute name that sounds fine, I will submit a patch. So the
>>following names would be changed to:
>>
>>defaultConversionMethod -> defaultJavaNamingMethod
>>nameConversion -> javaNamingMethod (for column and table elements)
>>
>
>Yes, I think those names (or ones like them) are more indicative of
>what the attributes are for.
>
>>BTW, I was not sure if the dtd was the correct place to put the docs for
>>the different naming methods. Are there plans to add this type of
>>documentation to the dtd? the xdocs? both? regardless I can add some
>>additional documentation.
>>
>
>IMHO, putting documentation in the DTD is just fine. Examples and
>usage instructions should be placed in the xdocs directory,
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
Here are two patches.
namingpatch.txt -> jakarta-turbine-torque directory
This patch makes the above name changes to javaNamingMethod exactly
as described.
docspatch.txt -> jakarta-turbine-2 directory
This patch adds documentation to torque-schema-ref.xml describing
the new javaNamingMethod attributes.
Thanks,
Byron
? namingpatch.txt
Index: src/dtd/database.dtd
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/dtd/database.dtd,v
retrieving revision 1.3
diff -u -r1.3 database.dtd
--- src/dtd/database.dtd 2001/09/16 18:48:03 1.3
+++ src/dtd/database.dtd 2001/10/13 10:12:17
@@ -20,7 +20,7 @@
<!--
-defaultConversionMethod determines how a table or column name,
+defaultJavaNamingMethod determines how a table or column name,
from the name attribute in the xml database file, is converted to a
Java class or method name.
@@ -41,7 +41,7 @@
baseClass CDATA #IMPLIED
basePeer CDATA #IMPLIED
- defaultNameConversion (nochange|underscore|javaname) "underscore"
+ defaultJavaNamingMethod (nochange|underscore|javaname) "underscore"
>
<!ELEMENT table (column+,(foreign-key|index|unique|id-method-parameter)*)>
@@ -54,7 +54,7 @@
baseClass CDATA #IMPLIED
basePeer CDATA #IMPLIED
alias CDATA #IMPLIED
- nameConversion (nochange|underscore|javaname) #IMPLIED
+ javaNamingMethod (nochange|underscore|javaname) #IMPLIED
>
<!ELEMENT id-method-parameter EMPTY>
@@ -82,7 +82,7 @@
autoIncrement (true|false) "false"
inheritance (single|false) "false"
inputValidator CDATA #IMPLIED
- nameConversion (nochange|underscore|javaname) #IMPLIED
+ javaNamingMethod (nochange|underscore|javaname) #IMPLIED
>
<!ELEMENT inheritance EMPTY>
Index: src/java/org/apache/torque/engine/database/model/Column.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Column.java,v
retrieving revision 1.13
diff -u -r1.13 Column.java
--- src/java/org/apache/torque/engine/database/model/Column.java 2001/09/30
21:28:42 1.13
+++ src/java/org/apache/torque/engine/database/model/Column.java 2001/10/13
+10:12:17
@@ -77,7 +77,7 @@
{
private String name;
private String javaName = null;
- private String nameConversion;
+ private String javaNamingMethod;
private boolean isNotNull = false;
private String size;
private String torqueType;
@@ -157,11 +157,11 @@
// retrieves the method for converting from specified name to
// a java name.
- nameConversion = attrib.getValue("nameConversion");
- if (nameConversion == null)
+ javaNamingMethod = attrib.getValue("javaNamingMethod");
+ if (javaNamingMethod == null)
{
- nameConversion =
- parentTable.getDatabase().getDefaultNameConversion();
+ javaNamingMethod =
+ parentTable.getDatabase().getDefaultJavaNamingMethod();
}
//Primary Key
@@ -232,7 +232,7 @@
{
List inputs = new ArrayList(2);
inputs.add(name);
- inputs.add(nameConversion);
+ inputs.add(javaNamingMethod);
try
{
javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR,
Index: src/java/org/apache/torque/engine/database/model/Database.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Database.java,v
retrieving revision 1.5
diff -u -r1.5 Database.java
--- src/java/org/apache/torque/engine/database/model/Database.java 2001/09/16
19:00:28 1.5
+++ src/java/org/apache/torque/engine/database/model/Database.java 2001/10/13
+10:12:18
@@ -88,7 +88,7 @@
private String baseClass;
private String basePeer;
private String defaultIdMethod;
- private String defaultNameConversion;
+ private String defaultJavaNamingMethod;
private AppData dbParent;
private Hashtable tablesByName = new Hashtable();
private Hashtable tablesByJavaName = new Hashtable();
@@ -110,10 +110,10 @@
baseClass = attrib.getValue("baseClass");
basePeer = attrib.getValue("basePeer");
defaultIdMethod = attrib.getValue("defaultIdMethod");
- defaultNameConversion = attrib.getValue("defaultNameConversion");
- if (defaultNameConversion == null)
+ defaultJavaNamingMethod = attrib.getValue("defaultJavaNamingMethod");
+ if (defaultJavaNamingMethod == null)
{
- defaultNameConversion = NameGenerator.CONV_METHOD_UNDERSCORE;
+ defaultJavaNamingMethod = NameGenerator.CONV_METHOD_UNDERSCORE;
}
}
@@ -214,23 +214,23 @@
}
/**
- * Get the value of defaultNameConversion which specifies the
+ * Get the value of defaultJavaNamingMethod which specifies the
* method for converting schema names for table and column
* to Java names.
* @return The default naming conversion used by this database.
*/
- public String getDefaultNameConversion()
+ public String getDefaultJavaNamingMethod()
{
- return defaultNameConversion;
+ return defaultJavaNamingMethod;
}
/**
- * Set the value of defaultNameConversion.
+ * Set the value of defaultJavaNamingMethod.
* @param v The default naming conversion for this database to use.
*/
- public void setDefaultNameConversion(String v)
+ public void setDefaultJavaNamingMethod(String v)
{
- this.defaultNameConversion = v;
+ this.defaultJavaNamingMethod = v;
}
/**
Index: src/java/org/apache/torque/engine/database/model/Table.java
===================================================================
RCS file:
/home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/engine/database/model/Table.java,v
retrieving revision 1.14
diff -u -r1.14 Table.java
--- src/java/org/apache/torque/engine/database/model/Table.java 2001/09/16 19:00:28
1.14
+++ src/java/org/apache/torque/engine/database/model/Table.java 2001/10/13 10:12:18
@@ -90,7 +90,7 @@
private String name;
private String javaName;
private String idMethod;
- private String nameConversion;
+ private String javaNamingMethod;
private Database tableParent;
private List referrers;
private List foreignTableNames;
@@ -139,10 +139,10 @@
// retrieves the method for converting from specified name to
// a java name.
- nameConversion = attrib.getValue("nameConversion");
- if (nameConversion == null)
+ javaNamingMethod = attrib.getValue("javaNamingMethod");
+ if (javaNamingMethod == null)
{
- nameConversion = getDatabase().getDefaultNameConversion();
+ javaNamingMethod = getDatabase().getDefaultJavaNamingMethod();
}
if ("null".equals(idMethod))
@@ -594,7 +594,7 @@
{
List inputs = new ArrayList(2);
inputs.add(name);
- inputs.add(nameConversion);
+ inputs.add(javaNamingMethod);
try
{
javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR,
? docspatch.txt
Index: xdocs/howto/torque-schema-ref.xml
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-2/xdocs/howto/torque-schema-ref.xml,v
retrieving revision 1.1
diff -u -r1.1 torque-schema-ref.xml
--- xdocs/howto/torque-schema-ref.xml 2001/08/19 16:37:39 1.1
+++ xdocs/howto/torque-schema-ref.xml 2001/10/13 10:08:44
@@ -31,17 +31,19 @@
defaultIdMethod="idBroker"
package="com.myapp.om"
baseClass="com.myapp.om.BaseClass"
- basePeer="com.myapp.om.BasePeer">
+ basePeer="com.myapp.om.BasePeer"
+ defaultJavaNamingMethod="underscore">
<table name="SIMPLE">
<!-- table info goes here -->
</table>
</database>]]>
</source>
<p>
- The database element has 5 attributes associated with it, they are:
+ The database element has 6 attributes associated with it, they are:
<ul>
<li>name - The name of the database being referenced</li>
<li>defaultIdMethod - How will the primary keys be created, defaults to
"none"</li>
+ <li>defaultJavaNamingMethod - indicates how a schema table or column name
+is mapped to a java class or method name respectively</li>
<li>package - used for OM Peer generation</li>
<li>baseClass - used for OM generation</li>
<li>basePeer - used for OM Peer generation</li>
@@ -69,6 +71,23 @@
</ul>
</p>
</subsection>
+ <subsection name="Attribute: defaultJavaNameMethod">
+ <p>
+ This attribute determines how table or column names, from the
+ name attribute of the table or column element, are converted to a
+ Java class or method name respectively when creating the OM java
+ objects. defaultJavaNameMethod can contain 3 different values:
+ <ul>
+ <li>nochange - Indicates no change is performed.</li>
+ <li>underscore - Underscores are removed, First letter is
+ capitalized, first letter after an underscore
+ is capitalized, the rest of the letters are
+ converted to lowercase.</li>
+ <li>javaname - Same as underscore, but no letters are converted
+ to lowercase.</li>
+ </ul>
+ </p>
+ </subsection>
<subsection name="Attribute: package">
<p>
The base package in which this database will generate the Object Models
associated with it.
@@ -96,12 +115,13 @@
idMethod="idbroker"
skipSql="false"
baseClass="com.myapp.om.table.BaseClass"
- basePeer="com.myapp.om.table.BasePeer">
+ basePeer="com.myapp.om.table.BasePeer"
+ javaNamingMethod="underscore">
<!-- column information here -->
</table>]]>
</source>
<p>
- The table element has 8 attributes associated with it, they are:
+ The table element has 9 attributes associated with it, they are:
<ul>
<li>name - The name of the database being referenced</li>
<li>javaName - How this table will be referenced in java</li>
@@ -111,6 +131,12 @@
<li>alias - The table alias</li>
<li>baseClass - used for OM Peer generation</li>
<li>basePeer - used for OM Peer generation</li>
+
+ <li>javaNamingMethod - Specifies how the name attribute is
+ converted to the Java class name of the coresponding OM
+ object. this attribute overides the
+ defaultJavaNamingMethod attribute of the database
+ element</li>
</ul>
</p>
@@ -141,13 +167,14 @@
primaryKey="true"
required="true"
size="4"
- type="VARCHAR">
+ type="VARCHAR"
+ javaNamingMethod="underscore">
<!-- inheritance info if necessary -->
</column>
]]>
</source>
<p>
- The column element has 8 attributes associated with it, they are:
+ The column element has 9 attributes associated with it, they are:
<ul>
<li>name - The name of the column being referenced</li>
<li>javaName - How this column will be referred to in Java</li>
@@ -159,6 +186,12 @@
<li>autoIncrement - Whether or not to auto-increment this field, defaults
to "false"</li>
<li>inheritance - ?</li>
<li>inputValidator - ?</li>
+
+ <li>javaNamingMethod - Specifies how the name attribute is
+ converted to a property name (defined by the get/set method pair)
+ of the coresponding OM object. this attribute overrides
+ the defaultJavaNamingMethod attribute of the database
+ element</li>
</ul>
</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]