cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r737709 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ framework/cayenne...
Date Mon, 26 Jan 2009 15:11:54 GMT
Author: aadamchik
Date: Mon Jan 26 15:11:53 2009
New Revision: 737709

URL: http://svn.apache.org/viewvc?rev=737709&view=rev
Log:
CAY-1175 Replace String column name capitalization property with an enum

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/CapsStrategy.java
Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQuery.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataObjectUtilsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/MapLoaderLoadTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_901Test.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateMainTab.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Mon Jan 26 15:11:53 2009
@@ -23,6 +23,7 @@
 CAY-1154 Rename .access.reveng package to .map.naming
 CAY-1156 Modeler search improvement
 CAY-1161 Deprecate SelectQuery custom columns feature
+CAY-1175 Replace String column name capitalization property with an enum
 
 Bug Fixes Since M5:
 

Modified: cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/UPGRADE.txt Mon Jan 26 15:11:53 2009
@@ -9,6 +9,9 @@
 * Per CAY-1161, custom columns feature in SelectQuery was deprecated. Consider switching
to EJBQL as an alternative.
   Custom columns support will likely go away completely after 3.0M6.
 
+* Per CAY-1175, 'columnNameCapitalization' property of SQLTemplate now takes an enum, not
a String. 
+  Calling code should be fixed.
+
 UPGRADING FROM 3.0M4
 
 * Per CAY-1127, query "name" property is no longer used as an internal cache key. This change
should be transparent

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/ProcedureAction.java
Mon Jan 26 15:11:53 2009
@@ -37,7 +37,6 @@
 import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.map.ProcedureParameter;
 import org.apache.cayenne.query.ProcedureQuery;
-import org.apache.cayenne.query.SQLTemplate;
 
 /**
  * A SQLAction that runs a stored procedure. Note that ProcedureAction has internal state
@@ -171,17 +170,16 @@
             ColumnDescriptor[] columns = descriptors.get(setIndex);
             builder.setColumns(columns);
         }
-        if (query.getColumnNamesCapitalization() != null) {
-            if (SQLTemplate.LOWERCASE_COLUMN_NAMES.equals(query
-                    .getColumnNamesCapitalization())) {
+
+        switch (query.getColumnNamesCapitalization()) {
+            case LOWER:
                 builder.useLowercaseColumnNames();
-            }
-            else if (SQLTemplate.UPPERCASE_COLUMN_NAMES.equals(query
-                    .getColumnNamesCapitalization())) {
+                break;
+            case UPPER:
                 builder.useUppercaseColumnNames();
-            }
+                break;
         }
-        
+
         return builder.getDescriptor(getAdapter().getExtendedTypes());
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/jdbc/SQLTemplateAction.java
Mon Jan 26 15:11:53 2009
@@ -290,15 +290,13 @@
             }
         }
 
-        if (query.getColumnNamesCapitalization() != null) {
-            if (SQLTemplate.LOWERCASE_COLUMN_NAMES.equals(query
-                    .getColumnNamesCapitalization())) {
+        switch (query.getColumnNamesCapitalization()) {
+            case LOWER:
                 builder.useLowercaseColumnNames();
-            }
-            else if (SQLTemplate.UPPERCASE_COLUMN_NAMES.equals(query
-                    .getColumnNamesCapitalization())) {
+                break;
+            case UPPER:
                 builder.useUppercaseColumnNames();
-            }
+                break;
         }
 
         return builder;

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/CapsStrategy.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/CapsStrategy.java?rev=737709&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/CapsStrategy.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/CapsStrategy.java
Mon Jan 26 15:11:53 2009
@@ -0,0 +1,28 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.query;
+
+/**
+ * Defines forced capitalization of the result column names in the DataRow.
+ * 
+ * @since 3.0
+ */
+public enum CapsStrategy {
+    DEFAULT, UPPER, LOWER
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQuery.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQuery.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQuery.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/ProcedureQuery.java
Mon Jan 26 15:11:53 2009
@@ -36,9 +36,8 @@
 /**
  * A query based on Procedure. Can be used as a select query, or as a query of an
  * arbitrary complexity, performing data modification, selecting data (possibly with
- * multiple result sets per call), returning values via OUT parameters.
- * <h3>Execution with DataContext</h3>
- * <h4>Reading OUT parameters</h4>
+ * multiple result sets per call), returning values via OUT parameters. <h3>Execution
with
+ * DataContext</h3> <h4>Reading OUT parameters</h4>
  * <p>
  * If a ProcedureQuery has OUT parameters, they are wrapped in a separate List in the
  * query result. Such list will contain a single Map with OUT parameter values.
@@ -53,7 +52,6 @@
  * form should be used:
  * {@link org.apache.cayenne.access.DataContext#performGenericQuery(Query)}.
  * </p>
- * 
  */
 public class ProcedureQuery extends AbstractQuery implements ParameterizedQuery,
         XMLSerializable {
@@ -61,15 +59,6 @@
     static final String COLUMN_NAME_CAPITALIZATION_PROPERTY = "cayenne.ProcedureQuery.columnNameCapitalization";
 
     /**
-     * @since 3.0
-     */
-    public static final String UPPERCASE_COLUMN_NAMES = "upper";
-
-    /**
-     * @since 3.0
-     */
-    public static final String LOWERCASE_COLUMN_NAMES = "lower";
-    /**
      * @since 1.2
      */
     protected String resultEntityName;
@@ -78,7 +67,7 @@
      * @since 1.2
      */
     protected Class<?> resultClass;
-    protected String columnNamesCapitalization;
+    protected CapsStrategy columnNamesCapitalization;
 
     protected Map<String, Object> parameters = new HashMap<String, Object>();
 
@@ -230,9 +219,11 @@
         Object columnNamesCapitalization = properties
                 .get(COLUMN_NAME_CAPITALIZATION_PROPERTY);
         this.columnNamesCapitalization = (columnNamesCapitalization != null)
-                ? columnNamesCapitalization.toString()
+                ? CapsStrategy.valueOf(columnNamesCapitalization
+                        .toString()
+                        .toUpperCase())
                 : null;
-                
+
         metaData.initWithProperties(properties);
     }
 
@@ -271,14 +262,14 @@
 
         encoder.println("\">");
         encoder.indent(1);
-        
+
         metaData.encodeAsXML(encoder);
-        if (getColumnNamesCapitalization() != null) {
+        if (getColumnNamesCapitalization() != CapsStrategy.DEFAULT) {
             encoder.printProperty(
                     COLUMN_NAME_CAPITALIZATION_PROPERTY,
-                    getColumnNamesCapitalization());
+                    getColumnNamesCapitalization().name());
         }
-        
+
         encoder.indent(-1);
         encoder.println("</query>");
     }
