You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by mp...@apache.org on 2003/12/03 17:41:38 UTC
cvs commit: db-torque/src/generator/src/java/org/apache/torque/engine/database/model Domain.java
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