## ============================================================================ ## Filename : CommandTemplate.vm ## Note(s) : This template is used to generate a Command class based on a ## database table/view. ## ## Note: The generated code is dependent on the ThinkUI framework. ## Please refer to the SQL Client documentation for details. ## ## Copyright (c) 2007 ThinkUI Software Inc. All rights reserved. ## ============================================================================ ## ## **************************************************************************** ## The following variables are available in this template. For more ## information on any of the following variable, please refer to the user guide. ## **************************************************************************** ## $projectName ## $authorName ## $headerText ## $tableName ## $className ## $packageName ## $prjPkgName ## $prjClassPrefix ## $dataClass ## $superClassName ## $date ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import thinkui.command.AbstractCommand; import thinkui.command.CommandContext; import thinkui.command.Parameter; import thinkui.common.Utils; import thinkui.config.Config; import thinkui.db.DataClass; import thinkui.db.DefaultDataClass; import thinkui.db.attribute.Attribute; import thinkui.db.attribute.AttributeAccess; import thinkui.db.attribute.AttributeType; /** * Implements a command to... * TODO - Update the ${className} class comments. */ public class ${className} extends ${superClassName} { // Parameter names. #foreach( $attr in $dataClass.getAttributes() ) #if ($codeGen.isIncludeAttrName($attr.getName())) public static final String $attr.getName().toUpperCase() = "$attr.getName().toUpperCase()"; #end #end // Parameters. private static final Attribute[] attrs = new Attribute[] { #set( $firstItem = 1 ) #foreach( $attr in $dataClass.getAttributes() ) #if ($codeGen.isIncludeAttrName($attr.getName())) #if ($firstItem == 1) #set( $firstItem = 0 ) #else, #end new Parameter($attr.getName().toUpperCase(), "$attr.getCaption()", AttributeType.${codeGen.getAttributeTypeConstant($attr.getType())}, $attr.isRequired())#end#end}; public static final DataClass DATA_CLASS = new DefaultDataClass("$className", attrs).allowSelectOnly(); /** * ${className} constructor. */ public $className() { super(); } public final DataClass getDataClass() { return DATA_CLASS; } /** * @return whether or not the precondition for the command has been met. */ /* public final boolean isPrecondition(CommandContext commandContext) { return true; }*/ public final Object execute(CommandContext commandContext) throws Exception { // TODO - Implement the ${className}.execute() method. return NO_RESULT; } }