@@ -357,7 +348,7 @@
     public void setFetchLimit(int fetchLimit) {
         this.metaData.setFetchLimit(fetchLimit);
     }
-    
+
     /**
      * @since 3.0
      */
@@ -390,8 +381,8 @@
 
     /**
      * @deprecated since 3.0. With introduction of the cache strategies this setting is
-     *            redundant, although it is still being taken into account. It will be
-     *            removed in the later versions of Cayenne.
+     *             redundant, although it is still being taken into account. It will be
+     *             removed in the later versions of Cayenne.
      */
     public boolean isRefreshingObjects() {
         return metaData.isRefreshingObjects();
@@ -399,8 +390,8 @@
 
     /**
      * @deprecated since 3.0. With introduction of the cache strategies this setting is
-     *            redundant, although it is still being taken into account. It will be
-     *            removed in the later versions of Cayenne.
+     *             redundant, although it is still being taken into account. It will be
+     *             removed in the later versions of Cayenne.
      */
     public void setRefreshingObjects(boolean flag) {
         // noop
@@ -524,12 +515,20 @@
     public void setResultEntityName(String resultEntityName) {
         this.resultEntityName = resultEntityName;
     }
-    
-    public String getColumnNamesCapitalization() {
-        return columnNamesCapitalization;
+
+    /**
+     * @since 3.0
+     */
+    public CapsStrategy getColumnNamesCapitalization() {
+        return columnNamesCapitalization != null
+                ? columnNamesCapitalization
+                : CapsStrategy.DEFAULT;
     }
-    
-    public void setColumnNamesCapitalization(String columnNameCapitalization) {
+
+    /**
+     * @since 3.0
+     */
+    public void setColumnNamesCapitalization(CapsStrategy columnNameCapitalization) {
         this.columnNamesCapitalization = columnNameCapitalization;
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/query/SQLTemplate.java
Mon Jan 26 15:11:53 2009
@@ -74,16 +74,6 @@
 
     static final String COLUMN_NAME_CAPITALIZATION_PROPERTY = "cayenne.SQLTemplate.columnNameCapitalization";
 
-    /**
-     * @since 3.0
-     */
-    public static final String UPPERCASE_COLUMN_NAMES = "upper";
-
-    /**
-     * @since 3.0
-     */
-    public static final String LOWERCASE_COLUMN_NAMES = "lower";
-
     private static final Transformer nullMapTransformer = new Transformer() {
 
         public Object transform(Object input) {
@@ -94,7 +84,7 @@
     protected String defaultTemplate;
     protected Map<String, String> templates;
     protected Map<String, ?>[] parameters;
-    protected String columnNamesCapitalization;
+    protected CapsStrategy columnNamesCapitalization;
     protected SQLResult result;
 
     SQLTemplateMetadata metaData = new SQLTemplateMetadata();
@@ -220,10 +210,10 @@
 
         metaData.encodeAsXML(encoder);
 
-        if (getColumnNamesCapitalization() != null) {
+        if (getColumnNamesCapitalization() != CapsStrategy.DEFAULT) {
             encoder.printProperty(
                     COLUMN_NAME_CAPITALIZATION_PROPERTY,
-                    getColumnNamesCapitalization());
+                    getColumnNamesCapitalization().name());
         }
 
         // encode default SQL
@@ -274,7 +264,9 @@
         Object columnNamesCapitalization = properties
                 .get(COLUMN_NAME_CAPITALIZATION_PROPERTY);
         this.columnNamesCapitalization = (columnNamesCapitalization != null)
-                ? columnNamesCapitalization.toString()
+                ? CapsStrategy.valueOf(columnNamesCapitalization
+                        .toString()
+                        .toUpperCase())
                 : null;
     }
 
@@ -591,8 +583,10 @@
      * 
      * @since 3.0
      */
-    public String getColumnNamesCapitalization() {
-        return columnNamesCapitalization;
+    public CapsStrategy getColumnNamesCapitalization() {
+        return columnNamesCapitalization != null
+                ? columnNamesCapitalization
+                : CapsStrategy.DEFAULT;
     }
 
     /**
@@ -605,11 +599,9 @@
      * Note that while a non-default setting is useful for queries that do not rely on a
      * #result directive to describe columns, it works for all SQLTemplates the same way.
      * 
-     * @param columnNameCapitalization Can be null of one of
-     *            {@link #LOWERCASE_COLUMN_NAMES} or {@link #UPPERCASE_COLUMN_NAMES}.
      * @since 3.0
      */
-    public void setColumnNamesCapitalization(String columnNameCapitalization) {
+    public void setColumnNamesCapitalization(CapsStrategy columnNameCapitalization) {
         this.columnNamesCapitalization = columnNameCapitalization;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataObjectUtilsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataObjectUtilsTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataObjectUtilsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/DataObjectUtilsTest.java
Mon Jan 26 15:11:53 2009
@@ -33,6 +33,7 @@
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.SQLResult;
 import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.ObjectIdQuery;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
@@ -58,7 +59,7 @@
         SQLTemplate query = new SQLTemplate(map, sql);
         query.setTemplate(FrontBaseAdapter.class.getName(), "SELECT COUNT(ARTIST_ID) AS X
FROM ARTIST");
         query.setTemplate(OpenBaseAdapter.class.getName(), "SELECT COUNT(ARTIST_ID) AS X
FROM ARTIST");
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
         SQLResult rsMap = new SQLResult();
         rsMap.addColumnResult("X");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextExtendedTypeOperationsTest.java
Mon Jan 26 15:11:53 2009
@@ -24,6 +24,7 @@
 import org.apache.art.StringET1;
 import org.apache.cayenne.exp.Expression;
 import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneCase;
@@ -45,7 +46,7 @@
                 ExtendedTypeEntity.class,
                 "SELECT * FROM EXTENDED_TYPE_TEST WHERE NAME = 'X'");
         checkQ.setFetchingDataRows(true);
-        checkQ.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        checkQ.setColumnNamesCapitalization(CapsStrategy.UPPER);
         assertEquals(1, e1.getObjectContext().performQuery(checkQ).size());
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextProcedureQueryTest.java
Mon Jan 26 15:11:53 2009
@@ -32,6 +32,7 @@
 import org.apache.cayenne.DataRow;
 import org.apache.cayenne.access.jdbc.ColumnDescriptor;
 import org.apache.cayenne.map.Procedure;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.ProcedureQuery;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneCase;
@@ -267,13 +268,13 @@
         createArtist(1000.0);
         ProcedureQuery q = new ProcedureQuery(SELECT_STORED_PROCEDURE);
         
-        q.setColumnNamesCapitalization(ProcedureQuery.LOWERCASE_COLUMN_NAMES);
+        q.setColumnNamesCapitalization(CapsStrategy.LOWER);
         q.addParameter("aName", "An Artist");
         List<DataRow> artists = runProcedureSelect(q);
         
         ProcedureQuery q1 = new ProcedureQuery(SELECT_STORED_PROCEDURE);
         
-        q1.setColumnNamesCapitalization(ProcedureQuery.UPPERCASE_COLUMN_NAMES);
+        q1.setColumnNamesCapitalization(CapsStrategy.UPPER);
         q1.addParameter("aName", "An Artist");
         List<DataRow> artists1 = runProcedureSelect(q1);
         

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DataContextSQLTemplateTest.java
Mon Jan 26 15:11:53 2009
@@ -36,6 +36,7 @@
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.map.EntityResult;
 import org.apache.cayenne.map.SQLResult;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.unit.CayenneCase;
 
@@ -62,7 +63,7 @@
 
         DataMap map = getDomain().getMap("testmap");
         SQLTemplate query = new SQLTemplate(map, sql);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
         EntityResult artistResult = new EntityResult(Artist.class);
         artistResult.addDbField(Artist.ARTIST_ID_PK_COLUMN, "X");
@@ -108,7 +109,7 @@
         query.setTemplate(
                 OpenBaseAdapter.class.getName(),
                 "SELECT COUNT(ARTIST_ID) X FROM ARTIST");
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
         SQLResult rsMap = new SQLResult();
         rsMap.addColumnResult("X");
@@ -135,7 +136,7 @@
         query.setTemplate(
                 OpenBaseAdapter.class.getName(),
                 "SELECT COUNT(ARTIST_ID) X, 77 Y FROM ARTIST GROUP BY 77");
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
         SQLResult rsMap = new SQLResult();
         rsMap.addColumnResult("X");
@@ -160,7 +161,7 @@
 
         String template = "SELECT * FROM ARTIST ORDER BY ARTIST_ID";
         SQLTemplate query = new SQLTemplate(Artist.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.LOWERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.LOWER);
         query.setFetchingDataRows(true);
 
         List rows = context.performQuery(query);
@@ -173,7 +174,7 @@
         assertFalse(row2.containsKey("ARTIST_ID"));
         assertTrue(row2.containsKey("artist_id"));
 
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
         List rowsUpper = context.performQuery(query);
 
@@ -235,7 +236,7 @@
         String template = "SELECT * FROM PAINTING "
                 + "WHERE #bindObjectEqual($a) ORDER BY PAINTING_ID";
         SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", a));
 
         List objects = context.performQuery(query);
@@ -255,7 +256,7 @@
         String template = "SELECT * FROM PAINTING "
                 + "WHERE #bindObjectNotEqual($a) ORDER BY PAINTING_ID";
         SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", a));
 
         List objects = context.performQuery(query);
@@ -278,7 +279,7 @@
         String template = "SELECT * FROM PAINTING t0"
                 + " WHERE #bindObjectEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER
BY PAINTING_ID";
         SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", a));
 
         List objects = context.performQuery(query);
@@ -298,7 +299,7 @@
         String template = "SELECT * FROM PAINTING t0"
                 + " WHERE #bindObjectEqual($a 't0.ARTIST_ID' 'ARTIST_ID' ) ORDER BY PAINTING_ID";
         SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", a));
 
         List objects = context.performQuery(query);
@@ -316,7 +317,7 @@
         String template = "SELECT * FROM PAINTING t0"
                 + " WHERE #bindObjectEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER
BY PAINTING_ID";
         SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", null));
 
         List objects = context.performQuery(query);
@@ -336,7 +337,7 @@
         String template = "SELECT * FROM PAINTING t0"
                 + " WHERE #bindObjectNotEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER
BY PAINTING_ID";
         SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", a));
 
         List objects = context.performQuery(query);
@@ -365,7 +366,7 @@
         String template = "SELECT * FROM COMPOUND_FK_TEST t0"
                 + " WHERE #bindObjectEqual($a [ 't0.F_KEY1', 't0.F_KEY2' ] [ 'KEY1', 'KEY2'
] ) ORDER BY PKEY";
         SQLTemplate query = new SQLTemplate(CompoundFkTestEntity.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", a));
 
         List objects = context.performQuery(query);
@@ -392,7 +393,7 @@
         String template = "SELECT * FROM COMPOUND_FK_TEST t0"
                 + " WHERE #bindObjectNotEqual($a [ 't0.F_KEY1', 't0.F_KEY2' ] [ 'KEY1', 'KEY2'
] ) ORDER BY PKEY";
         SQLTemplate query = new SQLTemplate(CompoundFkTestEntity.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", a));
 
         List objects = context.performQuery(query);
@@ -410,7 +411,7 @@
         String template = "SELECT * FROM PAINTING t0"
                 + " WHERE #bindObjectNotEqual($a [ 't0.ARTIST_ID' ] [ 'ARTIST_ID' ] ) ORDER
BY PAINTING_ID";
         SQLTemplate query = new SQLTemplate(Painting.class, template);
-        query.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        query.setColumnNamesCapitalization(CapsStrategy.UPPER);
         query.setParameters(Collections.singletonMap("a", null));
 
         List objects = context.performQuery(query);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/EnumTest.java
Mon Jan 26 15:11:53 2009
@@ -23,6 +23,7 @@
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.ObjectContext;
 import org.apache.cayenne.exp.ExpressionFactory;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
 import org.apache.cayenne.unit.CayenneCase;
@@ -73,7 +74,7 @@
         SQLTemplate q = new SQLTemplate(
                 EnumEntity.class,
                 "SELECT * FROM ENUM_ENTITY WHERE ENUM_ATTRIBUTE = 'one'");
-        q.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        q.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
         EnumEntity e = (EnumEntity) DataObjectUtils.objectForQuery(context, q);
         assertNotNull(e);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/MapLoaderLoadTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/MapLoaderLoadTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/MapLoaderLoadTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/map/MapLoaderLoadTest.java
Mon Jan 26 15:11:53 2009
@@ -30,6 +30,7 @@
 import org.apache.art.Artist;
 import org.apache.art.Gallery;
 import org.apache.cayenne.query.EJBQLQuery;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.Ordering;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.query.SelectQuery;
@@ -160,7 +161,7 @@
         SQLTemplate nonSelectingQuery = (SQLTemplate) map.getQuery("NonSelectingQuery");
         assertNotNull(nonSelectingQuery);
         assertEquals("NonSelectingQuery", nonSelectingQuery.getName());
-        assertEquals(SQLTemplate.UPPERCASE_COLUMN_NAMES, nonSelectingQuery.getColumnNamesCapitalization());
+        assertEquals(CapsStrategy.UPPER, nonSelectingQuery.getColumnNamesCapitalization());
         
         EJBQLQuery ejbqlQueryTest = (EJBQLQuery) map.getQuery("EjbqlQueryTest");      
         assertNotNull(ejbqlQueryTest);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/ProcedureQueryTest.java
Mon Jan 26 15:11:53 2009
@@ -40,11 +40,11 @@
 
     public void testColumnNameCapitalization() {
         ProcedureQuery q1 = new ProcedureQuery();
-        assertNull(q1.getColumnNamesCapitalization());
-        q1.setColumnNamesCapitalization(ProcedureQuery.UPPERCASE_COLUMN_NAMES);
-        assertEquals(ProcedureQuery.UPPERCASE_COLUMN_NAMES, q1.getColumnNamesCapitalization());
+        assertSame(CapsStrategy.DEFAULT, q1.getColumnNamesCapitalization());
+        q1.setColumnNamesCapitalization(CapsStrategy.UPPER);
+        assertEquals(CapsStrategy.UPPER, q1.getColumnNamesCapitalization());
     }
-    
+
     public void testCreateQueryWithParameters() {
         Map params = new HashMap();
         params.put("a", "1");

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/query/SQLTemplateTest.java
Mon Jan 26 15:11:53 2009
@@ -36,9 +36,9 @@
     
     public void testColumnNameCapitalization() {
         SQLTemplate q1 = new SQLTemplate("E1", "SELECT");
-        assertNull(q1.getColumnNamesCapitalization());
-        q1.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
-        assertEquals(SQLTemplate.UPPERCASE_COLUMN_NAMES, q1.getColumnNamesCapitalization());
+        assertSame(CapsStrategy.DEFAULT, q1.getColumnNamesCapitalization());
+        q1.setColumnNamesCapitalization(CapsStrategy.UPPER);
+        assertEquals(CapsStrategy.UPPER, q1.getColumnNamesCapitalization());
     }
 
     public void testQueryWithParameters() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_1125Test.java
Mon Jan 26 15:11:53 2009
@@ -27,6 +27,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.unit.CayenneCase;
 import org.apache.cayenne.unit.MySQLStackAdapter;
@@ -93,7 +94,7 @@
             context.performGenericQuery(insert);
 
             SQLTemplate select = new SQLTemplate(Artist.class, "SELECT * FROM ARTIST");
-            select.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+            select.setColumnNamesCapitalization(CapsStrategy.UPPER);
 
             List<Artist> results = context.performQuery(select);
             assertEquals(1, results.size());

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_901Test.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_901Test.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_901Test.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/unit/jira/CAY_901Test.java
Mon Jan 26 15:11:53 2009
@@ -25,6 +25,7 @@
 import org.apache.art.Painting;
 import org.apache.cayenne.DataObjectUtils;
 import org.apache.cayenne.ObjectContext;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.unit.CayenneCase;
 
@@ -54,7 +55,7 @@
         context.commitChanges();
 
         SQLTemplate q = new SQLTemplate(Painting.class, "SELECT * from PAINTING");
-        q.setColumnNamesCapitalization(SQLTemplate.UPPERCASE_COLUMN_NAMES);
+        q.setColumnNamesCapitalization(CapsStrategy.UPPER);
         q.setFetchingDataRows(true);
         
         Map row = (Map) DataObjectUtils.objectForQuery(context, q);

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateMainTab.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateMainTab.java?rev=737709&r1=737708&r2=737709&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateMainTab.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/SQLTemplateMainTab.java
Mon Jan 26 15:11:53 2009
@@ -40,6 +40,7 @@
 import org.apache.cayenne.modeler.util.CayenneWidgetFactory;
 import org.apache.cayenne.modeler.util.ProjectUtil;
 import org.apache.cayenne.modeler.util.TextAdapter;
+import org.apache.cayenne.query.CapsStrategy;
 import org.apache.cayenne.query.Query;
 import org.apache.cayenne.query.SQLTemplate;
 import org.apache.cayenne.util.Util;
@@ -60,16 +61,17 @@
     private static final String LOWER_CAPS_LABEL = "Force Lower Case";
     private static final String UPPER_CAPS_LABEL = "Force Upper Case";
 
-    private static final String[] LABEL_CAPITALIZATION = {
-            null, SQLTemplate.LOWERCASE_COLUMN_NAMES, SQLTemplate.UPPERCASE_COLUMN_NAMES
+    private static final CapsStrategy[] LABEL_CAPITALIZATION = {
+            CapsStrategy.DEFAULT, CapsStrategy.LOWER,
+            CapsStrategy.UPPER
     };
 
-    private static final Map labelCapsLabels = new HashMap();
+    private static final Map<CapsStrategy, String> labelCapsLabels = new HashMap<CapsStrategy,
String>();
 
     static {
-        labelCapsLabels.put(null, DEFAULT_CAPS_LABEL);
-        labelCapsLabels.put(SQLTemplate.LOWERCASE_COLUMN_NAMES, LOWER_CAPS_LABEL);
-        labelCapsLabels.put(SQLTemplate.UPPERCASE_COLUMN_NAMES, UPPER_CAPS_LABEL);
+        labelCapsLabels.put(CapsStrategy.DEFAULT, DEFAULT_CAPS_LABEL);
+        labelCapsLabels.put(CapsStrategy.LOWER, LOWER_CAPS_LABEL);
+        labelCapsLabels.put(CapsStrategy.UPPER, UPPER_CAPS_LABEL);
     }
 
     protected ProjectController mediator;
@@ -216,7 +218,7 @@
         protected PanelBuilder createPanelBuilder() {
             labelCase = CayenneWidgetFactory.createComboBox();
             labelCase.setRenderer(new LabelCapsRenderer());
-            
+
             labelCase.addActionListener(new ActionListener() {
 
                 public void actionPerformed(ActionEvent event) {
@@ -247,12 +249,7 @@
                 DefaultComboBoxModel labelCaseModel = new DefaultComboBoxModel(
                         LABEL_CAPITALIZATION);
 
-                String capitalization = template.getColumnNamesCapitalization();
-                if (capitalization == null) {
-                    capitalization = LABEL_CAPITALIZATION[0];
-                }
-
-                labelCaseModel.setSelectedItem(capitalization);
+                labelCaseModel.setSelectedItem(template.getColumnNamesCapitalization());
                 labelCase.setModel(labelCaseModel);
             }
         }



Mime
View raw message