## ============================================================================ ## Filename : CompositeObjectTemplate.vm ## Note(s) : This template is used to generate a CompositeObject class ## based on a database table/view foreign keys. ## ## 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 ## $packageName ## $prjPkgName ## $prjClassPrefix ## $dataClass ## $superClassName ## $date ## $relationships ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import java.util.HashMap; import thinkui.db.AbstractCompositeObject; import thinkui.db.DataObjectList; /** * Implements the ${className} CompositeObject. */ public class ${className} extends ${superClassName} { public static final String $codeGen.toConstantName($objectName)_COMPONENT_NAME = "$codeGen.toIdentifier($objectName)"; #foreach( $relationship in $relationships ) #set( $relationshipClassName = ${codeGen.getShortClassName(${relationship.getToDataClassName()})} ) #if ( ${relationship.getOrdinal()} < 0 ) #set( $relationshipVarName = ${codeGen.toPlural($relationshipClassName)} ) #else #set( $relationshipVarName = $relationshipClassName ) #end public static final String $codeGen.toConstantName($relationshipVarName)_COMPONENT_NAME = "$codeGen.toIdentifier(${codeGen.toClassName($relationshipVarName)})"; #end public static final java.util.Map DATA_CLASS_MAP = new HashMap(); static { DATA_CLASS_MAP.put($codeGen.toConstantName($objectName)_COMPONENT_NAME, ${objectName}.DATA_CLASS); #foreach( $relationship in $relationships ) #set( $relationshipClassName = ${codeGen.getShortClassName(${relationship.getToDataClassName()})} ) #if ( ${relationship.getOrdinal()} < 0 ) #set( $relationshipVarName = ${codeGen.toPlural($relationshipClassName)} ) #else #set( $relationshipVarName = $relationshipClassName ) #end DATA_CLASS_MAP.put(${codeGen.toConstantName($relationshipVarName)}_COMPONENT_NAME, ${codeGen.toClassName($relationshipClassName)}.DATA_CLASS); #end } /** * ${className} constructor. */ public ${className}() { super(); } public final java.util.Map getDataClassMap() { return DATA_CLASS_MAP; } public final ${objectName} get${objectName}() { return (${objectName}) getDataObject($codeGen.toConstantName($objectName)_COMPONENT_NAME); } public final void set${objectName}(${objectName} ${objectVar}) { setDataObject($codeGen.toConstantName($objectName)_COMPONENT_NAME, ${objectVar}); } #foreach( $relationship in $relationships ) #set( $relationshipClassName = ${codeGen.getShortClassName(${relationship.getToDataClassName()})} ) #if ( ${relationship.getOrdinal()} < 0 ) #set( $relationshipVarName = ${codeGen.toPlural($relationshipClassName)} ) public final DataObjectList get${codeGen.toClassName($relationshipVarName)}() { return (DataObjectList) getDataObjectList($codeGen.toConstantName($relationshipVarName)_COMPONENT_NAME); } public final void set${codeGen.toClassName($relationshipVarName)}(DataObjectList $codeGen.toIdentifier(${codeGen.toClassName($relationshipVarName)})) { setDataObjectList($codeGen.toConstantName($relationshipVarName)_COMPONENT_NAME, $codeGen.toIdentifier(${codeGen.toClassName($relationshipVarName)})); } #else #set( $relationshipVarName = $relationshipClassName ) public final ${codeGen.toClassName($relationshipVarName)} get${codeGen.toClassName($relationshipVarName)}() { return (${codeGen.toClassName($relationshipVarName)}) getDataObject($codeGen.toConstantName($relationshipVarName)_COMPONENT_NAME); } public final void set${codeGen.toClassName($relationshipVarName)}(${codeGen.toClassName($relationshipVarName)} $codeGen.toIdentifier(${codeGen.toClassName($relationshipVarName)})) { setDataObject($codeGen.toConstantName($relationshipVarName)_COMPONENT_NAME, $codeGen.toIdentifier(${codeGen.toClassName($relationshipVarName)})); } #end #end }