## ============================================================================ ## Filename : FWAuditTrailDataClassTemplate.vm ## Note(s) : This template is used to generate the data class for tables ## with audit trail columns. ## ## 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 ## $packageName ## $prjPkgName ## $prjClassPrefix ## $superClassName ## $date ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import thinkui.db.DataClass; import thinkui.db.DateTimeColumn; import thinkui.db.DefaultDataClass; import thinkui.db.StringColumn; import thinkui.db.attribute.Attribute; import thinkui.db.attribute.AttributeAccess; /** * Extends DefaultDataClass to provide meta data for data objects with audit trail columns. */ public class ${className} extends DefaultDataClass { // Attribute names common to all AuditTrail objects. protected static final String CREATE_DATETIME = "CREATE_DATETIME"; protected static final String CREATE_USER = "CREATE_USER"; protected static final String UPDATE_DATETIME = "UPDATE_DATETIME"; protected static final String UPDATE_USER = "UPDATE_USER"; protected static final Attribute[] attrs = new Attribute[] { new DateTimeColumn( CREATE_DATETIME, "Create Datetime", true, AttributeAccess.RC).setEditable(false).setUpdatedByTrigger(true), new StringColumn( CREATE_USER, "Create User", true, 30, AttributeAccess.RC).setEditable(false), new DateTimeColumn( UPDATE_DATETIME, "Update Datetime", true, AttributeAccess.RW).setEditable(false).setUpdatedByTrigger(true), new StringColumn( UPDATE_USER, "Update User", true, 30, AttributeAccess.RW).setEditable(false)}; static final DataClass DATA_CLASS = new DefaultDataClass( ${className}.class, "${className}", attrs); /** * ${className} constructor. */ public ${className}( Class javaClass, String name, String namePrefix, Attribute[] attributes, String[] primaryKeyAttrNames, String[] captionKeyAttrNames) { super( javaClass, name, namePrefix, attributes, primaryKeyAttrNames, captionKeyAttrNames); // Automatically add the audit trail columns. addAttributes(DATA_CLASS); } /** * @return whether or not the specified attribute is an audit trail column. */ static final boolean isAuditTrailColumn(Attribute attribute) { return ( attribute.getName().equals(CREATE_DATETIME) || attribute.getName().equals(CREATE_USER) || attribute.getName().equals(UPDATE_DATETIME) || attribute.getName().equals(UPDATE_USER) ); } }