## ============================================================================ ## Filename : SearchCriteriaDataTemplate.vm ## Note(s) : This template is used to generate a Search Criteria Data 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 ## $className ## $objectName ## $objectVar ## $attrNames ## $packageName ## $subPackageName ## $prjPkgName ## $prjClassPrefix ## $dataClass ## $superClassName ## $date ## $auditTrailColumns ## $accessMethods ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import java.sql.Timestamp; import thinkui.common.SearchCriteriaData; import thinkui.db.Column; import thinkui.db.DataClass; import thinkui.db.DefaultDataClass; import thinkui.db.BigDecimalColumn; import thinkui.db.CharacterColumn; import thinkui.db.DoubleColumn; import thinkui.db.DateColumn; import thinkui.db.DateTimeColumn; import thinkui.db.FloatColumn; import thinkui.db.IntegerColumn; import thinkui.db.LongColumn; import thinkui.db.StringColumn; import thinkui.db.TextColumn; import thinkui.db.TimestampColumn; import thinkui.db.YNCharacterColumn; import thinkui.db.attribute.Attribute; import thinkui.db.attribute.AttributeAccess; import thinkui.db.attribute.AttributeType; import thinkui.db.attribute.StringLengthConstraints; import ${subPackageName}.objects.${objectName}; /** * Implements a SearchDataCriteria to search for ${objectName} objects. */ public class $className extends $superClassName { // Attribute names. #foreach( $attrName in ${attrNames} ) #if ($codeGen.isIncludeAttrName($attrName)) public static final String ${attrName.toUpperCase()} = ${objectName}.${attrName.toUpperCase()}; #end #end #if ($auditTrailColumns) public static final String FROM_CREATE_DATETIME = "FROM_" + ${objectName}.CREATE_DATETIME; public static final String TO_CREATE_DATETIME = "TO_" + ${objectName}.CREATE_DATETIME; #end private static final Attribute[] attrs = new Attribute[] { #set( $firstItem = 1 ) #foreach( $attrName in ${attrNames} ) #set( $attr = ${dataClass.getAttribute($attrName)} ) #if ($codeGen.isIncludeAttrName($attr.getName())) #if ($firstItem == 1) #set( $firstItem = 0 ) #else, #end ## -- old code ## new Column($attr.getName().toUpperCase(), "$attr.getCaption()", AttributeType.${codeGen.getAttributeTypeConstant($attr.getType())}, false) new ${codeGen.getAttributeTypeClassName($attr.getType())}Column($attr.getName().toUpperCase(), "$attr.getCaption()", false${codeGen.getConstraintsCode($attr)})#end#end #if ($auditTrailColumns) , new TimestampColumn(FROM_CREATE_DATETIME, "From Create Datetime", false).setComputed(true), new TimestampColumn(TO_CREATE_DATETIME, "To Create Datetime", false).setComputed(true)}; #else}; #end public static final DataClass DATA_CLASS = new DefaultDataClass(${className}.class, "${className}", attrs). addAttributes(SearchCriteriaData.DATA_CLASS); /** * $className constructor. */ public ${className}() { super(); } public final DataClass getDataClass() { return DATA_CLASS; } #if ($accessMethods) // // Access methods. // #foreach( $attr in $dataClass.getAttributes() ) /** * Convenience method to invoke getValue() for the ${attr.getName().toUpperCase()} attribute. * @return the ${attr.getName().toUpperCase()} attribute value. */ public final $codeGen.getAttributeTypeValueClassName($attr.getType()) get${codeGen.toTypeName($attr.getName())}Value() { return (${codeGen.getAttributeTypeValueClassName($attr.getType())}) getValue(${attr.getName().toUpperCase()}); } /** * Convenience method to invoke setValue() for the ${attr.getName().toUpperCase()} attribute. * Sets the ${attr.getName().toUpperCase()} attribute value. */ public final void set${codeGen.toTypeName($attr.getName())}Value($codeGen.getAttributeTypeValueClassName($attr.getType()) $codeGen.toVarName($attr.getName())) { setValue(${attr.getName().toUpperCase()}, ${codeGen.toVarName($attr.getName())}); } #end #if ($auditTrailColumns) /** * @return the From Create Datetime. */ public final Timestamp getFromCreateDatetime() { return (Timestamp) getValue(FROM_CREATE_DATETIME); } /** * Sets the From Create Datetime. */ public final void setFromCreateDatetime(Timestamp fromCreateDatetime) { setValue(FROM_CREATE_DATETIME, fromCreateDatetime); } /** * @return the To Create Datetime. */ public final Timestamp getToCreateDatetime() { return (Timestamp) getValue(TO_CREATE_DATETIME); } /** * Sets the To Create Datetime. */ public final void setToCreateDatetime(Timestamp toCreateDatetime) { setValue(TO_CREATE_DATETIME, toCreateDatetime); } #end #end }