You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by to...@apache.org on 2006/06/19 00:10:42 UTC

svn commit: r415210 - in /db/ojb/branches/OJB_1_0_RELEASE: build.xml lib/DdlUtils-1.0-dev.jar src/java/org/apache/ojb/broker/ant/DdlUtilsDataHandling.java

Author: tomdz
Date: Sun Jun 18 15:10:41 2006
New Revision: 415210

URL: http://svn.apache.org/viewvc?rev=415210&view=rev
Log:
Updated DdlUtils-DB-Handling so that converters are now used

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/build.xml
    db/ojb/branches/OJB_1_0_RELEASE/lib/DdlUtils-1.0-dev.jar
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/ant/DdlUtilsDataHandling.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/build.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/build.xml?rev=415210&r1=415209&r2=415210&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/build.xml (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/build.xml Sun Jun 18 15:10:41 2006
@@ -420,6 +420,7 @@
                      includes="*schema.xml"/>
 
             <createdatabase failonerror="false"/>
+            <writeschemasqltofile alterdatabase="false" outputfile="${build.test}/ojbtest-schema.sql"/>
             <writeschematodatabase alterdatabase="false"/>
         </ddl2Database>
         <ojbData usedelimitedsqlidentifiers="false"

Modified: db/ojb/branches/OJB_1_0_RELEASE/lib/DdlUtils-1.0-dev.jar
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/lib/DdlUtils-1.0-dev.jar?rev=415210&r1=415209&r2=415210&view=diff
==============================================================================
Binary files - no diff available.

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/ant/DdlUtilsDataHandling.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/ant/DdlUtilsDataHandling.java?rev=415210&r1=415209&r2=415210&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/ant/DdlUtilsDataHandling.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/ant/DdlUtilsDataHandling.java Sun Jun 18 15:10:41 2006
@@ -1,6 +1,6 @@
 package org.apache.ojb.broker.ant;
 
-/* Copyright 2004-2005 The Apache Software Foundation
+/* Copyright 2004-2006 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,8 +28,11 @@
 import org.apache.commons.digester.Rule;
 import org.apache.commons.digester.RuleSetBase;
 import org.apache.ddlutils.Platform;
+import org.apache.ddlutils.io.ConverterConfiguration;
+import org.apache.ddlutils.io.converters.SqlTypeConverter;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
+import org.apache.ddlutils.model.Table;
 import org.apache.ojb.broker.metadata.ClassDescriptor;
 import org.apache.ojb.broker.metadata.DescriptorRepository;
 import org.xml.sax.Attributes;
@@ -39,6 +42,8 @@
 /**
  * Provides data input and output via DdlUtils.
  * 
+ * TODO: It might be useful to extend {@link org.apache.ddlutils.io.DataReader}
+ * 
  * @author Thomas Dudziak
  */
 public class DdlUtilsDataHandling
@@ -61,13 +66,18 @@
             {
                 String attrName  = attributes.getLocalName(idx);
                 String attrValue = attributes.getValue(idx);
+                Table  table     = _preparedModel.getTableFor(name);
                 Column column    = _preparedModel.getColumnFor(name, attrName);
 
                 if (column == null)
                 {
                     throw new DataTaskException("Unknown attribute "+attrName+" of element "+name);
                 }
-                bean.set(column.getName(), attrValue);
+
+                SqlTypeConverter converter = DdlUtilsDataHandling.this._converterConf.getRegisteredConverter(table, column);
+                Object           propValue = (converter != null ? converter.convertFromString(attrValue, column.getTypeCode()) : attrValue);
+
+                bean.set(column.getName(), propValue);
             }
             DdlUtilsDataHandling.this._digester.push(bean);
         }
@@ -103,6 +113,8 @@
     private PreparedModel _preparedModel;
     /** The digester for parsing the XML */
     private Digester _digester;
+    /** The converters. */
+    private ConverterConfiguration _converterConf = new ConverterConfiguration();
 
     /**
      * Creates a new data handling object.



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