cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/transformation SQLTransformer.java
Date Sat, 06 Mar 2004 02:05:27 GMT
joerg       2004/03/05 18:05:27

  Modified:    .        status.xml
               src/blocks/databases/java/org/apache/cocoon/transformation
                        SQLTransformer.java
  Log:
  bug 22400: added additional property <column-case> to the SQLTransformer with the
possible values "preserve", "uppercase", and "lowercase".
  
  Revision  Changes    Path
  1.259     +5 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.258
  retrieving revision 1.259
  diff -u -r1.258 -r1.259
  --- status.xml	5 Mar 2004 02:24:26 -0000	1.258
  +++ status.xml	6 Mar 2004 02:05:27 -0000	1.259
  @@ -196,6 +196,10 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="JH" type="add" fixes-bug="22400" due-to="Steve Krulewitz" due-to-email="skrul@yahoo.com">
  +     Added additional property &lt;column-case&gt; to the SQLTransformer with
  +     the possible values "preserve", "uppercase", and "lowercase".
  +   </action>
      <action dev="JH" type="fix" fixes-bug="27254" due-to="Georg Ragaller" due-to-email="georg.ragaller@nse.de">
        Fixed path separator handling in cocoon.bat/.sh and Loader.java.
      </action>
  
  
  
  1.16      +28 -8     cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java
  
  Index: SQLTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/databases/java/org/apache/cocoon/transformation/SQLTransformer.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SQLTransformer.java	5 Mar 2004 13:01:55 -0000	1.15
  +++ SQLTransformer.java	6 Mar 2004 02:05:27 -0000	1.16
  @@ -87,6 +87,7 @@
       public static final String MAGIC_NR_OF_ROWS = "show-nr-of-rows";
       public static final String MAGIC_QUERY = "query";
       public static final String MAGIC_VALUE = "value";
  +    public static final String MAGIC_COLUMN_CASE = "column-case";
       public static final String MAGIC_DOC_ELEMENT = "doc-element";
       public static final String MAGIC_ROW_ELEMENT = "row-element";
       public static final String MAGIC_IN_PARAMETER = "in-parameter";
  @@ -110,7 +111,7 @@
       public static final String MAGIC_NAME_ATTRIBUTE = "name";
       public static final String MAGIC_STORED_PROCEDURE_ATTRIBUTE = "isstoredprocedure";
       public static final String MAGIC_UPDATE_ATTRIBUTE = "isupdate";
  -	  public static final String CLOB_ENCODING = "clob-encoding";
  +    public static final String CLOB_ENCODING = "clob-encoding";
   
       /** The states we are allowed to be in **/
       protected static final int STATE_OUTSIDE = 0;
  @@ -878,6 +879,9 @@
           /** Mapping out parameters - objectModel **/
           protected HashMap outParametersNames = null;
   
  +        /** Handling of case of column names in results */
  +        protected String columnCase; 
  +
           protected Query( SQLTransformer transformer, int query_index ) {
               this.transformer = transformer;
               this.query_index = query_index;
  @@ -1046,7 +1050,7 @@
   
               this.rowset_name = properties.getParameter( SQLTransformer.MAGIC_DOC_ELEMENT,
"rowset" );
               this.row_name = properties.getParameter( SQLTransformer.MAGIC_ROW_ELEMENT,
"row" );
  -
  +            this.columnCase = properties.getParameter(SQLTransformer.MAGIC_COLUMN_CASE,
"lowercase");
               Enumeration enum = query_parts.elements();
               StringBuffer sb = new StringBuffer();
               while ( enum.hasMoreElements() ) {
  @@ -1265,9 +1269,10 @@
               AttributesImpl attr = new AttributesImpl();
               if ( !isupdate && !isstoredprocedure ) {
                   for ( int i = 1; i <= md.getColumnCount(); i++ ) {
  -                    transformer.start( md.getColumnName( i ).toLowerCase(), attr );
  -                    this.serializeData(manager, getColumnValue( i ) );
  -                    transformer.end( md.getColumnName( i ).toLowerCase() );
  +                    String columnName = getColumnName(md.getColumnName(i));
  +                    transformer.start(columnName, attr);
  +                    this.serializeData(manager, getColumnValue(i));
  +                    transformer.end(columnName);
                   }
               } else if ( isupdate && !isstoredprocedure ) {
                   transformer.start( "returncode", attr );
  @@ -1304,13 +1309,14 @@
                                   while ( rs.next() ) {
                                       transformer.start( this.row_name, attr );
                                       for ( int i = 1; i <= md.getColumnCount(); i++ )
{
  -                                        transformer.start( md.getColumnName( i ).toLowerCase(),
attr );
  +                                        String columnName = getColumnName(md.getColumnName(i));
  +                                        transformer.start(columnName, attr);
                                           if ( md.getColumnType( i ) == 8 ) {  //prevent
nasty exponent notation
                                               this.serializeData(manager, SQLTransformer.getStringValue(
rs.getBigDecimal( i ) ));
                                           } else {
                                               this.serializeData(manager, SQLTransformer.getStringValue(
rs.getObject( i ) ));
                                           }
  -                                        transformer.end( md.getColumnName( i ).toLowerCase()
);
  +                                        transformer.end(columnName);
                                       }
                                       transformer.end( this.row_name );
                                   }
  @@ -1328,6 +1334,20 @@
               } finally {
                   //close();
               }
  +        }
  +
  +        private String getColumnName(String tempColumnName) {
  +            if (this.columnCase.equals("lowercase")) {
  +                tempColumnName = tempColumnName.toLowerCase();
  +            } else if (this.columnCase.equals("uppercase")) {
  +                tempColumnName = tempColumnName.toUpperCase();
  +            } else if (this.columnCase.equals("preserve")) {
  +                // do nothing
  +            } else {
  +                getTheLogger().warn("[" + this.columnCase + "] is not a valid value for
<column-case>. "
  +                                    + "Column name retrieved from database will be used.");
  +            }
  +            return tempColumnName;
           }
       }
   
  
  
  

Mime
View raw message