db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1403508 - in /db/torque/torque4/trunk/torque-templates/src/main: java/org/apache/torque/templates/ java/org/apache/torque/templates/transformer/om/ java/org/apache/torque/templates/transformer/om/mapInit/ resources/org/apache/torque/templa...
Date Mon, 29 Oct 2012 21:01:00 GMT
Author: tfischer
Date: Mon Oct 29 21:00:59 2012
New Revision: 1403508

URL: http://svn.apache.org/viewvc?rev=1403508&view=rev
Log:
TORQUE-240 fix issues with qualified table names

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/DatabaseMapInitTableTransformer.java
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0-strict.xsd
    db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java?rev=1403508&r1=1403507&r2=1403508&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/TemplateOptionName.java
Mon Oct 29 21:00:59 2012
@@ -44,6 +44,10 @@ public enum TemplateOptionName implement
      */
     OM_USE_IS_FOR_BOOLEAN_GETTERS("torque.om.useIsForBooleanGetters"),
 
+    /** Whether to retain schema names in java names. */
+    OM_RETAIN_SCHEMA_NAMES_IN_JAVA_NAME(
+            "torque.om.retainSchemaNamesInJavaName"),
+
     /** The default type for a column if no type is given. */
     DEFAULT_TYPE("torque.om.column.defaultType"),
 

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java?rev=1403508&r1=1403507&r2=1403508&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/OMTableAndViewTransformer.java
Mon Oct 29 21:00:59 2012
@@ -64,9 +64,6 @@ public class OMTableAndViewTransformer e
     private static CollectAttributeSetTrueTransformer primaryKeyTransformer
             = new CollectAttributeSetTrueTransformer();
 
-    /** The Camelbacker for producing the java name from the table name. */
-    private static Camelbacker javaNameCamelbacker = new Camelbacker();
-
     /** Prevents reserved java words. */
     private static WrapReservedJavaWords reservedJavaWordsWrapper
             = new WrapReservedJavaWords();
@@ -104,7 +101,7 @@ public class OMTableAndViewTransformer e
         throws SourceTransformerException
     {
         checkElementName(tableElement);
-        setJavaNameAttribute(tableElement);
+        setJavaNameAttribute(tableElement,controllerState);
         setFieldNameAttribute(tableElement);
         setIdMethodAttribute(tableElement);
         setSequenceAttributeIfNecessary(tableElement);
@@ -170,11 +167,14 @@ public class OMTableAndViewTransformer e
      * already set.
      *
      * @param tableElement the table element, not null.
+     * @param controllerState the controller state, not null.
      *
      * @throws SourceTransformerException if both attributes javaName and name
      *         are not set on the tableElement.
      */
-    public static void setJavaNameAttribute(SourceElement tableElement)
+    public static void setJavaNameAttribute(
+            SourceElement tableElement,
+              ControllerState controllerState)
             throws SourceTransformerException
     {
         // set javaName attribute
@@ -192,6 +192,15 @@ public class OMTableAndViewTransformer e
                         + tableElement.getName()
                         + " is null");
             }
+            Camelbacker javaNameCamelbacker = new Camelbacker();
+            javaNameCamelbacker.setRemoveWithoutUppercase("");
+            javaNameCamelbacker.setRemoveWithUppercase(
+                    javaNameCamelbacker.getRemoveWithUppercase() + ".");
+            if (!controllerState.getBooleanOption(
+                    TemplateOptionName.OM_RETAIN_SCHEMA_NAMES_IN_JAVA_NAME))
+            {
+                javaNameCamelbacker.setIgnorePartBefore(".");
+            }
             javaName = javaNameCamelbacker.process(inputName.toString());
             tableElement.setAttribute(
                     TorqueSchemaAttributeName.JAVA_NAME,

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/DatabaseMapInitTableTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/DatabaseMapInitTableTransformer.java?rev=1403508&r1=1403507&r2=1403508&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/DatabaseMapInitTableTransformer.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/DatabaseMapInitTableTransformer.java
Mon Oct 29 21:00:59 2012
@@ -71,19 +71,21 @@ public class DatabaseMapInitTableTransfo
 
     @Override
     public SourceElement transform(
-            SourceElement rootElement,
+            SourceElement tableElement,
             ControllerState controllerState)
         throws SourceTransformerException
     {
         if (!TorqueSchemaElementName.TABLE.getName().equals(
-                rootElement.getName()))
+                tableElement.getName()))
         {
             throw new IllegalArgumentException("Illegal element Name "
-                    + rootElement.getName());
+                    + tableElement.getName());
         }
-        OMTableAndViewTransformer.setJavaNameAttribute(rootElement);
-        super.transform(rootElement, controllerState);
-        OMTableAndViewTransformer.setPeerImplGetterAttribute(rootElement);
-        return rootElement;
+        OMTableAndViewTransformer.setJavaNameAttribute(
+                tableElement,
+                controllerState);
+        super.transform(tableElement, controllerState);
+        OMTableAndViewTransformer.setPeerImplGetterAttribute(tableElement);
+        return tableElement;
     }
  }

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties?rev=1403508&r1=1403507&r2=1403508&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/om/conf/options.properties
Mon Oct 29 21:00:59 2012
@@ -31,6 +31,12 @@ torque.om.retrievableInterface = org.apa
 # instead of getX methods.
 torque.om.useIsForBooleanGetters = true;
 
+# If true, Torque retains the schema names in automatically created java Names:
+# E.g. the table name bookstore.Book will result in the java name BookstoreBook.
+# If false, the schema name will be removed:
+# E.g. the table name bookstore.Book will result in the java name Book.
+torque.om.retainSchemaNamesInJavaName = false
+
 # If true, Torque generates data objects with getters and setters 
 # for referenced and referencing objects connected by foreign key relations.
 torque.om.complexObjectModel = true

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0-strict.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0-strict.xsd?rev=1403508&r1=1403507&r2=1403508&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0-strict.xsd
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0-strict.xsd
Mon Oct 29 21:00:59 2012
@@ -82,7 +82,7 @@ as compared to the standard database.xsd
         </xs:documentation>
       </xs:annotation>
       <xs:restriction base="sqlQualifiedNameType">
-        <xs:pattern value="[A-Za-z$#][A-Za-z_$#0-9]*\.?[A-Za-z$#][A-Za-z_$#0-9]*" />
+        <xs:pattern value="[A-Za-z$#][A-Za-z_$#0-9]*(\.[A-Za-z$#][A-Za-z_$#0-9]*)?" />
       </xs:restriction>
     </xs:simpleType>
   </xs:redefine>

Modified: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd?rev=1403508&r1=1403507&r2=1403508&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd
Mon Oct 29 21:00:59 2012
@@ -318,7 +318,7 @@ Define a unique value constraint
         </xs:element>
       </xs:choice>
     </xs:sequence>
-    <xs:attribute name="name" type="sqlNameType" use="required" >
+    <xs:attribute name="name" type="sqlQualifiedNameType" use="required" >
       <xs:annotation>
         <xs:documentation xml:lang="en">
 The table name of the SQL table.
@@ -618,7 +618,7 @@ The name used to create the foreign key 
         </xs:documentation>
       </xs:annotation>
     </xs:attribute>
-    <xs:attribute name="foreignTable" type="sqlNameType" use="required" >
+    <xs:attribute name="foreignTable" type="sqlQualifiedNameType" use="required" >
       <xs:annotation>
         <xs:documentation xml:lang="en">
 The name of the table that contains the foreign key



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message