## $Source: /usr/cvsroot/melati/melati/src/main/java/org/melati/admin/DSD.wm,v $
## $Revision: 1.26 $
##
## Copyright (C) 2002 Tim Pizey
##
## Part of Melati (http://melati.org), a framework for the rapid
## development of clean, maintainable web applications.
##
## Melati is free software; Permission is granted to copy, distribute
## and/or modify this software under the terms either:
##
## (a) the GNU General Public License as published by the Free Software
##    Foundation; either version 2 of the License, or (at your option)
##    any later version,
##
##    or
##
## (b) any version of the Melati Software License, as published
##    at http://melati.org
##
## You should have received a copy of the GNU General Public License and
## the Melati Software License along with this program;
## if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA to obtain the
## GNU General Public License and visit http://melati.org to obtain the
## Melati Software License.
##
## Feel free to contact the Developers of Melati (http://melati.org),
## if you would like to work out a different arrangement than the options
## outlined here.  It is our intention to allow Melati to be used by as
## wide an audience as possible.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## Contact details for copyright holder:
##
##     Tim Pizey <timp At paneris.org>
##
#set $melati.ResponseContentType = "text/plain"
## Add comments if user requests them
#if ($Form.comments) #begin
#set $c = true
#end
## Add comments if variable has been set in context
#if ($comments) #begin
#set $c = true
#end
## Add system, dynamically created and inherited tables if user requests them
#if ($Form.all) #begin
#set $all = true
#end
/*
 * DSD for $melati.Database ($melati.Database.Class.Name)
 * 
 *  Generated for $melati.getUser()
 * 
 * WARNING
 * This export is not necessarily information preserving.
 * 1) if you have used a capitalisation regime other than first 
 *    letter capital then the case  will not be preserved.
 * 2) Abstract tables are not preserved; the tables are 'de-normalised'.
 * 3) Importing another DSD, such as messageboards, is 
 *    not preserved, all tables are in a single package namespace.

#if (!$c) #begin
 *    
 * NOTE
 * This template can include comments for defaulted items
 * (add comments=true to URL)
#end
#if ($all) #begin
 *    
 * NOTE
 * This template includes all System and inherited tables, 
 * so should NOT be used to replace an existing DSD.
#end #else #begin 
 *    
 * NOTE
 * This template can include all system and inherited tables but then 
 * should NOT be used to replace an existing DSD.
 * (add all=true to URL)
#end
 *    
 */

package $(package);


#foreach $table in $melati.Database.getDisplayTables() #begin
#if ($table.Class.Name.indexOf($package) == 0 || $table.Class.Name.equals("org.melati.poem.JdbcTable") || $all) #begin
#if ($c) #begin
//   $table
//   $table.Class.Name
#end
table $table.Name


#foreach $field in $table.getInfo().getFields() #begin
#set $infoFieldClass = $field.getType().getClass().getName()
#if($field.getRaw() == null) #begin
#if ($c) #begin
  // ($field.getName() = null)
#end
#end #else #begin
#if ($field.getName() != "id") #begin
#if ($field.getName() != "name") #begin
#if($infoFieldClass.equals("org.melati.poem.StringPoemType")) #begin
  ($field.getName() = "$field.getCooked()")
#end #else #begin
#if($field.getName().equals("category")) #begin
  ($field.getName() = "$ml.rendered($field)")
#end #else #begin
#if($infoFieldClass.equals("org.melati.poem.BooleanPoemType")) #begin
#if ($field.getRaw().toString().equals("true")) #begin 
  ($field.getName())
#end #else #begin
#if ($c) #begin
  // Not $field.getName()
#end
#end 
#end #else #begin
  ($field.getName() = $ml.rendered($field))
#end
#end
#end
#end
#end
#end
#end
{

#foreach $column in $table.columns() #begin

#if ($c) #begin
    //$column 
#end
    $column.getType().toDsdType() $column.getName()

#if ($column.isTroidColumn()) #begin
      (primary)
#end
#foreach $field in $column.getColumnInfo().getDsdQualifiers() #begin
#set $infoFieldClass = $field.getType().getClass().getName()
#if($field.getRaw() == null) #begin
#if ($c) #begin
      // ($field.getName() = null)
#end
#end #else #begin
#if ($field.getName() == "size") #begin 
#if ($field.getRaw() == -1) #begin
      ($field.getName() = unlimited)
#end #else #begin
      ($field.getName() = $ml.rendered($field))
#end
#end #else #begin
#if($infoFieldClass.equals("org.melati.poem.StringPoemType")) #begin
      ($field.getName() = "$field.getCooked()")
#end #else #begin
#if($infoFieldClass.equals("org.melati.poem.BooleanPoemType")) #begin
#if ($field.getName().equals("usereditable")) #begin
#if ($field.getRaw().toString().equals("true")) #begin 
#if ($c) #begin
      // $field.getName()
#end
#end #else #begin
      (uneditable)
#end 
#end #else #begin
#if ($field.getName().equals("usercreateable")) #begin
#if ($field.getRaw().toString().equals("true")) #begin 
#if ($c) #begin
      // $field.getName()
#end
#end #else #begin
      (uncreateable)
#end 
#end #else #begin
#if ($field.getRaw().toString().equals("true")) #begin 
      ($field.getName())
#end #else #begin
#if ($c) #begin
      // Not $field.getName()
#end
#end 
#end
#end
#end #else #begin
      ($field.getName() = $ml.rendered($field))
#end
#end
#end
#end
#end
      ;
#end
 }

#end
#end


