## 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 $torqueGen.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>
