Frank Conradie wrote:
> 
> > Again. Let's add "javaname" attribute and everyone is happy.
> 
> Feel free to add it. Just make sure that when no "javaname" property is
> specified, that the old, default naming scheme is used.

here it is. I did not try to build newtorque yet so be careful - these are not checked:

-------------patch---------------
Index: Column.java
===================================================================
RCS file: 
/products/cvs/turbine/turbine/src/java/org/apache/turbine/samples/newtorque/Column.java,v
retrieving revision 1.2
diff -u -r1.2 Column.java
--- Column.java 2000/09/10 14:48:28     1.2
+++ Column.java 2000/09/14 02:47:39
@@ -78,6 +78,8 @@
 
 
        private String name;
+    private String javaName = null;
+    private boolean javaNameExplicit = false;
        private String relatedTableName;
        private String relatedColumnName;
        private boolean isNotNull;
@@ -114,6 +116,7 @@
 
         //Name
         name = attrib.getValue("name");
+        setJavaName(attrib.getValue("javaName"));
 
         //Foreign Key
        relatedTableName = attrib.getValue("foreignKeyTable");
@@ -230,6 +233,28 @@
     }
 
     /**
+     * Get name to use in Java sources
+     */
+    
+    public String getJavaName()
+    {
+        return javaName;
+    }
+
+    /**
+     * Set name to use in Java sources
+     */
+    
+    public void setJavaName(String javaName)
+    {
+        javaNameExplicit = (javaName!=null)
+        if (javaNameExplicit)
+            this.javaName = javaName;
+        else
+            this.javaName = StringUtil.removeUnderScores(name);
+    }
+
+    /**
      * Get the relatedTableName of the column if isForeignKey = true.
      * Otherwise return null
      */
@@ -502,6 +527,8 @@
     {
         StringBuffer result = new StringBuffer();
         result.append("<column name=\""+name+"\"");
+        if (javaNameExplicit)
+            result.append(" javaName=\"").append(javaName).append("\"")
         if (isPrimaryKey)
         {
             result.append(" primarykey=\""+isPrimaryKey+"\"");
@@ -617,4 +644,4 @@
         return "ON UPDATE "+getOnUpdateString().toUpperCase();
     }
 
-}
\ No newline at end of file
+}
Index: Table.java
===================================================================
RCS file: 
/products/cvs/turbine/turbine/src/java/org/apache/turbine/samples/newtorque/Table.java,v
retrieving revision 1.2
diff -u -r1.2 Table.java
--- Table.java  2000/09/10 14:48:28     1.2
+++ Table.java  2000/09/14 02:47:39
@@ -64,6 +64,8 @@
 import org.xml.sax.*;
 import org.xml.sax.helpers.*;
 
