db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: db-torque/src/generator/src/test/org/apache/torque/engine/database/model DomainTest.java
Date Sun, 16 Nov 2003 20:16:55 GMT
mpoeschl    2003/11/16 12:16:55

  Modified:    src/generator/src/java/org/apache/torque/engine/platform
                        PlatformPostgresqlImpl.java
                        PlatformHypersonicImpl.java PlatformMysqlImpl.java
                        PlatformAxionImpl.java PlatformMssqlImpl.java
                        PlatformDb2Impl.java PlatformDefaultImpl.java
                        Platform.java PlatformSapdbImpl.java
                        PlatformInterbaseImpl.java PlatformOracleImpl.java
                        PlatformCloudscapeImpl.java
                        PlatformMsaccessImpl.java PlatformSybaseImpl.java
                        PlatformDb2400Impl.java
               src/generator/src/java/org/apache/torque/engine/database/model
                        Domain.java Column.java
               src/generator/src/test/org/apache/torque/engine/database/model
                        DomainTest.java
  Added:       src/generator/src/test/org/apache/torque/engine/platform
                        PlatformMysqlImplTest.java
  Log:
  extend Platform (add getDomainForSchemaType())
  this will replace the db.props soon ...
  
  Revision  Changes    Path
  1.2       +37 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformPostgresqlImpl.java
  
  Index: PlatformPostgresqlImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformPostgresqlImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformPostgresqlImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformPostgresqlImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,12 +54,48 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * Postgresql Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformPostgresqlImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformPostgresqlImpl()
  +    {
  +        super();
  +        initialize();
  +    }
  +
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.BIT, "boolean"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TINYINT, "int2"));
  +        setSchemaDomainMapping(new Domain(SchemaType.SMALLINT, "int2"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BIGINT, "int8"));
  +        setSchemaDomainMapping(new Domain(SchemaType.REAL, "float"));
  +        // TODO check this .. just copied from db.props
  +        setSchemaDomainMapping(new Domain(SchemaType.BOOLEANCHAR, "char"));
  +        // TODO check this .. just copied from db.props
  +        setSchemaDomainMapping(new Domain(SchemaType.BOOLEANINT, "int2"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "double precision"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "text"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BINARY, "bytea"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "bytea"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "bytea"));
  +        setSchemaDomainMapping(new Domain(SchemaType.CLOB, "text"));
  +    }
  +    
       /**
        * @see Platform#getNativeIdMethod()
        */
  
  
  
  1.2       +23 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformHypersonicImpl.java
  
  Index: PlatformHypersonicImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformHypersonicImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformHypersonicImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformHypersonicImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,11 +54,33 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * Hypersonic Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformHypersonicImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformHypersonicImpl()
  +    {
  +        super();
  +        initialize();
  +    }
   
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.CHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BINARY"));
  +    }
   }
  
  
  
  1.2       +29 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMysqlImpl.java
  
  Index: PlatformMysqlImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMysqlImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformMysqlImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformMysqlImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,11 +54,39 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * MySql Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformMysqlImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformMysqlImpl()
  +    {
  +        super();
  +        initialize();
  +    }
   
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.NUMERIC, "DECIMAL"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "MEDIUMTEXT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DATE, "DATETIME"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BINARY, "BLOB"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "MEDIUMBLOB"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONGBLOB"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BLOB, "LONGBLOB"));
  +        setSchemaDomainMapping(new Domain(SchemaType.CLOB, "LONGTEXT"));
  +    }
  +    
   }
  
  
  
  1.2       +24 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformAxionImpl.java
  
  Index: PlatformAxionImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformAxionImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformAxionImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformAxionImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,11 +54,34 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * Axion Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformAxionImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformAxionImpl()
  +    {
  +        super();
  +        initialize();
  +    }
   
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.DECIMAL, "INTEGER"));
  +        setSchemaDomainMapping(new Domain(SchemaType.CHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BINARY"));
  +    }
   }
  
  
  
  1.2       +31 -2     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMssqlImpl.java
  
  Index: PlatformMssqlImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMssqlImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformMssqlImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformMssqlImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,18 +54,47 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * MS SQL Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformMssqlImpl extends PlatformDefaultImpl
   {
       /**
  +     * Default constructor.
  +     */
  +    public PlatformMssqlImpl()
  +    {
  +        super();
  +        initialize();
  +    }
  +
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.INTEGER, "INT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "FLOAT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "TEXT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DATE, "DATETIME"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TIME, "DATETIME"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TIMESTAMP, "DATETIME"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BINARY, "BINARY(7132)"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "IMAGE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "IMAGE"));      
  +    }
  +    
  +    /**
        * @see Platform#getMaxColumnNameLength()
        */
       public int getMaxColumnNameLength()
       {
           return 30;
       }
  -
   }
  
  
  
  1.2       +26 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDb2Impl.java
  
  Index: PlatformDb2Impl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDb2Impl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformDb2Impl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformDb2Impl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,12 +54,37 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * DB2 Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformDb2Impl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformDb2Impl()
  +    {
  +        super();
  +        initialize();
  +    }
  +
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.CHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BINARY, "CHAR(n) FOR BIT DATA"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "VARCHAR(n) FOR BIT DATA"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG VARCHAR FOR BIT
DATA"));
  +    }
   
       /**
        * @see Platform#getMaxColumnNameLength()
  
  
  
  1.2       +43 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDefaultImpl.java
  
  Index: PlatformDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDefaultImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformDefaultImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformDefaultImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,6 +54,15 @@
    * <http://www.apache.org/>.
    */
   
  +import java.util.Hashtable;
  +import java.util.Iterator;
  +import java.util.Map;
  +
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
  +
  +
   /**
    * Default implementation for the Platform interface.
    *
  @@ -62,7 +71,32 @@
    */
   public class PlatformDefaultImpl implements Platform
   {
  +    private Map schemaDomainMap;
  +    
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformDefaultImpl() 
  +    {
  +        initialize();
  +    }
  +    
  +    private void initialize()
  +    {
  +        schemaDomainMap = new Hashtable(30);
  +        Iterator iter = SchemaType.iterator();
  +        while (iter.hasNext()) 
  +        {
  +            SchemaType type = (SchemaType) iter.next();
  +            schemaDomainMap.put(type, new Domain(type));
  +        }
  +    }
   
  +    protected void setSchemaDomainMapping(Domain domain) 
  +    {
  +        schemaDomainMap.put(domain.getType(), domain);
  +    }
  +    
       /**
        * @see Platform#getMaxColumnNameLength()
        */
  @@ -77,6 +111,14 @@
       public String getNativeIdMethod()
       {
           return "identity";
  +    }
  +
  +    /**
  +     * @see Platform#getDomainForJdbcType(SchemaType)
  +     */
  +    public Domain getDomainForSchemaType(SchemaType jdbcType) 
  +    {
  +        return (Domain) schemaDomainMap.get(jdbcType);
       }
   
   }
  
  
  
  1.2       +12 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/Platform.java
  
  Index: Platform.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/Platform.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Platform.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ Platform.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,6 +54,9 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
    * Interface for RDBMS platform specific behaviour.
    *
  @@ -75,4 +78,12 @@
        * @return the max column length
        */
       int getMaxColumnNameLength();
  +
  +    /**
  +     * Returns the db specific domain for a jdbcType.
  +     *
  +     * @param jdbcType the jdbcType name
  +     * @return the db specific domain
  +     */
  +    Domain getDomainForSchemaType(SchemaType jdbcType);
   }
  
  
  
  1.2       +36 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformSapdbImpl.java
  
  Index: PlatformSapdbImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformSapdbImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformSapdbImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformSapdbImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,12 +54,47 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * SAP DB Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformSapdbImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformSapdbImpl()
  +    {
  +        super();
  +        initialize();
  +    }
  +
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.BIT, "FIXED", "1", "0"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TINYINT, "CHAR BYTE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BIGINT, "FIXED", "38", "0"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "DOUBLE PRECISION"));
  +        setSchemaDomainMapping(new Domain(SchemaType.NUMERIC, "DECIMAL"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BINARY, "CHAR(254) BYTE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "LONG BYTE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG BYTE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.JAVA_OBJECT, "LONG BYTE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BLOB, "LONG BYTE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.CLOB, "LONG UNICODE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BOOLEANINT, "SMALLINT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BOOLEANCHAR, "CHAR"));
  +    }
  +
       /**
        * @see Platform#getNativeIdMethod()
        */
  
  
  
  1.2       +23 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformInterbaseImpl.java
  
  Index: PlatformInterbaseImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformInterbaseImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformInterbaseImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformInterbaseImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,11 +54,33 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * Interbase Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformInterbaseImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformInterbaseImpl()
  +    {
  +        super();
  +        initialize();
  +    }
   
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.CHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BLOB"));
  +    }
   }
  
  
  
  1.2       +37 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformOracleImpl.java
  
  Index: PlatformOracleImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformOracleImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformOracleImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformOracleImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,12 +54,48 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * Oracle Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformOracleImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformOracleImpl()
  +    {
  +        super();
  +        initialize();
  +    }
  +
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.BIT, "NUMBER", "1", "0"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TINYINT, "NUMBER", "3", "0"));
  +        setSchemaDomainMapping(new Domain(SchemaType.SMALLINT, "NUMBER", "5", "0"));
  +        setSchemaDomainMapping(new Domain(SchemaType.INTEGER, "NUMBER"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BIGINT, "NUMBER", "20", "0"));
  +        setSchemaDomainMapping(new Domain(SchemaType.REAL, "NUMBER"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "FLOAT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DECIMAL, "NUMBER"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARCHAR, "VARCHAR2"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR2", "2000"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TIME, "DATE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TIMESTAMP, "DATE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BINARY, "LONG RAW"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BLOB"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG RAW"));
  +    }
  +    
       /**
        * @see Platform#getMaxColumnNameLength()
        */
  
  
  
  1.2       +28 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformCloudscapeImpl.java
  
  Index: PlatformCloudscapeImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformCloudscapeImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformCloudscapeImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformCloudscapeImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,11 +54,38 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * Cloudscape Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformCloudscapeImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformCloudscapeImpl()
  +    {
  +        super();
  +        initialize();
  +    }
   
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.INTEGER, "INT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BIGINT, "LONGINT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "DOUBLE PRECISION"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.BINARY, "LONG BINARY"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "LONG BINARY"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG VARBINARY"));
  +        setSchemaDomainMapping(new Domain(SchemaType.JAVA_OBJECT, "SERIALIZE"));    
  +    }
   }
  
  
  
  1.2       +24 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMsaccessImpl.java
  
  Index: PlatformMsaccessImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformMsaccessImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformMsaccessImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformMsaccessImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,11 +54,34 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * MS Access Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformMsaccessImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformMsaccessImpl()
  +    {
  +        super();
  +        initialize();
  +    }
   
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.CHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "MEMO"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BINARY"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "BINARY"));
  +    }
   }
  
  
  
  1.2       +30 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformSybaseImpl.java
  
  Index: PlatformSybaseImpl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformSybaseImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformSybaseImpl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformSybaseImpl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,12 +54,41 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * Sybase Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformSybaseImpl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformSybaseImpl()
  +    {
  +        super();
  +        initialize();
  +    }
  +
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.INTEGER, "INT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "FLOAT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "TEXT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DATE, "DATETIME"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TIME, "TIMESTAMP"));
  +        setSchemaDomainMapping(new Domain(SchemaType.TIMESTAMP, "DATETIME"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "IMAGE"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "IMAGE"));
  +    }
  +    
       /**
        * @see Platform#getMaxColumnNameLength()
        */
  
  
  
  1.2       +30 -1     db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDb2400Impl.java
  
  Index: PlatformDb2400Impl.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/platform/PlatformDb2400Impl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlatformDb2400Impl.java	27 Sep 2003 11:10:15 -0000	1.1
  +++ PlatformDb2400Impl.java	16 Nov 2003 20:16:53 -0000	1.2
  @@ -54,12 +54,41 @@
    * <http://www.apache.org/>.
    */
   
  +import org.apache.torque.engine.database.model.Domain;
  +import org.apache.torque.engine.database.model.SchemaType;
  +
   /**
  + * DB2-AS400 Platform implementation.
  + *
    * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
    * @version $Id$
    */
   public class PlatformDb2400Impl extends PlatformDefaultImpl
   {
  +    /**
  +     * Default constructor.
  +     */
  +    public PlatformDb2400Impl()
  +    {
  +        super();
  +        initialize();
  +    }
  +
  +    /**
  +     * Initializes db specific domain mapping.
  +     */
  +    private void initialize()
  +    {
  +        setSchemaDomainMapping(new Domain(SchemaType.TINYINT, "SMALLINT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.INTEGER, "INT"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "DOUBLE PRECISION"));
  +        setSchemaDomainMapping(new Domain(SchemaType.DECIMAL, "DEC"));
  +        setSchemaDomainMapping(new Domain(SchemaType.CHAR, "VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
  +        setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "VARCHAR (32000) FOR BIT
DATA"));
  +        setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG VARCHAR FOR BIT
DATA"));
  +    }
  +    
       /**
        * @see Platform#getMaxColumnNameLength()
        */
  
  
  
  1.3       +74 -6     db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Domain.java
  
  Index: Domain.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Domain.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Domain.java	30 Oct 2003 17:52:10 -0000	1.2
  +++ Domain.java	16 Nov 2003 20:16:54 -0000	1.3
  @@ -69,7 +69,8 @@
       private String size;
       private String scale;
       /** type as defined in schema.xml */
  -    private String torqueType;
  +    private SchemaType torqueType;
  +    private String sqlType;
       private String defaultValue;
   
       
  @@ -78,11 +79,11 @@
        */
       public Domain()
       {
  -        this(null);
  +        this.name = null;
       }
   
       /**
  -     * Creates a new column and set the name
  +     * Creates a new Domain and set the name
        *
        * @param name column name
        */
  @@ -90,8 +91,51 @@
       {
           this.name = name;
       }
  +    
  +    /**
  +     * Creates a new Domain and set the name
  +     */
  +    public Domain(SchemaType type)
  +    {
  +        this.name = null;
  +        this.torqueType = type;
  +        this.sqlType = type.getName();
  +    }
   
       /**
  +     * Creates a new Domain and set the name
  +     */
  +    public Domain(SchemaType type, String sqlType)
  +    {
  +        this.name = null;
  +        this.torqueType = type;
  +        this.sqlType = sqlType;
  +    }
  +    
  +    /**
  +     * Creates a new Domain and set the name
  +     */
  +    public Domain(SchemaType type, String sqlType, String size, String scale)
  +    {
  +        this.name = null;
  +        this.torqueType = type;
  +        this.sqlType = sqlType;
  +        this.size = size;
  +        this.scale = scale;
  +    }
  +
  +    /**
  +     * Creates a new Domain and set the name
  +     */
  +    public Domain(SchemaType type, String sqlType, String size)
  +    {
  +        this.name = null;
  +        this.torqueType = type;
  +        this.sqlType = sqlType;
  +        this.size = size;
  +    }
  +    
  +    /**
        * Imports a column from an XML specification
        */
       public void loadFromXML(Attributes attrib)
  @@ -175,7 +219,7 @@
       /**
        * @return Returns the torqueType.
        */
  -    public String getType()
  +    public SchemaType getType()
       {
           return torqueType;
       }
  @@ -183,12 +227,20 @@
       /**
        * @param torqueType The torqueType to set.
        */
  -    public void setType(String torqueType)
  +    public void setType(SchemaType torqueType)
       {
           this.torqueType = torqueType;
       }
   
       /**
  +     * @param torqueType The torqueType to set.
  +     */
  +    public void setType(String torqueType)
  +    {
  +        this.torqueType = SchemaType.getEnum(torqueType);
  +    }
  +    
  +    /**
        * @return Returns the defaultValue.
        */
       public String getDefaultValue()
  @@ -202,6 +254,22 @@
       public void setDefaultValue(String defaultValue)
       {
           this.defaultValue = defaultValue;
  +    }
  +
  +    /**
  +     * @return Returns the sqlType.
  +     */
  +    public String getSqlType() 
  +    {
  +        return sqlType;
  +    }
  +
  +    /**
  +     * @param sqlType The sqlType to set.
  +     */
  +    public void setSqlType(String sqlType) 
  +    {
  +        this.sqlType = sqlType;
       }
   
   }
  
  
  
  1.9       +4 -3      db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java
  
  Index: Column.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Column.java	3 Nov 2003 06:37:27 -0000	1.8
  +++ Column.java	16 Nov 2003 20:16:54 -0000	1.9
  @@ -165,11 +165,12 @@
       public void loadFromXML(Attributes attrib)
       {
           String dom = attrib.getValue("domain");
  -        if (StringUtils.isNotEmpty(dom)) {
  +        if (StringUtils.isNotEmpty(dom)) 
  +        {
               Domain domain = getTable().getDatabase().getDomain(dom);
               size = domain.getSize();
               scale = domain.getScale();
  -            setType(domain.getType());
  +            setType(domain.getType().getName());
               defaultValue = domain.getDefaultValue();
           } 
           else
  
  
  
  1.1                  db-torque/src/generator/src/test/org/apache/torque/engine/platform/PlatformMysqlImplTest.java
  
  Index: PlatformMysqlImplTest.java
  ===================================================================
  package org.apache.torque.engine.platform;
  
  import junit.framework.TestCase;
  
  import org.apache.torque.engine.database.model.Domain;
  import org.apache.torque.engine.database.model.SchemaType;
  
  /**
   * @author martin
   */
  public class PlatformMysqlImplTest extends TestCase {
  
      Platform platform;
      
      public void setUp()
      {
          platform = PlatformFactory.getPlatformFor("mysql");
      }
      
      public void testGetMaxColumnNameLength() {
          assertEquals(64, platform.getMaxColumnNameLength());
      }
  
      public void testGetNativeIdMethod() {
          assertEquals("identity", platform.getNativeIdMethod());
      }
  
      public void testGetDomainForJdbcType() {
          Domain numeric = platform.getDomainForSchemaType(SchemaType.NUMERIC);
          assertEquals(SchemaType.NUMERIC, numeric.getType());
          assertEquals("DECIMAL", numeric.getSqlType());
      }
  
  }
  
  
  
  1.3       +3 -2      db-torque/src/generator/src/test/org/apache/torque/engine/database/model/DomainTest.java
  
  Index: DomainTest.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/model/DomainTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DomainTest.java	3 Nov 2003 06:37:27 -0000	1.2
  +++ DomainTest.java	16 Nov 2003 20:16:55 -0000	1.3
  @@ -94,7 +94,7 @@
       public void testAllAttributes() throws Exception
       {
           Domain amount = db.getDomain("amount");
  -        assertEquals("NUMERIC", amount.getType());
  +        assertEquals(SchemaType.NUMERIC, amount.getType());
           assertEquals("10", amount.getSize());
           assertEquals("2", amount.getScale());
           assertEquals("0", amount.getDefaultValue());
  @@ -111,6 +111,7 @@
           assertEquals("VARCHAR", name.getType());
           assertEquals("40", name.getSize());
           Column price = table.getColumn("price");
  +        assertEquals("NUMERIC", price.getTorqueType());
           assertEquals("NUMERIC", price.getType());
           assertEquals("10", price.getSize());
           assertEquals("2", price.getScale());
  
  
  

---------------------------------------------------------------------
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