db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r910600 [21/29] - in /db/torque/torque4/trunk: maven-torque-gf-plugin/ maven-torque-gf-plugin/src/ maven-torque-gf-plugin/src/main/ maven-torque-gf-plugin/src/main/java/ maven-torque-gf-plugin/src/main/java/org/ maven-torque-gf-plugin/src/m...
Date Tue, 16 Feb 2010 17:16:02 GMT
Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/MapInitDatabaseTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/MapInitDatabaseTransformer.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/MapInitDatabaseTransformer.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/om/mapInit/MapInitDatabaseTransformer.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,79 @@
+package org.apache.torque.templates.transformer.om.mapInit;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.InputStreamReader;
+
+import org.apache.torque.gf.control.ControllerState;
+import org.apache.torque.gf.processor.string.Camelbacker;
+import org.apache.torque.gf.source.SourceElement;
+import org.apache.torque.gf.source.transform.AttributeTransformer;
+import org.apache.torque.gf.source.transform.SourceTransformerException;
+import org.apache.torque.templates.TemplateOptionName;
+import org.apache.torque.templates.TorqueSchemaAttributeName;
+import org.apache.torque.templates.TorqueSchemaElementName;
+import org.apache.torque.templates.transformer.om.DatabaseAttributeName;
+
+public class MapInitDatabaseTransformer  extends AttributeTransformer
+{
+    private static Camelbacker camelbacker = new Camelbacker();
+
+    public MapInitDatabaseTransformer() throws SourceTransformerException
+    {
+        super(new InputStreamReader(
+                MapInitDatabaseTransformer.class
+                   .getResourceAsStream(
+                        "MapInitDatabaseTransformer.properties")));
+    }
+
+    public SourceElement transform(
+            SourceElement databaseElement,
+            ControllerState controllerState)
+        throws SourceTransformerException
+    {
+        if (!TorqueSchemaElementName.DATABASE.getName().equals(
+                databaseElement.getName()))
+        {
+            throw new IllegalArgumentException("Illegal element Name "
+                    + databaseElement.getName());
+        }
+        String name = (String) databaseElement.getAttribute(
+                TorqueSchemaAttributeName.NAME.getName());
+        if (name == null)
+        {
+            throw new SourceTransformerException("The attribute "
+                    + TorqueSchemaAttributeName.NAME.getName()
+                    + " on element "
+                    + databaseElement.getName()
+                    + " is null");
+        }
+        String mapInitClassName
+                = controllerState.getOption(
+                        TemplateOptionName.OM_MAP_INIT_CLASS_NAME_PREFIX)
+                    + camelbacker.process(name)
+                    + controllerState.getOption(
+                        TemplateOptionName.OM_MAP_INIT_CLASS_NAME_SUFFIX);
+        databaseElement.setAttribute(
+                DatabaseAttributeName.MAP_INIT_CLASS_NAME,
+                mapInitClassName);
+        super.transform(databaseElement, controllerState);
+        return databaseElement;
+    }
+ }

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/transformer/sql/SQLTransformer.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,422 @@
+package org.apache.torque.templates.transformer.sql;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.torque.gf.control.ControllerState;
+import org.apache.torque.gf.source.SourceElement;
+import org.apache.torque.gf.source.SourcePath;
+import org.apache.torque.gf.source.transform.SourceTransformer;
+import org.apache.torque.gf.source.transform.SourceTransformerException;
+import org.apache.torque.templates.TemplateOptionName;
+import org.apache.torque.templates.TorqueSchemaAttributeName;
+import org.apache.torque.templates.TorqueSchemaElementName;
+import org.apache.torque.templates.TorqueSchemaIdMethod;
+import org.apache.torque.templates.platform.Platform;
+import org.apache.torque.templates.platform.PlatformFactory;
+import org.apache.torque.templates.transformer.CollectAttributeSetTrueTransformer;
+import org.apache.torque.templates.transformer.SchemaTypeHelper;
+import org.apache.torque.templates.transformer.om.TableChildElementName;
+import org.apache.torque.templates.typemapping.SqlType;
+import org.apache.torque.templates.typemapping.SchemaType;
+import org.apache.torque.templates.typemapping.TypeMap;
+
+/**
+ * Transforms the tables in the OM model.
+ */
+public class SQLTransformer implements SourceTransformer
+{
+    private static final String PRIMARY_KEY_COLUMN_NAMES_ATTRIBUTE
+            = "primaryKeyColumnNames";
+
+    private static final String UNIQUE_COLUMN_NAMES_ATTRIBUTE
+            = "uniqueColumnNames";
+
+    private static final String INDEX_COLUMN_NAMES_ATTRIBUTE
+            = "indexColumnNames";
+
+    private static final String LOCAL_COLUMN_NAMES_ATTRIBUTE
+            = "localColumnNames";
+
+    private static final String FOREIGN_COLUMN_NAMES_ATTRIBUTE
+            = "foreignColumnNames";
+
+    private static final String PRIMARY_KEY_CONSTRAINT_NAME_ATTRIBUTE
+            = "primaryKeyConstraintName";
+
+    private static final String SEQUENCE_NAME_ATTRIBUTE
+            = "sequenceName";
+
+    private static final String DDL_SQL_ATTRIBUTE
+            = "ddlSql";
+
+    private CollectAttributeSetTrueTransformer collectAttributeSetTrueTransformer
+            = new CollectAttributeSetTrueTransformer();
+
+    public SourceElement transform(
+            SourceElement databaseElement,
+            ControllerState controllerState)
+        throws SourceTransformerException
+    {
+        // TODO: move check to better place
+        Object databaseOption = controllerState.getOption("torque.database");
+        if (databaseOption == null)
+        {
+            throw new SourceTransformerException(
+                    "Option torque:database must be set");
+        }
+
+        List<SourceElement> tableElements = databaseElement.getChildren(
+                TorqueSchemaElementName.TABLE.getName());
+        for (SourceElement tableElement : tableElements)
+        {
+            transformTable(tableElement, controllerState);
+        }
+        return databaseElement;
+    }
+
+    public void transformTable(
+            SourceElement tableElement,
+            ControllerState controllerState)
+        throws SourceTransformerException
+    {
+        Object idMethod = tableElement.getAttribute(
+                TorqueSchemaAttributeName.ID_METHOD.getName());
+        // TODO: in the 3.3 schema, "null" is the default value for idMethod.
+        // Therefore we must test for this explicit string.
+        // Can be removed once the dtd/schema is updated.
+        if (idMethod == null
+            || TorqueSchemaIdMethod.NULL.getName().equals(idMethod))
+        {
+            Object defaultIdMethod = tableElement.getParent().getAttribute(
+                    TorqueSchemaAttributeName.DEFAULT_ID_METHOD.getName());
+            if (defaultIdMethod == null)
+            {
+                throw new SourceTransformerException("id Method is not set"
+                        + " on table "
+                        + tableElement.getAttribute(
+                                TorqueSchemaAttributeName.NAME.getName())
+                        + " and defaultIdMethod is not set on database");
+            }
+            tableElement.setAttribute(
+                    TorqueSchemaAttributeName.ID_METHOD.getName(),
+                    defaultIdMethod);
+        }
+        String tableName = (String) tableElement.getAttribute(
+                TorqueSchemaAttributeName.NAME.getName());
+        if (tableElement.getAttribute(PRIMARY_KEY_CONSTRAINT_NAME_ATTRIBUTE)
+                == null)
+        {
+            // TODO: Column length from database descriptor
+            String primaryKeyConstraintName =
+                (tableName.length() > 27 ? tableName.substring(0, 26) : tableName)
+                  + "_PK";
+            tableElement.setAttribute(
+                    PRIMARY_KEY_CONSTRAINT_NAME_ATTRIBUTE,
+                    primaryKeyConstraintName);
+        }
+        if (tableElement.getAttribute(SEQUENCE_NAME_ATTRIBUTE)
+                == null)
+        {
+            // TODO: Sequence name length from database descriptor
+            String sequenceName =
+                (tableName.length() > 27 ? tableName.substring(0, 26) : tableName)
+                  + "_SEQ";
+            tableElement.setAttribute(
+                    SEQUENCE_NAME_ATTRIBUTE,
+                    sequenceName);
+        }
+
+        // primary keys
+        collectAttributeSetTrueTransformer.transform(
+                tableElement,
+                controllerState,
+                TorqueSchemaElementName.COLUMN,
+                TorqueSchemaAttributeName.PRIMARY_KEY,
+                TableChildElementName.PRIMARY_KEYS);
+
+        StringBuilder primaryKeyColumnNames = new StringBuilder();
+        SourceElement primaryKeysElement = tableElement.getChild(
+                TableChildElementName.PRIMARY_KEYS);
+        boolean firstPk = true;
+        for (SourceElement primaryKeyColumn : primaryKeysElement.getChildren())
+        {
+            if (!firstPk)
+            {
+                primaryKeyColumnNames.append(", ");
+            }
+            primaryKeyColumnNames.append(primaryKeyColumn.getAttribute(
+                            TorqueSchemaAttributeName.NAME.getName()));
+            firstPk = false;
+        }
+        tableElement.setAttribute(
+                PRIMARY_KEY_COLUMN_NAMES_ATTRIBUTE,
+                primaryKeyColumnNames.toString());
+
+        // unique
+        int uniqueIndex = 1;
+        for (SourceElement uniqueElement : tableElement.getChildren(
+                TorqueSchemaElementName.UNIQUE.getName()))
+        {
+            if (uniqueElement.getAttribute(
+                        TorqueSchemaAttributeName.NAME.getName())
+                    == null)
+            {
+                uniqueElement.setAttribute(
+                        TorqueSchemaAttributeName.NAME.getName(),
+                        uniqueElement.getParent().getAttribute(
+                               TorqueSchemaAttributeName.NAME.getName())
+                            + "_UQ_" + uniqueIndex);
+            }
+            String uniqueColumnNames = collectAttributes(
+                    uniqueElement,
+                    TorqueSchemaElementName.UNIQUE_COLUMN.getName(),
+                    TorqueSchemaAttributeName.NAME.getName());
+            uniqueElement.setAttribute(
+                    UNIQUE_COLUMN_NAMES_ATTRIBUTE,
+                    uniqueColumnNames);
+            ++uniqueIndex;
+        }
+
+        // index
+        for (SourceElement indexElement : tableElement.getChildren(
+                TorqueSchemaElementName.INDEX.getName()))
+        {
+            String indexColumnNames = collectAttributes(
+                    indexElement,
+                    TorqueSchemaElementName.INDEX_COLUMN.getName(),
+                    TorqueSchemaAttributeName.NAME.getName());
+            indexElement.setAttribute(
+                    INDEX_COLUMN_NAMES_ATTRIBUTE,
+                    indexColumnNames);
+        }
+
+        List<SourceElement> columnElements = tableElement.getChildren(
+                TorqueSchemaElementName.COLUMN.getName());
+        for (SourceElement columnElement : columnElements)
+        {
+            transformColumn(columnElement, controllerState);
+        }
+        List<SourceElement> foreignKeyElements = tableElement.getChildren(
+                TorqueSchemaElementName.FOREIGN_KEY.getName());
+
+        int fkIndex = 1;
+        for (SourceElement foreignKeyElemenElement : foreignKeyElements)
+        {
+            transformForeignKey(
+                    foreignKeyElemenElement,
+                    controllerState,
+                    fkIndex);
+            ++fkIndex;
+        }
+    }
+
+    private void transformColumn(
+            SourceElement columnElement,
+            ControllerState controllerState)
+        throws SourceTransformerException
+    {
+        String sql = (String) columnElement.getAttribute(
+                DDL_SQL_ATTRIBUTE);
+        if (sql == null)
+        {
+            sql = getSql(columnElement, controllerState);
+            columnElement.setAttribute(DDL_SQL_ATTRIBUTE, sql);
+        }
+    }
+
+    private String getSql(
+            SourceElement columnElement,
+            ControllerState controllerState)
+        throws SourceTransformerException
+    {
+        SchemaType schemaType = SchemaTypeHelper.getSchemaType(
+                columnElement,
+                controllerState);
+        Object size = columnElement.getAttribute(
+                TorqueSchemaAttributeName.SIZE);
+        Object scale = columnElement.getAttribute(
+                TorqueSchemaAttributeName.SCALE);
+        Object defaultValue = columnElement.getAttribute(
+                TorqueSchemaAttributeName.DEFAULT);
+        SqlType sqlType = SchemaTypeHelper.getSqlType(
+                schemaType,
+                controllerState,
+                ObjectUtils.toString(size, null),
+                ObjectUtils.toString(scale, null),
+                ObjectUtils.toString(defaultValue, null));
+        Platform platform = PlatformFactory.getPlatformFor(
+                controllerState.getStringOption(
+                        TemplateOptionName.DATABASE));
+
+        List<String> resultList = new ArrayList<String>();
+
+        String sqlTypeName = sqlType.getSqlTypeName();
+
+        if (platform.hasSize(sqlType.getSqlTypeName()))
+        {
+            sqlTypeName += sqlType.printSize();
+        }
+
+        resultList.add(sqlTypeName);
+
+        if (StringUtils.isNotEmpty(sqlType.getDefaultValue()))
+        {
+            resultList.add("default");
+
+            if (TypeMap.isTextType(schemaType))
+            {
+                // TODO: Properly SQL-escape the text.
+                resultList.add(
+                        new StringBuffer()
+                        .append('\'')
+                        .append(sqlType.getDefaultValue())
+                        .append('\'')
+                        .toString());
+            }
+            else
+            {
+                resultList.add(sqlType.getDefaultValue());
+            }
+        }
+
+        boolean primaryKey;
+        {
+            String primaryKeyString = (String) columnElement.getAttribute(
+                    TorqueSchemaAttributeName.PRIMARY_KEY);
+            primaryKey = Boolean.parseBoolean(primaryKeyString);
+        }
+        boolean required;
+        {
+            String requiredString = (String) columnElement.getAttribute(
+                    TorqueSchemaAttributeName.REQUIRED);
+            required = Boolean.parseBoolean(requiredString);
+        }
+        boolean isNotNull = primaryKey || required;
+        String isNotNullString = platform.getNullString(isNotNull);
+
+        if (platform.createNotNullBeforeAutoincrement())
+        {
+            if (StringUtils.isNotEmpty(isNotNullString))
+            {
+                resultList.add(isNotNullString);
+            }
+        }
+        // if idMethod was not set explicitly by the user,
+        // the transformTable() method sets the attribute from the
+        // defaultIdMethod of the database, so this always returns
+        // the id method
+        Object idMethod = columnElement.getParent().getAttribute(
+                TorqueSchemaAttributeName.ID_METHOD);
+        if (primaryKey
+                && TorqueSchemaIdMethod.NATIVE.getName().equals(idMethod))
+        {
+            String autoIncrement = platform.getAutoIncrement();
+            if (StringUtils.isNotEmpty(autoIncrement))
+            {
+                resultList.add(autoIncrement);
+            }
+        }
+        if (!platform.createNotNullBeforeAutoincrement())
+        {
+            if (StringUtils.isNotEmpty(isNotNullString))
+            {
+                resultList.add(isNotNullString);
+            }
+        }
+        return StringUtils.join(resultList.iterator(), ' ');
+    }
+
+    private void transformForeignKey(
+            SourceElement foreignKeyElement,
+            ControllerState controllerState,
+            int fkIndex)
+        throws SourceTransformerException
+    {
+        // TODO: the 3.3 schema specifies "none" as default value
+        // for the attributes onUpdate and onDelete.
+        // This is equivalent to null. This code can be removed
+        // once the schema/dtd is updated
+        if ("none".equals(foreignKeyElement.getAttribute(
+                TorqueSchemaAttributeName.ON_UPDATE.getName())))
+        {
+            foreignKeyElement.setAttribute(
+                    TorqueSchemaAttributeName.ON_UPDATE.getName(),
+                    null);
+        }
+        if ("none".equals(foreignKeyElement.getAttribute(
+                TorqueSchemaAttributeName.ON_DELETE.getName())))
+        {
+            foreignKeyElement.setAttribute(
+                    TorqueSchemaAttributeName.ON_DELETE.getName(),
+                    null);
+        }
+
+        if (foreignKeyElement.getAttribute(
+                    TorqueSchemaAttributeName.NAME.getName())
+                == null)
+        {
+            foreignKeyElement.setAttribute(
+                    TorqueSchemaAttributeName.NAME.getName(),
+                    foreignKeyElement.getParent().getAttribute(
+                           TorqueSchemaAttributeName.NAME.getName())
+                        + "_FK_" + fkIndex);
+        }
+        String localColumnsNames = collectAttributes(
+                foreignKeyElement,
+                TorqueSchemaElementName.REFERENCE.getName(),
+                TorqueSchemaAttributeName.LOCAL.getName());
+        foreignKeyElement.setAttribute(
+                LOCAL_COLUMN_NAMES_ATTRIBUTE,
+                localColumnsNames);
+        String foreignColumnsNames = collectAttributes(
+                foreignKeyElement,
+                TorqueSchemaElementName.REFERENCE.getName(),
+                TorqueSchemaAttributeName.FOREIGN.getName());
+        foreignKeyElement.setAttribute(
+                FOREIGN_COLUMN_NAMES_ATTRIBUTE,
+                foreignColumnsNames);
+    }
+
+    private String collectAttributes(
+            SourceElement rootElement,
+            String sourcePath,
+            String attributeName)
+    {
+        StringBuilder result = new StringBuilder();
+        List<SourceElement> toCollectFrom = SourcePath.getElements(
+                rootElement, sourcePath);
+        boolean firstElement = true;
+        for (SourceElement sourceElement : toCollectFrom)
+        {
+            if (!firstElement)
+            {
+                result.append(", ");
+            }
+            result.append(sourceElement.getAttribute(attributeName));
+            firstElement = false;
+        }
+        return result.toString();
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/JavaType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/JavaType.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/JavaType.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/JavaType.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,99 @@
+package org.apache.torque.templates.typemapping;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+public enum JavaType
+{
+    STRING("String", false, false, null),
+    BIG_DECIMAL("BigDecimal", false, true, "java.math."),
+    BOOLEAN_PRIMITIVE("boolean", true, false, null),
+    BOOLEAN_OBJECT("Boolean", false, false, null),
+    BYTE_PRIMITIVE("byte", true, true, null),
+    BYTE_OBJECT("Byte", false, true, null),
+    SHORT_PRIMITIVE("short", true, true, null),
+    SHORT_OBJECT("Short", false, true, null),
+    INTEGER_PRIMITIVE("int", true, true, null),
+    INTEGER_OBJECT("Integer", false, true, null),
+    LONG_PRIMITIVE("long", true, true, null),
+    LONG_OBJECT("Long", false, true, null),
+    FLOAT_PRIMITIVE("float", true, true, null),
+    FLOAT_OBJECT("Float", false, true, null),
+    DOUBLE_PRIMITIVE("double", true, true, null),
+    DOUBLE_OBJECT("Double", false, true, null),
+    CHAR_PRIMITIVE("char", true, false, null),
+    CHAR_OBJECT("Char", false, false, null),
+    BYTE_PRIMITIVE_ARRAY("byte[]", false, false, null),
+    DATE("java.util.Date", false, false, null);
+
+    private String className;
+
+    private boolean primitive;
+
+    private boolean number;
+
+    private String packagePrefix;
+
+    private JavaType(
+            String className,
+            boolean primitive,
+            boolean number,
+            String packagePrefix)
+    {
+        this.className = className;
+        this.primitive = primitive;
+        this.number = number;
+        this.packagePrefix = packagePrefix;
+    }
+
+    public boolean isPrimitive()
+    {
+        return primitive;
+    }
+
+    public boolean isNumber()
+    {
+        return number;
+    }
+
+    public String getClassName()
+    {
+        return className;
+    }
+
+    public String getPackagePrefix()
+    {
+        return packagePrefix;
+    }
+
+    public String getFullClassName()
+    {
+        if (packagePrefix == null)
+        {
+            return className;
+        }
+        else
+        {
+            return packagePrefix + className;
+        }
+    }
+
+
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SchemaType.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,61 @@
+package org.apache.torque.templates.typemapping;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+/**
+ * Enum for types used in Torque schema.xml files.
+ *
+ * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
+ * @version $Id: SchemaType.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public enum SchemaType
+{
+    BIT,
+    TINYINT,
+    SMALLINT,
+    INTEGER,
+    BIGINT,
+    FLOAT,
+    REAL,
+    NUMERIC,
+    DECIMAL,
+    CHAR,
+    VARCHAR,
+    LONGVARCHAR,
+    DATE,
+    TIME,
+    TIMESTAMP,
+    BINARY,
+    VARBINARY,
+    LONGVARBINARY,
+    NULL,
+    OTHER,
+    JAVA_OBJECT,
+    DISTINCT,
+    STRUCT,
+    ARRAY,
+    BLOB,
+    CLOB,
+    REF,
+    BOOLEANINT,
+    BOOLEANCHAR,
+    DOUBLE;
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SizedForBitDataSqlType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SizedForBitDataSqlType.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SizedForBitDataSqlType.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SizedForBitDataSqlType.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,91 @@
+package org.apache.torque.templates.typemapping;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * <p>
+ * Supports the Derby / DB2 / SQL92 standard for defining Binary data fields
+ * with either CHAR(#) FOR BIT DATA or VARCHAR(#) FOR BIT DATA. This can be
+ * used in Platform implementors initialize() methods, by using lines like:
+ * </p>
+ * <code>
+ * setSchemaDomainMapping(new SizedForBitDataDomain(
+ *                          SchemaType.BINARY, "CHAR", "1"));
+ * setSchemaDomainMapping(new SizedForBitDataDomain(
+ *                          SchemaType.VARBINARY, "VARCHAR"));
+ * </code>
+ * <p>
+ * This will cause the Column.getSqlString() method to produce items similar to:
+ * </p>
+ * <code>
+ * CHAR(#) FOR BIT DATA
+ * VARCHAR(#)FOR BIT DATA
+ * </code>
+ * <p>
+ * Where: # is the size= schema attribute or a default size specified in the
+ * constructor.
+ * </p>
+ * <p>
+ * Note that this is dependent on the platform implementation correctly defining
+ * BINARY and VARBINARY as having a size attribute in the "hasSize()" method.
+ * </p>
+ *
+ * @see org.apache.torque.templates.platform.Platform
+ * @see org.apache.torque.templates.transformer.sql.SQLTransformer#getSqlString()
+ * @author <a href="Monroe@DukeCE.com">Greg Monroe</a>
+ */
+public class SizedForBitDataSqlType extends SqlType
+{
+    /**
+     * @see SqlType#SqlType(String)
+     */
+    public SizedForBitDataSqlType(String sqlType)
+    {
+        super(sqlType);
+    }
+
+    /**
+     * @see SqlType#SqlType(String, String)
+     */
+    public SizedForBitDataSqlType(String sqlType, String size)
+    {
+        super(sqlType, size);
+    }
+
+    /**
+     * Returns the size postfix for the base SQL Column type.
+     *
+     * @return "(size) FOR BIT DATA" or just " FOR BIT DATA" if size
+     * is null.
+     * @see org.apache.torque.SqlType.database.model.Domain#getSize()
+     */
+    public String printSize()
+    {
+        String result = "";
+        if (!StringUtils.isBlank(getSize()))
+        {
+            result =  "(" + getSize() + ")";
+        }
+        result = result + " FOR BIT DATA";
+        return result;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SqlType.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SqlType.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SqlType.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/SqlType.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,255 @@
+package org.apache.torque.templates.typemapping;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+/**
+ * The SQL type data for a column. Can contain additional information such as
+ * default size, scale and defaultValue.
+ * This class is immutable.
+ *
+ * @version $Id: Domain.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class SqlType
+{
+    /**
+     * The default size for the columns with this type
+     * (can be overridden in the column definition).
+     */
+    private String size;
+
+    /**
+     * The default scale for the columns with this type
+     * (can be overridden in the column definition).
+     */
+    private String scale;
+
+    /**
+     * The default "default value" for the columns with this type
+     * (can be overridden in the column definition).
+     */
+    private String defaultValue;
+
+    /**
+     * The SQL expression for the type name, not null.
+     */
+    private String sqlTypeName;
+
+    /**
+     * Creates a new SqlType with the given SQL Type.
+     * Size, scale and defaultValue are set to null.
+     *
+     * @param sqlType the SQL name of the SQL type, not null.
+     *
+     * @throws NullPointerException if sqlTypeName is null.
+     */
+    public SqlType(String sqlTypeName)
+    {
+        if (sqlTypeName == null)
+        {
+            throw new NullPointerException("sqlTypeName must not be null");
+        }
+        this.sqlTypeName = sqlTypeName;
+    }
+
+    /**
+     * Creates a new SqlType with null scale and null default value.
+     *
+     * @param sqlTypeName the SQL name of the SQL type, not null.
+     * @param size the default size of the columns with this SQL type.
+     *        Can be overridden in the column definition.
+     *
+     * @throws NullPointerException if sqlTypeName is null.
+     */
+    public SqlType(
+            String sqlTypeName,
+            String size)
+    {
+        this(sqlTypeName);
+        this.size = size;
+    }
+
+    /**
+     * Creates a new SqlType with null default value.
+     *
+     * @param sqlTypeName the SQL name of the SQL type, not null.
+     * @param size the default size of the columns with this SQL type.
+     *        Can be overridden in the column definition.
+     * @param scale the default scale of the columns with this SQL type.
+     *        Can be overridden in the column definition.
+     *
+     * @throws NullPointerException if sqlTypeName is null.
+     */
+    public SqlType(
+            String sqlTypeName,
+            String size,
+            String scale)
+    {
+        this(sqlTypeName, size);
+        this.scale = scale;
+    }
+
+    /**
+     * Creates a new SqlType.
+     *
+     * @param sqlTypeName the SQL name of the SQL type, not null.
+     * @param size the default size of the columns with this SQL type.
+     *        Can be overridden in the column definition.
+     * @param scale the default scale of the columns with this SQL type.
+     *        Can be overridden in the column definition.
+     * @param defaultValue the default "default value" of the columns with this
+     *        SQL type. Can be overridden in the column definition.
+     *
+     * @throws NullPointerException if sqlTypeName is null.
+     */
+    public SqlType(
+            String sqlTypeName,
+            String size,
+            String scale,
+            String defaultValue)
+    {
+        this(sqlTypeName, size, scale);
+        this.defaultValue = defaultValue;
+    }
+
+    /**
+     * Creates a new SqlType by copying another sql type.
+     *
+     * @param sqlType the SQL type, to copy, not null.
+     * @param size the default size of the columns with this SQL type.
+     *        Can be overridden in the column definition.
+     *        If null, the size from sqlType is used.
+     * @param scale the default scale of the columns with this SQL type.
+     *        Can be overridden in the column definition.
+     *        If null, the scale from sqlType is used.
+     * @param defaultValue the default "default value" of the columns with this
+     *        SQL type. Can be overridden in the column definition.
+     *        If null, the defaultValue from sqlType is used.
+     *
+     * @throws NullPointerException if sqlType is null.
+     */
+    public SqlType(
+            SqlType sqlType,
+            String size,
+            String scale,
+            String defaultValue)
+    {
+        this(sqlType.getSqlTypeName());
+        if (size != null)
+        {
+            this.size = size;
+        }
+        else
+        {
+            this.size = sqlType.getSize();
+        }
+        if (scale != null)
+        {
+            this.scale = scale;
+        }
+        else
+        {
+            this.scale = sqlType.getScale();
+        }
+        if (defaultValue != null)
+        {
+            this.defaultValue = defaultValue;
+        }
+        else
+        {
+            this.defaultValue = sqlType.getDefaultValue();
+        }
+    }
+
+    /**
+     * @return Returns the scale.
+     */
+    public String getScale()
+    {
+        return scale;
+    }
+
+    /**
+     * @return Returns the size.
+     */
+    public String getSize()
+    {
+        return size;
+    }
+
+    /**
+     * @return Returns the defaultValue.
+     */
+    public String getDefaultValue()
+    {
+        return defaultValue;
+    }
+
+    /**
+     * @return Returns the SQL type name for this column type.
+     */
+    public String getSqlTypeName()
+    {
+        return sqlTypeName;
+    }
+
+    /**
+     * Return the size and scale in brackets for use in an SQL script.
+     *
+     * @return size and scale or an empty String if there are no values
+     *         available.
+     */
+    public String printSize()
+    {
+        if (StringUtils.isNotBlank(size) && StringUtils.isNotBlank(scale))
+        {
+            return '(' + size + ',' + scale + ')';
+        }
+        else if (StringUtils.isNotBlank(size))
+        {
+            return '(' + size + ')';
+        }
+        else
+        {
+            return "";
+        }
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/TypeMap.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/TypeMap.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/TypeMap.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/TypeMap.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,417 @@
+package org.apache.torque.templates.typemapping;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Various mappings for schema types, e.g. to their corresponding
+ * Java object types, and Java native types.
+ *
+ * These are the official SQL type to Java type mappings.
+ * These don't quite correspond to the way the peer
+ * system works so we'll have to make some adjustments.
+ * <pre>
+ * -------------------------------------------------------
+ * SQL Type      | Java Type            | Peer Type
+ * -------------------------------------------------------
+ * CHAR          | String               | String
+ * VARCHAR       | String               | String
+ * LONGVARCHAR   | String               | String
+ * NUMERIC       | java.math.BigDecimal | java.math.BigDecimal
+ * DECIMAL       | java.math.BigDecimal | java.math.BigDecimal
+ * BIT           | boolean OR Boolean   | Boolean
+ * TINYINT       | byte OR Byte         | Byte
+ * SMALLINT      | short OR Short       | Short
+ * INTEGER       | int OR Integer       | Integer
+ * BIGINT        | long OR Long         | Long
+ * REAL          | float OR Float       | Float
+ * FLOAT         | double OR Double     | Double
+ * DOUBLE        | double OR Double     | Double
+ * BINARY        | byte[]               | ?
+ * VARBINARY     | byte[]               | ?
+ * LONGVARBINARY | byte[]               | ?
+ * DATE          | java.sql.Date        | java.util.Date
+ * TIME          | java.sql.Time        | java.util.Date
+ * TIMESTAMP     | java.sql.Timestamp   | java.util.Date
+ *
+ * -------------------------------------------------------
+ * A couple variations have been introduced to cover cases
+ * that may arise, but are not covered above
+ * BOOLEANCHAR   | boolean OR Boolean   | String
+ * BOOLEANINT    | boolean OR Boolean   | Integer
+ * </pre>
+ *
+ * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
+ * @author <a href="mailto:mpoeschl@marmot.at>Martin Poeschl</a>
+ * @version $Id: TypeMap.java 473814 2006-11-11 22:30:30 +0000 (Sat, 11 Nov 2006) tv $
+ */
+public class TypeMap
+{
+    private static final SchemaType[] TEXT_TYPES =
+    {
+        SchemaType.CHAR,
+        SchemaType.VARCHAR,
+        SchemaType.LONGVARCHAR,
+        SchemaType.CLOB,
+        SchemaType.DATE,
+        SchemaType.TIME,
+        SchemaType.TIMESTAMP,
+        SchemaType.BOOLEANCHAR
+    };
+
+    public static final String CHAR_OBJECT_TYPE = "\"\"";
+    public static final String VARCHAR_OBJECT_TYPE = "\"\"";
+    public static final String LONGVARCHAR_OBJECT_TYPE = "\"\"";
+    public static final String CLOB_OBJECT_TYPE = "\"\"";
+    public static final String NUMERIC_OBJECT_TYPE = "new java.math.BigDecimal((double) 0)";
+    public static final String DECIMAL_OBJECT_TYPE = "new java.math.BigDecimal((double) 0)";
+    public static final String BIT_OBJECT_TYPE = "new Boolean(true)";
+    public static final String TINYINT_OBJECT_TYPE = "new Byte((byte)0)";
+    public static final String SMALLINT_OBJECT_TYPE = "new Short((short)0)";
+    public static final String INTEGER_OBJECT_TYPE = "new Integer(0)";
+    public static final String BIGINT_OBJECT_TYPE = "new Long(0)";
+    public static final String REAL_OBJECT_TYPE = "new Float(0)";
+    public static final String FLOAT_OBJECT_TYPE = "new Double(0)";
+    public static final String DOUBLE_OBJECT_TYPE = "new Double(0)";
+    public static final String BINARY_OBJECT_TYPE = "new Object()"; //?
+    public static final String VARBINARY_OBJECT_TYPE = "new Object()"; //?
+    public static final String LONGVARBINARY_OBJECT_TYPE = "new Object()"; //?
+    public static final String BLOB_OBJECT_TYPE = "new Object()"; //?
+    public static final String DATE_OBJECT_TYPE = "new Date()";
+    public static final String TIME_OBJECT_TYPE = "new Date()";
+    public static final String TIMESTAMP_OBJECT_TYPE = "new Date()";
+    public static final String BOOLEANCHAR_OBJECT_TYPE = "\"\"";
+    public static final String BOOLEANINT_OBJECT_TYPE = "new Integer(0)";
+
+    /**
+     * The mapping from schema type to the default initialisation value
+     * for that schema type.
+     */
+    private static final Map<SchemaType, String>
+            SCHEMA_TYPE_TO_INIT_VALUE_MAP;
+
+    /**
+     * The default Mapping of schema Types to Java Types. Where possible,
+     * primitive types are used.
+     */
+    private static final Map<SchemaType, JavaType>
+            SCHEMA_TYPE_TO_JAVA_PRIMITIVE_TYPE_MAP;
+    /**
+     * The default Mapping of schema Types to Java Types.
+     * No primitive types are used.
+     */
+    private static final Map<SchemaType, JavaType>
+            SCHEMA_TYPE_TO_JAVA_OBJECT_TYPE_MAP;
+
+    /**
+     * The village method used for a given schema type.
+     * Conversions to primitive types are used where possible.
+     */
+    private static final Map<SchemaType, VillageMethod>
+            SCHEMA_TYPE_TO_VILLAGE_METHOD_MAP;
+
+    /**
+     * The village method used for a given schema type.
+     * No conversions to primitive types are used.
+     */
+    private static final Map<SchemaType, VillageMethod>
+            SCHEMA_TYPE_TO_VILLAGE_OBJECT_METHOD_MAP;
+
+    // fill SCHEMA_TYPE_TO_INIT_VALUE_MAP
+    static {
+        Map<SchemaType, String> schemaToInitValue
+                = new HashMap<SchemaType, String>();
+
+        schemaToInitValue.put(SchemaType.CHAR, CHAR_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.VARCHAR, VARCHAR_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.LONGVARCHAR, LONGVARCHAR_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.CLOB, CLOB_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.NUMERIC, NUMERIC_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.DECIMAL, DECIMAL_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.BIT, BIT_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.TINYINT, TINYINT_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.SMALLINT, SMALLINT_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.INTEGER, INTEGER_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.BIGINT, BIGINT_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.REAL, REAL_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.FLOAT, FLOAT_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.DOUBLE, DOUBLE_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.BINARY, BINARY_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.VARBINARY, VARBINARY_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.LONGVARBINARY, LONGVARBINARY_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.BLOB, BLOB_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.DATE, DATE_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.TIME, TIME_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.TIMESTAMP, TIMESTAMP_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.BOOLEANCHAR, BOOLEANCHAR_OBJECT_TYPE);
+        schemaToInitValue.put(SchemaType.BOOLEANINT, BOOLEANINT_OBJECT_TYPE);
+        SCHEMA_TYPE_TO_INIT_VALUE_MAP
+            = Collections.unmodifiableMap(schemaToInitValue);
+    }
+
+    // Fill SCHEMA_TYPE_TO_JAVA_PRIMITIVE_TYPE_MAP
+    static
+    {
+        Map<SchemaType, JavaType> schemaToJava
+                = new HashMap<SchemaType, JavaType>();
+        schemaToJava.put(SchemaType.CHAR, JavaType.STRING);
+        schemaToJava.put(SchemaType.VARCHAR, JavaType.STRING);
+        schemaToJava.put(SchemaType.LONGVARCHAR, JavaType.STRING);
+        schemaToJava.put(SchemaType.CLOB, JavaType.STRING);
+        schemaToJava.put(SchemaType.NUMERIC, JavaType.BIG_DECIMAL);
+        schemaToJava.put(SchemaType.DECIMAL, JavaType.BIG_DECIMAL);
+        schemaToJava.put(SchemaType.BIT, JavaType.BOOLEAN_PRIMITIVE);
+        schemaToJava.put(SchemaType.TINYINT, JavaType.BYTE_PRIMITIVE);
+        schemaToJava.put(SchemaType.SMALLINT, JavaType.SHORT_PRIMITIVE);
+        schemaToJava.put(SchemaType.INTEGER, JavaType.INTEGER_PRIMITIVE);
+        schemaToJava.put(SchemaType.BIGINT, JavaType.LONG_PRIMITIVE);
+        schemaToJava.put(SchemaType.REAL, JavaType.FLOAT_PRIMITIVE);
+        schemaToJava.put(SchemaType.FLOAT, JavaType.DOUBLE_PRIMITIVE);
+        schemaToJava.put(SchemaType.DOUBLE, JavaType.DOUBLE_PRIMITIVE);
+        schemaToJava.put(SchemaType.BINARY, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.VARBINARY, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.LONGVARBINARY, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.BLOB, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.DATE, JavaType.DATE);
+        schemaToJava.put(SchemaType.TIME, JavaType.DATE);
+        schemaToJava.put(SchemaType.TIMESTAMP, JavaType.DATE);
+        schemaToJava.put(SchemaType.BOOLEANCHAR, JavaType.BOOLEAN_PRIMITIVE);
+        schemaToJava.put(SchemaType.BOOLEANINT, JavaType.BOOLEAN_PRIMITIVE);
+        SCHEMA_TYPE_TO_JAVA_PRIMITIVE_TYPE_MAP
+                = Collections.unmodifiableMap(schemaToJava);
+    }
+
+
+    // Fill SCHEMA_TYPE_TO_JAVA_OBJECT_TYPE_MAP
+    static
+    {
+        Map<SchemaType, JavaType> schemaToJava
+                = new HashMap<SchemaType, JavaType>();
+        schemaToJava.put(SchemaType.CHAR, JavaType.STRING);
+        schemaToJava.put(SchemaType.VARCHAR, JavaType.STRING);
+        schemaToJava.put(SchemaType.LONGVARCHAR, JavaType.STRING);
+        schemaToJava.put(SchemaType.CLOB, JavaType.STRING);
+        schemaToJava.put(SchemaType.NUMERIC, JavaType.BIG_DECIMAL);
+        schemaToJava.put(SchemaType.DECIMAL, JavaType.BIG_DECIMAL);
+        schemaToJava.put(SchemaType.BIT, JavaType.BOOLEAN_OBJECT);
+        schemaToJava.put(SchemaType.TINYINT, JavaType.BYTE_OBJECT);
+        schemaToJava.put(SchemaType.SMALLINT, JavaType.SHORT_OBJECT);
+        schemaToJava.put(SchemaType.INTEGER, JavaType.INTEGER_OBJECT);
+        schemaToJava.put(SchemaType.BIGINT, JavaType.LONG_OBJECT);
+        schemaToJava.put(SchemaType.REAL, JavaType.FLOAT_OBJECT);
+        schemaToJava.put(SchemaType.FLOAT, JavaType.DOUBLE_OBJECT);
+        schemaToJava.put(SchemaType.DOUBLE, JavaType.DOUBLE_OBJECT);
+        schemaToJava.put(SchemaType.BINARY, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.VARBINARY, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.LONGVARBINARY, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.BLOB, JavaType.BYTE_PRIMITIVE_ARRAY);
+        schemaToJava.put(SchemaType.DATE, JavaType.DATE);
+        schemaToJava.put(SchemaType.TIME, JavaType.DATE);
+        schemaToJava.put(SchemaType.TIMESTAMP, JavaType.DATE);
+        schemaToJava.put(SchemaType.BOOLEANCHAR, JavaType.BOOLEAN_OBJECT);
+        schemaToJava.put(SchemaType.BOOLEANINT, JavaType.BOOLEAN_OBJECT);
+        SCHEMA_TYPE_TO_JAVA_OBJECT_TYPE_MAP
+                = Collections.unmodifiableMap(schemaToJava);
+    }
+
+    static
+    {
+        Map<SchemaType, VillageMethod> schema2VillageMethod
+                = new HashMap<SchemaType, VillageMethod>();
+
+        schema2VillageMethod.put(SchemaType.CHAR, VillageMethod.STRING);
+        schema2VillageMethod.put(SchemaType.VARCHAR, VillageMethod.STRING);
+        schema2VillageMethod.put(SchemaType.LONGVARCHAR, VillageMethod.STRING);
+        schema2VillageMethod.put(SchemaType.CLOB, VillageMethod.STRING);
+        schema2VillageMethod.put(SchemaType.NUMERIC, VillageMethod.BIG_DECIMAL);
+        schema2VillageMethod.put(SchemaType.DECIMAL, VillageMethod.BIG_DECIMAL);
+        schema2VillageMethod.put(SchemaType.BIT, VillageMethod.BOOLEAN);
+        schema2VillageMethod.put(SchemaType.TINYINT, VillageMethod.BYTE);
+        schema2VillageMethod.put(SchemaType.SMALLINT, VillageMethod.SHORT);
+        schema2VillageMethod.put(SchemaType.INTEGER, VillageMethod.INT);
+        schema2VillageMethod.put(SchemaType.BIGINT, VillageMethod.LONG);
+        schema2VillageMethod.put(SchemaType.REAL, VillageMethod.FLOAT);
+        schema2VillageMethod.put(SchemaType.FLOAT, VillageMethod.DOUBLE);
+        schema2VillageMethod.put(SchemaType.DOUBLE, VillageMethod.DOUBLE);
+        schema2VillageMethod.put(SchemaType.BINARY, VillageMethod.BYTES);
+        schema2VillageMethod.put(SchemaType.VARBINARY, VillageMethod.BYTES);
+        schema2VillageMethod.put(SchemaType.LONGVARBINARY, VillageMethod.BYTES);
+        schema2VillageMethod.put(SchemaType.BLOB, VillageMethod.BYTES);
+        schema2VillageMethod.put(SchemaType.DATE, VillageMethod.UTIL_DATE);
+        schema2VillageMethod.put(SchemaType.TIME, VillageMethod.UTIL_DATE);
+        schema2VillageMethod.put(SchemaType.TIMESTAMP, VillageMethod.UTIL_DATE);
+        schema2VillageMethod.put(SchemaType.BOOLEANCHAR, VillageMethod.BOOLEAN);
+        schema2VillageMethod.put(SchemaType.BOOLEANINT, VillageMethod.BOOLEAN);
+        SCHEMA_TYPE_TO_VILLAGE_METHOD_MAP
+                = Collections.unmodifiableMap(schema2VillageMethod);
+    }
+
+    static
+    {
+        Map<SchemaType, VillageMethod> schemaToVillageMethod
+                = new HashMap<SchemaType, VillageMethod>();
+
+        schemaToVillageMethod.put(SchemaType.CHAR, VillageMethod.STRING);
+        schemaToVillageMethod.put(SchemaType.VARCHAR, VillageMethod.STRING);
+        schemaToVillageMethod.put(SchemaType.LONGVARCHAR, VillageMethod.STRING);
+        schemaToVillageMethod.put(SchemaType.CLOB, VillageMethod.STRING);
+        schemaToVillageMethod.put(SchemaType.NUMERIC, VillageMethod.BIG_DECIMAL);
+        schemaToVillageMethod.put(SchemaType.DECIMAL, VillageMethod.BIG_DECIMAL);
+        schemaToVillageMethod.put(SchemaType.BIT, VillageMethod.BOOLEAN_OBJECT);
+        schemaToVillageMethod.put(SchemaType.TINYINT, VillageMethod.BYTE_OBJECT);
+        schemaToVillageMethod.put(SchemaType.SMALLINT, VillageMethod.SHORT_OBJECT);
+        schemaToVillageMethod.put(SchemaType.INTEGER, VillageMethod.INTEGER_OBJECT);
+        schemaToVillageMethod.put(SchemaType.BIGINT, VillageMethod.LONG_OBJECT);
+        schemaToVillageMethod.put(SchemaType.REAL, VillageMethod.FLOAT_OBJECT);
+        schemaToVillageMethod.put(SchemaType.FLOAT, VillageMethod.DOUBLE_OBJECT);
+        schemaToVillageMethod.put(SchemaType.DOUBLE, VillageMethod.DOUBLE);
+        schemaToVillageMethod.put(SchemaType.BINARY, VillageMethod.BYTES);
+        schemaToVillageMethod.put(SchemaType.VARBINARY, VillageMethod.BYTES);
+        schemaToVillageMethod.put(SchemaType.LONGVARBINARY, VillageMethod.BYTES);
+        schemaToVillageMethod.put(SchemaType.BLOB, VillageMethod.BYTES);
+        schemaToVillageMethod.put(SchemaType.DATE, VillageMethod.UTIL_DATE);
+        schemaToVillageMethod.put(SchemaType.TIME, VillageMethod.UTIL_DATE);
+        schemaToVillageMethod.put(SchemaType.TIMESTAMP, VillageMethod.UTIL_DATE);
+        schemaToVillageMethod.put(SchemaType.BOOLEANCHAR, VillageMethod.BOOLEAN_OBJECT);
+        schemaToVillageMethod.put(SchemaType.BOOLEANINT, VillageMethod.BOOLEAN_OBJECT);
+        SCHEMA_TYPE_TO_VILLAGE_OBJECT_METHOD_MAP
+                = Collections.unmodifiableMap(schemaToVillageMethod);
+    }
+
+
+    /**
+     * Return a Java object which corresponds to the
+     * JDBC type provided. Use in MapBuilder generation.
+     *
+     * @param jdbcType the JDBC type
+     * @return name of the Object
+     */
+    public static String getJavaObject(SchemaType jdbcType)
+    {
+        return (String) SCHEMA_TYPE_TO_INIT_VALUE_MAP.get(jdbcType);
+    }
+
+    /**
+     * Returns the java type which corresponds to the schema type provided.
+     * Where possible, primitive types are used.
+     *
+     * @param schemaType the schema type.
+     * @return name of the native java type
+     */
+    public static JavaType getJavaPrimitiveType(SchemaType schemaType)
+    {
+        return SCHEMA_TYPE_TO_JAVA_PRIMITIVE_TYPE_MAP.get(schemaType);
+    }
+
+    /**
+     * Returns the java type which corresponds to the schema type provided.
+     * Only Object types are used.
+     *
+     * @param schemaType the schema type.
+     * @return the corresponding java Type.
+     */
+    public static JavaType getJavaObjectType(SchemaType schemaType)
+    {
+        return SCHEMA_TYPE_TO_JAVA_OBJECT_TYPE_MAP.get(schemaType);
+    }
+
+    /**
+     * Return Village asX() method which corresponds to the
+     * Schema type provided.
+     *
+     * @param schemaType the Schema type
+     * @return name of the Village asX() method
+     */
+    public static VillageMethod getVillageMethod(SchemaType schemaType)
+    {
+        return SCHEMA_TYPE_TO_VILLAGE_METHOD_MAP.get(schemaType);
+    }
+
+    /**
+     * Return Village asX() method which corresponds to the
+     * Schema type provided.
+     *
+     * @param schemaType the schema type
+     * @return name of the Village asX() method
+     */
+    public static VillageMethod getVillageObjectMethod(SchemaType schemaType)
+    {
+        return SCHEMA_TYPE_TO_VILLAGE_OBJECT_METHOD_MAP.get(schemaType);
+    }
+
+    /**
+     * Returns true if the type is boolean in the java
+     * object and a numeric (1 or 0) in the db.
+     *
+     * @param type The type to check.
+     * @return true if the type is BOOLEANINT
+     */
+    public static boolean isBooleanInt(SchemaType type)
+    {
+        return SchemaType.BOOLEANINT.equals(type);
+    }
+
+    /**
+     * Returns true if the type is boolean in the
+     * java object and a String "Y" or "N" in the db.
+     *
+     * @param type The type to check.
+     * @return true if the type is BOOLEANCHAR
+     */
+    public static boolean isBooleanChar(SchemaType type)
+    {
+        return SchemaType.BOOLEANCHAR.equals(type);
+    }
+
+    /**
+     * Returns true if the type is boolean in the
+     * java object and a Bit "1" or "0" in the db.
+     *
+     * @param type The type to check.
+     * @return true if the type is BIT
+     */
+    public static boolean isBit(SchemaType type)
+    {
+        return SchemaType.BIT.equals(type);
+    }
+
+    /**
+     * Returns true if values for the type need to be quoted.
+     *
+     * @param type The type to check.
+     * @return true if values for the type need to be quoted.
+     */
+    public static final boolean isTextType(SchemaType type)
+    {
+        for (int i = 0; i < TEXT_TYPES.length; i++)
+        {
+            if (type.equals(TEXT_TYPES[i]))
+            {
+                return true;
+            }
+        }
+
+        // If we get this far, there were no matches.
+        return false;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/VillageMethod.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/VillageMethod.java?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/VillageMethod.java (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/typemapping/VillageMethod.java Tue Feb 16 17:15:43 2010
@@ -0,0 +1,65 @@
+package org.apache.torque.templates.typemapping;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * All available village value conversion methods.
+ *
+ * $Id: $
+ */
+public enum VillageMethod
+{
+    STRING("asString()"),
+    BIG_DECIMAL("asBigDecimal()"),
+    BOOLEAN("asBoolean()"),
+    BYTE("asByte()"),
+    SHORT("asShort()"),
+    INT("asInt()"),
+    LONG("asLong()"),
+    FLOAT("asFloat()"),
+    DOUBLE("asDouble()"),
+    BYTES("asBytes()"),
+    UTIL_DATE("asUtilDate()"),
+
+    BOOLEAN_OBJECT("asBooleanObj()"),
+    BYTE_OBJECT("asByteObj()"),
+    SHORT_OBJECT("asShortObj()"),
+    INTEGER_OBJECT("asIntegerObj()"),
+    LONG_OBJECT("asLongObj()"),
+    FLOAT_OBJECT("asFloatObj()"),
+    DOUBLE_OBJECT("asDoubleObj()");
+
+    private String method;
+
+    private VillageMethod(String method)
+    {
+        this.method = method;
+    }
+
+    public String getMethod()
+    {
+        return method;
+    }
+
+    public String toString()
+    {
+        return method;
+    }
+}

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/control.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<control loglevel="info"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/configuration.xsd"
+    xmlns="http://db.apache.org/torque/gf/4.0/configuration">
+  <options xsi:type="propertiesOptions" path="options.properties"/>
+  
+  <!-- Documentation css -->
+  <output name="torque.doc.html.css" file="datamodel.css">
+    <source elements="database" path="*schema.xml">
+    </source>
+    <generator name="torque.doc.html.css"/>
+  </output>
+
+  <!-- Documentation html -->
+  <output name="torque.doc.html.html" file="datamodel.html">
+    <source elements="database" path="*schema.xml">
+      <transformer class="org.apache.torque.templates.transformer.om.OMTransformer"/>
+    </source>
+    <generator name="torque.doc.html.html"/>
+  </output>
+</control>
+  
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/options.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/options.properties?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/options.properties (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/conf/options.properties Tue Feb 16 17:15:43 2010
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# replaces torque:correctGetters
+torque.om.useIsForBooleanGetters = true;
+
+torque.om.column.defaultType = VARCHAR

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/generatorDefs/html.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/generatorDefs/html.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/generatorDefs/html.xml (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/generatorDefs/html.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<generators xmlns="http://db.apache.org/torque/gf/4.0/configuration"
+    xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/generator.xsd"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <generator name="torque.doc.html.css" 
+      xsi:type="velocityGenerator" 
+      path="datamodel.css.vm">
+  </generator>
+
+  <generator name="torque.doc.html.html"
+      xsi:type="velocityGenerator" 
+      path="datamodel.vm">
+    <mergepoint name="tableDocs">
+      <action xsi:type="traverseAllAction" element="table"
+           generator="torque.doc.html.table"/>
+    </mergepoint>
+  </generator>
+  <generator name="torque.doc.html.table"
+      xsi:type="velocityGenerator" 
+      path="table.vm">
+  </generator>
+</generators>
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.css.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.css.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.css.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.css.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,117 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+/*
+Copyright 2001-2005 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.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+/*
+===============================================================
+css stylesheet for the html documentation generated by Torque
+will not be overwritten any more once the file exists
+===============================================================
+*/
+
+/* for the html body */
+body { font-family: Verdana; font-size: 10pt; color:black; }
+/* for all links */
+.link { }
+
+/* for the whole summary table */
+.summarytable { margin:0px; padding:0px; border-collapse:collapse; width:100%; }
+/* for all td's of the summary table */
+.summaryborder { border:1px solid black; }
+
+/* for the headline of the summary table */
+.summaryhead { }
+/* for all td's of the headline of the summary table */
+.summaryheadbackground { background-color:#CCCCCC; }
+/* for the different cells of the headline of the summary table */
+/* e.g. use display:none for not displaying a certain column  */
+.summaryheadtablename { }
+.summaryheadjavaname { }
+.summaryheaddescription { }
+
+/* for all regular rows of the summary table */
+.summaryrow { }
+/* for all td's in regular rows of the summary table */
+.summarybackground { background-color:white; }
+/* for the different cells in the regular rows of the summary table */
+/* e.g. use display:none for not displaying a certain column */
+.summarytablename { }
+.summaryjavaname { }
+.summarydescription { }
+
+/* for the hrefs in the summary table */
+.summarytablenamelink { }
+
+/* for the headline of the detail tables */
+.detailtable { margin:0px; padding:0px; border-collapse:collapse; width:100%; }
+/* for all td's of the summary table */
+.detailborder { border:1px solid black; }
+
+/* for the headline of the detail tables */
+.detailhead { }
+/* for all td's in the headline of the detail tables */
+.detailheadbackground { background-color:#CCCCCC; }
+/* for the different cells in the headline of the detail tables */
+/* e.g. use display:none for not displaying a certain column */
+.detailheadname { }
+.detailheadtype { } 
+.detailheadsize { }
+.detailheaddefault { }
+.detailheadjavaname { }
+.detailheadpk { }
+.detailheadfk { }
+.detailheadnotnull { }
+.detailheaddescription { }
+
+/* for all regular rows in the detail tables */
+.detailrow { }
+/* for all td's in the regular rows in the detail tables */
+.detailbackground { background-color:white; }
+/* for the different cells in the regular rows of the detail tables */
+/* e.g use display:none for not displaying a certain column */
+.detailname { }
+.detailtype { } 
+.detailsize { }
+.detaildefault { }
+.detailjavaname { }
+.detailpk { }
+.detailfk { }
+.detailnotnull { }
+.detaildescription { }
+
+/* for the links to the referenced tables for foreign key column names */
+.detailforeignkeylink { color:#44AA44; }
+/* for the name cell of primary keys */
+.primarykey { background-color:#FFCCCC; }
+/* for the name cell of foreign keys */
+.foreignkey { }
+/* for the name cell of not null columns */
+.notnull { }

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/datamodel.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,45 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+<html>
+<head>
+  <title>$name</title>
+  <link rel="stylesheet" type="text/css" href="datamodel.css">
+</head>
+
+<body class="normalFont">
+  <table class="summarytable">
+    <tr class="summaryhead">
+      <th class="summaryheadbackground summaryborder summaryheadtablename">Table Name</th>
+      <th class="summaryheadbackground summaryborder summaryheadjavaname">OM Class</th>
+      <th class="summaryheadbackground summaryborder summaryheaddescription">Description</th>
+    </tr>
+  #set ($tableElements = $torqueGf.getChildren("table"))
+  #foreach ($tableElement in $tableElements)
+    #set ( $tableName = $tableElement.getAttribute("name") )
+    #set ( $tableJavaName = $tableElement.getAttribute("javaName") )
+    #set ( $tableDescription = $tableElement.getAttribute("description") )
+    <tr class=summaryrow">
+      <td class="summarybackground summaryborder summarytablename"><a href="#$tableName" class="link summarytablenamelink">$tableName</a></td>
+      <td class="summarybackground summaryborder summaryjavaname">$tableJavaName</td>
+      <td class="summarybackground summaryborder summarydescription">#if ($tableDescription) $tableDescription#else &nbsp;#end</td>
+    </tr>
+  #end
+  </table>
+
+  $torqueGf.mergepoint("tableDocs")
+</body>
+</html>

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/table.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/table.vm?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/table.vm (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/html/templates/table.vm Tue Feb 16 17:15:43 2010
@@ -0,0 +1,62 @@
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##   http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+<a name="$name"/>
+<h2>$name</h2>
+$!description
+<p/>
+<table class="detailtable">
+  <tr class="detailhead">
+    <th class="detailheadbackground detailborder detailheadname">Name</th>
+    <th class="detailheadbackground detailborder detailheadtype">Type</th>
+    <th class="detailheadbackground detailborder detailheadsize">Size</th>
+    <th class="detailheadbackground detailborder detailheaddefault">Default</th>
+    <th class="detailheadbackground detailborder detailheadjavaname">JavaName</th>
+    <th class="detailheadbackground detailborder detailheadpk">PK</th>
+    <th class="detailheadbackground detailborder detailheadfk">FK</th>
+    <th class="detailheadbackground detailborder detailheadnotnull">not null</th>
+    <th class="detailheadbackground detailborder detailheaddescription">Description</th>
+  </tr>
+#foreach ($columnElement in $torqueGf.getChildren("column"))
+  <tr class="detailrow">
+  #set ( $columnName = $columnElement.getAttribute("name"))
+  #set ( $columnSize = $columnElement.getAttribute("size"))
+  #set ( $columnDefault = $columnElement.getAttribute("default"))
+  #set ( $columnDescription = $columnElement.getAttribute("description"))
+  #set ( $columnPrimaryKey = $columnElement.getAttribute("primaryKey"))
+  #set ( $columnJavaName = $columnElement.getAttribute("javaName"))
+  #set ( $columnFieldType = $columnElement.getAttribute("fieldType"))
+  #set ( $columnRequired = $columnElement.getAttribute("required"))
+  #set ( $referencedColumnElements = $columnElement.getChildren("referenced-column"))
+  
+    <td class="detailbackground detailborder detailname#if ($columnPrimaryKey=="true") primarykey#end#if (!$referencedColumnElements.isEmpty()) foreignkey#end#if ($columnRequired=="true") notnull#end" id="$name$columnName">$columnName
+  #foreach ($referencedColumnElement in $referencedColumnElements)
+    #set ( $foreignColumnName = $referencedColumnElement.getChild("column").getAttribute("name") )
+    #set ( $foreignTableName = $referencedColumnElement.getChild("column").getParent().getAttribute("name") )
+    <a href="#$foreignTableName" title="Foreign key to $foreignTableName.${foreignColumnName}" class="link detailforeignkeylink">(fk)</a>
+  #end        
+        </td>
+    <td class="detailbackground detailborder detailtype">$columnFieldType</td>
+    <td class="detailbackground detailborder detailsize">#if ($columnSize && $columnSize.length() > 0) $columnSize #else &nbsp;#end</td>
+    <td class="detailbackground detailborder detaildefault">#if ($columnDefault) $columnDefault#else &nbsp;#end</td>
+    <td class="detailbackground detailborder detailjavaname">$columnJavaName</td>
+    <td class="detailbackground detailborder detailpk"><center> #if ($columnPrimaryKey=="true")X#else &nbsp;#end </center></td>
+    <td class="detailbackground detailborder detailfk"><center> #if (!$referencedColumnElements.isEmpty())X#else &nbsp;#end </center></td>
+    <td class="detailbackground detailborder detailnotnull"><center> #if ($columnRequired=="true")X#else &nbsp;#end </center></td>
+    <td class="detailbackground detailborder detaildescription">#if ($columnDescription) $columnDescription#else &nbsp;#end</td>
+  </tr>
+#end
+</table>

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/control.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<control loglevel="info"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/configuration.xsd"
+    xmlns="http://db.apache.org/torque/gf/4.0/configuration">
+  <options xsi:type="propertiesOptions" path="options.properties"/>
+  
+  <!-- Documentation xdoc -->
+  <output name="torque.doc.xdoc.xdoc"  file="datamodel.xml">
+    <source elements="database" path="*schema.xml">
+      <transformer class="org.apache.torque.templates.transformer.om.OMTransformer"/>
+    </source>
+    <generator name="torque.doc.xdoc.xdoc"/>
+  </output>
+</control>
+  
\ No newline at end of file

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/options.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/options.properties?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/options.properties (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/conf/options.properties Tue Feb 16 17:15:43 2010
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# replaces torque.correctGetters
+torque.om.useIsForBooleanGetters = true;
+
+torque.om.column.defaultType = VARCHAR

Added: db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/generatorDefs/xdoc.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/generatorDefs/xdoc.xml?rev=910600&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/generatorDefs/xdoc.xml (added)
+++ db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/doc/xdoc/generatorDefs/xdoc.xml Tue Feb 16 17:15:43 2010
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<generators xmlns="http://db.apache.org/torque/gf/4.0/configuration"
+    xsi:schemaLocation="http://db.apache.org/torque/gf/4.0/configuration http://db.apache.org/torque/gf/4.0/generator.xsd"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <generator name="torque.doc.xdoc.xdoc"
+      xsi:type="velocityGenerator" 
+      path="datamodel.vm">
+    <mergepoint name="tableDocs">
+      <action xsi:type="traverseAllAction"
+          element="table"
+          generator="torque.doc.xdoc.table"/>
+    </mergepoint>
+  </generator>
+  <generator name="torque.doc.xdoc.table"
+      xsi:type="velocityGenerator" 
+      path="table.vm">
+  </generator>
+</generators>
\ No newline at end of file



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