+//StringUtil
+import org.apache.turbine.samples.newtorque.generation.StringUtil;
 
 /**
  * A Class for holding data about a table used in an Application.
@@ -77,6 +79,8 @@
        private Vector columnVector;
        private String name;
        private AppData tableParent;
+    private String javaName = null;
+    private boolean javaNameExplicit = false;
 
     /**
      * Default Constructor
@@ -91,13 +95,13 @@
         this.name = name;
        columnVector = new Vector();
     }
-
-
+    
     public void loadFromXML (AttributeList attrib)
     {
        //attributes = new AttributeListImpl(attrib);
        //name
        name = attrib.getValue("name");
+        setJavaName(attrib.getValue("javaName"));
     }
 
 
@@ -131,13 +135,37 @@
     {
        return name;
     }
-
+    
     /**
      * Set the name of the Table
      */
     public void setName(String newName)
     {
        name = newName;
+        if (!javaNameExplicit)
+            setJavaName(null);
+    }
+
+    /**
+     * Get name to use in Java sources
+     */
+    
+    public String getJavaName()
+    {
+        return javaName;
+    }
+
+    /**
+     * Set name to use in Java sources
+     */
+    
+    public void setJavaName(String javaName)
+    {
+        javaNameExplicit = (javaName!=null)
+        if (javaNameExplicit)
+            this.javaName = javaName;
+        else
+            this.javaName = StringUtil.removeUnderScores(name);
     }
 
     /**
@@ -212,7 +240,12 @@
     {
         StringBuffer result = new StringBuffer();
 
-           result.append ("<table name=\"").append(name).append("\">\n");
+           result.append ("<table name=\"").append(name).append("\"");
+        if (javaNameExplicit)
+            result.append(" javaName=\"").append(javaName).append("\"")
+        result.append (">\n");
+        
+        
 
            for (Enumeration e = columnVector.elements() ; e.hasMoreElements() ;)
            {
@@ -247,4 +280,4 @@
         return result.toString();
     }
 
-}
\ No newline at end of file
+}
Index: mapbuilder.java
===================================================================
RCS file: /products/cvs/turbine/turbine/src/templates/newtorque/om/mapbuilder.java,v
retrieving revision 1.1
diff -u -r1.1 mapbuilder.java
--- mapbuilder.java     2000/09/10 14:05:36     1.1
+++ mapbuilder.java     2000/09/14 02:46:25
@@ -10,10 +10,10 @@
 import org.apache.turbine.util.db.pool.DBBroker;
 
 /** This class was autogenerated by GenerateMapBuilder on: Tue Jul 18 08:19:52 
GMT+02:00 2000 */
-public class $strings.removeUnderScores($table.Name)MapBuilder implements MapBuilder
+public class $table.JavaName;MapBuilder implements MapBuilder
 {
     /** the name of this class */
-    public static final String CLASS_NAME = 
"$package;.map.$strings.removeUnderScores($table.Name)MapBuilder";
+    public static final String CLASS_NAME = 
+"$package;.map.$table.JavaName;MapBuilder";
 
     /** item */
     public static String getTable( )
@@ -23,8 +23,8 @@
 
 #foreach $col in $table.Columns
 #begin
-    #set $tfc=$strings.removeUnderScores($table.Name)
-    #set $cfc=$strings.removeUnderScores($col.Name)
+    #set $tfc=$table.JavaName
+    #set $cfc=$col.JavaName
     #set $cup=$col.Name.toUpperCase()
 
     /** $table.Name;.$cup; */
@@ -67,8 +67,8 @@
 
 #foreach $col in $table.Columns
 #begin
-    #set $tfc=$strings.removeUnderScores($table.Name)
-    #set $cfc=$strings.removeUnderScores($col.Name)
+    #set $tfc=$table.JavaName
+    #set $cfc=$col.JavaName
     #set $cup=$col.Name.toUpperCase()
 
     #if($col.isPrimaryKey())
Index: object.java
===================================================================
RCS file: /products/cvs/turbine/turbine/src/templates/newtorque/om/object.java,v
retrieving revision 1.1
diff -u -r1.1 object.java
--- object.java 2000/09/10 14:05:36     1.1
+++ object.java 2000/09/14 02:46:25
@@ -7,7 +7,7 @@
 import org.apache.turbine.om.BaseObject;
 
 /** This class was autogenerated by GenerateMapBuilder on: Mon Aug 07 14:19:51 
GMT+02:00 2000 */
-public class $strings.removeUnderScores($table.Name) extends BaseObject
+public class $table.JavaName extends BaseObject
 {
 #foreach $col in $table.Columns
 #begin
@@ -19,7 +19,7 @@
 
 #foreach $col in $table.Columns
 #begin
-    #set $cfc=$strings.removeUnderScores($col.Name)
+    #set $cfc=$col.JavaName
     #set $clo=$col.Name.toLowerCase()
     /**
      * Get the $cfc
Index: omgenerate.wm
===================================================================
RCS file: /products/cvs/turbine/turbine/src/templates/newtorque/om/omgenerate.wm,v
retrieving revision 1.1
diff -u -r1.1 omgenerate.wm
--- omgenerate.wm       2000/09/10 14:05:36     1.1
+++ omgenerate.wm       2000/09/14 02:46:26
@@ -13,7 +13,7 @@
 #begin
     $tbl.Name
 
-    #set $firstcap=$strings.removeUnderScores($tbl.Name)
+    #set $firstcap=$tbl.JavaName
 
     #set $fname=$strings.concat($firstcap,"Peer.java")
     
$generator.parse("table",$tbl,"om/peer.java",$strings.concat($strings.getPackageAsPath($pkpeer),$fname))
@@ -24,4 +24,4 @@
     #set $fname=$strings.concat($firstcap,".java")
     
$generator.parse("table",$tbl,"om/object.java",$strings.concat($strings.getPackageAsPath($dbpackage),$fname))
 
-#end
\ No newline at end of file
+#end
Index: peer.java
===================================================================
RCS file: /products/cvs/turbine/turbine/src/templates/newtorque/om/peer.java,v
retrieving revision 1.1
diff -u -r1.1 peer.java
--- peer.java   2000/09/10 14:05:36     1.1
+++ peer.java   2000/09/14 02:46:26
@@ -18,18 +18,18 @@
 import $package;.*;
 
 /** This class was autogenerated by GenerateMapBuilder on: $now */
-public class $strings.removeUnderScores($table.Name)Peer extends BasePeer
+public class $table.JavaNamePeer extends BasePeer
 {
     /** the mapbuilder for this class */
-    private static final $strings.removeUnderScores($table.Name)MapBuilder mapBuilder 
= 
($strings.removeUnderScores($table.Name)MapBuilder)getMapBuilder($strings.removeUnderScores($table.Name)MapBuilder.CLASS_NAME);
+    private static final $table.JavaNameMapBuilder mapBuilder = 
+($table.JavaNameMapBuilder)getMapBuilder($table.JavaNameMapBuilder.CLASS_NAME);
 
     /** the table name for this class */
     public static final String TABLE_NAME = mapBuilder.getTable();
 
 #foreach $col in $table.Columns
 #begin
-    #set $tfc=$strings.removeUnderScores($table.Name)
-    #set $cfc=$strings.removeUnderScores($col.Name)
+    #set $tfc=$table.JavaName
+    #set $cfc=$col.JavaName
     #set $cup=$col.Name.toUpperCase()
     /** the column name for the $cup field */
     public static final String $cup = mapBuilder.get$tfc;_$cfc;();
@@ -52,13 +52,13 @@
     }
     
     /** Create a new object from a resultset row */
-    public static $strings.removeUnderScores($table.Name) row2Object (Record row, int 
offset) throws Exception
+    public static $table.JavaName row2Object (Record row, int offset) throws Exception
     {
-        $strings.removeUnderScores($table.Name) obj = new 
$strings.removeUnderScores($table.Name) ();
+        $table.JavaName obj = new $table.JavaName ();
         #set $n=0
         #foreach $col in $table.Columns
         #begin
-            #set $cfc=$strings.removeUnderScores($col.Name)
+            #set $cfc=$col.JavaName
             obj.set$cfc; ( 
row.getValue(offset+$n).$strings.getVillageType($col.Type); );
             #set $n=$numbers.increment($n)
         #end
@@ -110,25 +110,25 @@
      }
 
     /** Method to do inserts */
-    public static Object doInsert( $strings.removeUnderScores($table.Name) obj ) 
throws Exception
+    public static Object doInsert( $table.JavaName obj ) throws Exception
     {
-        return 
$strings.removeUnderScores($table.Name);Peer.doInsert(buildCriteria(obj));
+        return $table.JavaName;Peer.doInsert(buildCriteria(obj));
     }
 
     /** Build a Criteria object from the data object for this peer */
-    public static Criteria buildCriteria( $strings.removeUnderScores($table.Name) obj 
)
+    public static Criteria buildCriteria( $table.JavaName obj )
     {
         Criteria criteria = new Criteria();
         /*if( obj.getVisitorid() > 0 )
             criteria.add( VisitorPeer.VISITORID, obj.getVisitorid() );*/
  #foreach $col in $table.Columns
  #begin
-     #set $cfc=$strings.removeUnderScores($col.Name)
+     #set $cfc=$col.JavaName
      #set $cup=$col.Name.toUpperCase()
      #if($col.isPrimaryKey())
      #begin
         if( obj.get$cfc;() > 0 )
-            criteria.add( $strings.removeUnderScores($table.Name)Peer.$cup, 
obj.get$cfc;() );
+            criteria.add( $table.JavaNamePeer.$cup, obj.get$cfc;() );
             
      #end
      #else
@@ -143,16 +143,16 @@
     /**
      * @param obj the data object to update in the database.
      */
-    public static void doUpdate($strings.removeUnderScores($table.Name) obj) throws 
Exception
+    public static void doUpdate($table.JavaName obj) throws Exception
     {
-        $strings.removeUnderScores($table.Name);Peer.doUpdate(buildCriteria(obj));
+        $table.JavaName;Peer.doUpdate(buildCriteria(obj));
     }
     /**
      * @param obj the data object to delete in the database.
      */
-    public static void doDelete($strings.removeUnderScores($table.Name) obj) throws 
Exception
+    public static void doDelete($table.JavaName obj) throws Exception
     {
-        $strings.removeUnderScores($table.Name);Peer.doDelete(buildCriteria(obj));
+        $table.JavaName;Peer.doDelete(buildCriteria(obj));
     }
 
 }
----end of patch ----


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to