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/java/org/apache/torque/engine/database/model Domain.java
Date Wed, 03 Dec 2003 16:41:38 GMT
mpoeschl    2003/12/03 08:41:38

  Modified:    src/generator/src/java/org/apache/torque/engine/database/transform
                        XmlToAppData.java
               src/generator/src/java/org/apache/torque/engine/database/model
                        Domain.java
  Log:
  load platform specific sql type
  
  Revision  Changes    Path
  1.13      +2 -2      db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java
  
  Index: XmlToAppData.java
  ===================================================================
  RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XmlToAppData.java	3 Dec 2003 15:00:28 -0000	1.12
  +++ XmlToAppData.java	3 Dec 2003 16:41:38 -0000	1.13
  @@ -292,7 +292,7 @@
               else if (rawName.equals("domain"))
               {
                   Domain domain = new Domain();
  -                domain.loadFromXML(attributes);
  +                domain.loadFromXML(attributes, database.getPlatform());
                   database.addDomain(domain);
               }
               else if (rawName.equals("table"))
  
  
  
  1.5       +35 -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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Domain.java	25 Nov 2003 19:19:06 -0000	1.4
  +++ Domain.java	3 Dec 2003 16:41:38 -0000	1.5
  @@ -55,6 +55,7 @@
    */
   
   import org.apache.commons.lang.StringUtils;
  +import org.apache.torque.engine.platform.Platform;
   import org.xml.sax.Attributes;
   
   /**
  @@ -73,7 +74,6 @@
       private SchemaType torqueType;
       private String sqlType;
       private String defaultValue;
  -
       
       /**
        * Creates a new instance with a <code>null</code> name.
  @@ -138,6 +138,11 @@
       
       public Domain(Domain domain)
       {
  +        copy(domain);
  +    }
  +    
  +    public void copy(Domain domain)
  +    {
           this.defaultValue = domain.getDefaultValue();
           this.description = domain.getDescription();
           this.name = domain.getName();
  @@ -150,8 +155,10 @@
       /**
        * Imports a column from an XML specification
        */
  -    public void loadFromXML(Attributes attrib)
  +    public void loadFromXML(Attributes attrib, Platform platform)
       {
  +        SchemaType schemaType = SchemaType.getEnum(attrib.getValue("type"));
  +        copy(platform.getDomainForSchemaType(schemaType));
           //Name
           name = attrib.getValue("name");
           //Default column value.
  @@ -159,8 +166,6 @@
           size = attrib.getValue("size");
           scale = attrib.getValue("scale");
   
  -        setType(attrib.getValue("type"));
  -
           description = attrib.getValue("description");
       }
   
  @@ -292,6 +297,30 @@
       }
   
       /**
  +     * Return a string that will give this column a default value.
  +     * <p>
  +     * TODO: Properly SQL-escape text values.
  +     */
  +    public String getDefaultSetting()
  +    {
  +        StringBuffer dflt = new StringBuffer(0);
  +        if (getDefaultValue() != null)
  +        {
  +            dflt.append("default ");
  +            if (TypeMap.isTextType(getType()))
  +            {
  +                // TODO: Properly SQL-escape the text.
  +                dflt.append('\'').append(getDefaultValue()).append('\'');
  +            }
  +            else
  +            {
  +                dflt.append(getDefaultValue());
  +            }
  +        }
  +        return dflt.toString();
  +    } 
  +     
  +    /**
        * @param defaultValue The defaultValue to set.
        */
       public void setDefaultValue(String defaultValue)
  @@ -346,5 +375,5 @@
               return "";
           }
       }
  -    
  +
   }
  
  
  

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