Author: tfischer
Date: Mon Mar 19 19:14:08 2012
New Revision: 1302605
URL: http://svn.apache.org/viewvc?rev=1302605&view=rev
Log:
TORQUE-175: first attempt at generating SQL for views
TORQUE-184: remove defaultJavaNamingMethod and javaNamingMethod attributes
Added:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/view.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/viewColumn.vm
Modified:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd
Modified:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml?rev=1302605&r1=1302604&r2=1302605&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
(original)
+++
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/outlets/ddl.xml
Mon Mar 19 19:14:08 2012
@@ -46,6 +46,11 @@
element="table"
outlet="torque.sql.ddl.foreignKeySkipDecider"/>
</mergepoint>
+ <mergepoint name="views">
+ <action xsi:type="traverseAllAction"
+ element="view"
+ outlet="torque.sql.ddl.view"/>
+ </mergepoint>
<mergepoint name="comments">
<action xsi:type="traverseAllAction"
element="table"
@@ -190,4 +195,19 @@
<outlet name="torque.sql.ddl.foreignKey"
xsi:type="velocityOutlet"
path="ddl/${option:database}/foreignKey.vm" />
+
+ <outlet name="torque.sql.ddl.view"
+ xsi:type="velocityOutlet"
+ path="ddl/view.vm">
+ <mergepoint name="columns">
+ <action xsi:type="traverseAllAction"
+ element="column"
+ outlet="torque.sql.ddl.viewColumn"/>
+ </mergepoint>
+ </outlet>
+
+ <outlet name="torque.sql.ddl.viewColumn"
+ xsi:type="velocityOutlet"
+ path="ddl/viewColumn.vm">
+ </outlet>
</outlets>
\ No newline at end of file
Modified:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm?rev=1302605&r1=1302604&r2=1302605&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
(original)
+++
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/database.vm
Mon Mar 19 19:14:08 2012
@@ -18,5 +18,6 @@ $torqueGen.mergepoint("databaseStart")
$torqueGen.mergepoint("drop")
$torqueGen.mergepoint("tables")
$torqueGen.mergepoint("foreignKeys")
+$torqueGen.mergepoint("views")
$torqueGen.mergepoint("comments")
$torqueGen.mergepoint("databaseEnd")
\ No newline at end of file
Added:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/view.vm
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/view.vm?rev=1302605&view=auto
==============================================================================
---
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/view.vm
(added)
+++
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/view.vm
Mon Mar 19 19:14:08 2012
@@ -0,0 +1,29 @@
+## 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.
+#if (!$skipSql.equals("true"))##
+ #if (${createSql})##
+${createSql}##
+ #else
+CREATE OR REPLACE VIEW ${name} AS
+ SELECT
+ #set ( $cols = $torqueGen.mergepoint("columns") )
+ #set ( $lastCommaPos = $cols.lastIndexOf(","))
+ #if ($lastCommaPos == -1)${cols}#else${cols.substring(0,
$lastCommaPos)}#end
+
+ ${sqlSuffix};
+ #end
+#end
\ No newline at end of file
Added:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/viewColumn.vm
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/viewColumn.vm?rev=1302605&view=auto
==============================================================================
---
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/viewColumn.vm
(added)
+++
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/viewColumn.vm
Mon Mar 19 19:14:08 2012
@@ -0,0 +1,18 @@
+## 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.
+##
+ ${select} AS ${name},
Modified:
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd?rev=1302605&r1=1302604&r2=1302605&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd
(original)
+++
db/torque/torque4/trunk/torque-templates/src/main/resources/org/apache/torque/templates/xsd/database-4-0.xsd
Mon Mar 19 19:14:08 2012
@@ -96,6 +96,14 @@ Define table with its relevant attribute
</xs:documentation>
</xs:annotation>
</xs:element>
+ <xs:element name="view" type="viewType" minOccurs="0"
+ maxOccurs="unbounded" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+Define table with its relevant attributes.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
<xs:attribute name="name" type="javaNameType" use="required">
<xs:annotation>
@@ -130,28 +138,6 @@ i.e. it needs to be the superclass.
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="defaultJavaNamingMethod" use="optional"
- type="namingMethodType" default="underscore" >
- <xs:annotation>
- <xs:documentation xml:lang="en">
-This attribute determines how table or column names, from the name
-attribute of the table or column element, are converted to a Java
-class or method name respectively when creating the OM Java
-objects. There are three different options:
-
-- nochange
- Indicates no change is performed
-- underscore
- Underscores are removed, First letter is capitalized,
- first letter after an underscore is capitalized, the
- rest of the letters are converted to lowercase.
-- javaname
- Same as underscore, but no letters are converted to lowercase.
-- null
- Use the value previously set or the default value.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
<xs:attribute name="defaultJavaType" use="optional"
type="javaReturnType" default="primitive" >
<xs:annotation>
@@ -377,9 +363,8 @@ Whether or not to generate the class as
<xs:attribute name="javaName" type="javaNameType" use="optional" >
<xs:annotation>
<xs:documentation xml:lang="en">
-This is the Java class name to use when generating the Table or column. If
-this is missing the Java name is generated base on the Java Naming Method
-setting.
+This is the Java class name to use when generating the table. If
+this is missing the Java name is generated from the name attribute.
</xs:documentation>
</xs:annotation>
</xs:attribute>
@@ -400,27 +385,6 @@ the table generation SQL if the server t
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="javaNamingMethod" use="optional"
- type="namingMethodType" >
- <xs:annotation>
- <xs:documentation xml:lang="en">
-This attribute determines how the table and column names in this table
-definition are converted to a Java class or method name respectively when
-creating the OM Java objects. There are four different options:
-
-- nochange
- Indicates no change is performed
-- underscore
- Underscores are removed, First letter is capitalized, first letter
-after an underscore is capitalized, the rest of the letters are
-converted to lowercase.
-- javaname
- Same as underscore, but no letters are converted to lowercase.
-- null
- Use the value previously set or the default value.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
</xs:complexType>
<!-- =====================================
@@ -554,14 +518,6 @@ than public.
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="javaNamingMethod" use="optional"
- type="javaNameType" >
- <xs:annotation>
- <xs:documentation xml:lang="en">
-The method to use to convert the column name to a valid Java property name.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
<xs:attribute name="description" type="xs:string" use="optional" >
<xs:annotation>
<xs:documentation xml:lang="en">
@@ -792,6 +748,202 @@ The name to use in defining this constra
</xs:complexType>
<!-- =====================================
+ view element definition
+ ===================================== -->
+ <xs:complexType name="viewType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The view element and its relevant attributes.
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="option" type="optionType" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xs:element name="column" type="viewColumnType" maxOccurs="unbounded" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The column element and its relevant attributes
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="sqlNameType" use="required" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The name of the SQL view.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="baseClass" type="javaQualifiedNameType" use="optional">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The fully qualified class that the generated Java view
+record objects will extend. This class does not have to extend
+org.apache.torque.om.BaseObject.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="basePeer" type="javaQualifiedNameType" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The fully qualified class that the generated Java Peer objects will extend.
+Unlike baseClass, basePeer should extend BasePeer at some point in the chain,
+i.e. it needs to be the superclass.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="abstract" use="optional" type="xs:boolean"
+ default="false" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+Whether or not to generate the class as Abstract or not
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="javaName" type="javaNameType" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+This is the Java class name to use when generating the view. If
+this is missing the Java name is generated from the name attribute.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="sqlSuffix" type="xs:string" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The remainder of the sql for the view after column definitions.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="createSql" type="xs:string" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The complete SQL for creating the view. Overrides all other means
+of generating the SQL for view creation.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="skipSql" use="optional" type="xs:boolean"
+ default="false" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+Whether or not to skip SQL generation for this reference.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="description" type="xs:string" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+A description of this view.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+
+<!-- =====================================
+ view column element definition
+ ===================================== -->
+ <xs:complexType name="viewColumnType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The column element and its relevant attributes
+ </xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="option" type="optionType" minOccurs="0"
+ maxOccurs="unbounded" />
+ <xs:element name="inheritance" type="inheritanceType" minOccurs="0"
+ maxOccurs="unbounded" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+Define an inheritance mapping of records to class by a key column. See the
+inheritance How To document.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ </xs:sequence>
+ <xs:attribute name="name" type="sqlNameType" use="required" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The column name
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="type" use="required" type="sqlDataType">
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The SQL Standard data type for the column
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="size" type="xs:decimal" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The size of the field. E.g. Varchar(size) or Numeric(Size). Note that
+while this still supports the original torque use of using a
+decimal number (5.2) to indicate the precision
+and scale in one attribute. Use of the scale attribute is preferred.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="scale" type="xs:integer" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The scale of the field. E.g.decimal(size, scale)
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="javaName" type="javaNameType"
+ use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The Java property name to use for this column in the record objects.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="javaType" use="optional"
+ type="javaReturnType" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+Defines if the record object property getter / setters will
+use objects (e.g. Integer) or primitives (e.g. int), defaults
+to database attribute or primitive
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="domain" type="xs:string" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The domain reference name to set common settings.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="select" type="sqlNameType" use="required" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The sql snippet which contains the value to select.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="protected" use="optional"
+ type="xs:boolean" default="false" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+If true, the setters and getters for this property will be protected rather
+than public.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="description" type="xs:string" use="optional" >
+ <xs:annotation>
+ <xs:documentation xml:lang="en">
+The description of this column for documentation purposes.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+<!-- =====================================
Type definitions for attributes
===================================== -->
@@ -853,30 +1005,6 @@ none = Don't try to auto assign id n
</xs:restriction>
</xs:simpleType>
- <xs:simpleType name="namingMethodType">
- <xs:annotation>
- <xs:documentation xml:lang="en">
-This attribute determines how table or column names, from the name attribute
-of the table or column element, are converted to a Java class or method
-name respectively when creating the OM Java objects.
-defaultJavaNamingMethod can contain four different values:
-
-nochange = Indicates no change is performed
-underscore = Underscores are removed, First letter is capitalized,
- first letter after an underscore is capitalized, the
- rest of the letters are converted to lowercase.
-javaname = Same as underscore, but no letters are converted to lowercase.
-null = Use the value previously set or the default value.
- </xs:documentation>
- </xs:annotation>
- <xs:restriction base="xs:NMTOKEN">
- <xs:enumeration value="nochange" />
- <xs:enumeration value="underscore" />
- <xs:enumeration value="underscoreOmitSchema" />
- <xs:enumeration value="javaname" />
- </xs:restriction>
- </xs:simpleType>
-
<xs:simpleType name="javaReturnType">
<xs:restriction base="xs:NMTOKEN">
<xs:enumeration value="object" />
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]