All Downloads are FREE. Search and download functionalities are using the official Maven repository.

templates.velocity.java5g.perschema.constant.vm Maven / Gradle / Ivy

There is a newer version: 5.2.0
Show newest version
#parse( "schema.include.vm" )
#parse( "header.include.vm" )
#set ( $javaClassName = 'Constant' )

$codewriter.setCurrentJavaFilename($pkg, "${javaClassName}.java")
#if(${codewriter.getProperty('manager.alias')})
#set ( $aliasName = """${codewriter.getProperty('manager.alias')}""" )
#else
#set ( $aliasName = 'null' )
#end
package $pkg;

import java.util.List;
import java.util.Arrays;
import java.util.Set;
import java.util.Collections;
import java.util.LinkedHashSet;

#if($constAnnotSupport)
import gu.sql2java.BaseRow;
import gu.sql2java.annotations.SchemaComponent;
import gu.sql2java.annotations.SchemaConstantSupplier;
#end

#####################
/**
 * constant declare
 * @author guyadong
 */
#if($constAnnotSupport)
@SchemaComponent 
#end
public interface $javaClassName extends gu.sql2java.Constant {

    /** alias name of connection */
#constantSupplier("ALIAS_NAME")
    public static String ALIAS_NAME = $aliasName;
    /** same prefix of all tablename */
#constantSupplier("SAME_PREFIX")
    public static String SAME_PREFIX = "$db.samePrefix";
#if($constAnnotSupport)
    //////////////////////////////////////
    // TABLE CLASS DECLARE
    //////////////////////////////////////    
#foreach($t in $tables)
#constantSupplier($t.asConstantVar("_CLASS"))
    public static final Class ${t.name.toUpperCase()}_CLASS = ${t.asBeanClass($isGeneral)}.class;
#end
#end
    //////////////////////////////////////
    // COLUMN COLUMN CONSTANT
    //////////////////////////////////////    
    #join($tables '
#constantSupplier($e.asConstantVar("_COLUMN_COUNT"))
    public static final int ${e.name.toUpperCase()}_COLUMN_COUNT = $e.countColumns();
    public static final int ${e.name.toUpperCase()}_COLUMN_BIT_MAX = $e.stateBitMaxCount();
#constantSupplier($e.asConstantVar("_PK_COUNT"))
    public static final int ${e.name.toUpperCase()}_PK_COUNT = $e.countPrimaryKeys();' '')

    //////////////////////////////////////
    // COLUMN ID DECLARE
    //////////////////////////////////////    
#foreach($t in $tables)
#foreach ( $column in $t.columns )
#set ( $vcmo = $velocityCount - 1 )
    /** Identify the $column.getFullName() field (ordinal:$column.getOrdinalPosition()). */
#constantSupplier($column.getIDAssociated())
    public static final int $column.getIDConstName() = $vcmo;
#end
#end
    //////////////////////////////////////
    // COLUMN NAME DECLARE
    //////////////////////////////////////    
#foreach($t in $tables)
    /////////////////// $t.name ////////////
#constantSupplier($t.asConstantVar("_NAME"))
    public static final String ${t.name.toUpperCase()}_NAME = "$t.name";

#constantSupplier($t.asConstantVar("_LOCAL_COLUMNS"))
    public static final String[] ${t.name.toUpperCase()}_LOCAL_COLUMNS = new String[]{#join($t.getColumnsByVisibility('LOCAL') '"$e.name"' ',')};
#constantSupplier($t.asConstantVar("_LOCAL_COLUMN_LIST"))
    public static final List ${t.name.toUpperCase()}_LOCAL_COLUMN_LIST = Collections.unmodifiableList(Arrays.asList(${t.name.toUpperCase()}_LOCAL_COLUMNS));
#constantSupplier($t.asConstantVar("_LOCAL_COLUMN_SET"))
    public static final Set ${t.name.toUpperCase()}_LOCAL_COLUMN_SET = Collections.unmodifiableSet(new LinkedHashSet<>($t.name.toUpperCase()_LOCAL_COLUMN_LIST));
#constantSupplier($t.asConstantVar("_THRIFT_COLUMNS"))
    public static final String[] ${t.name.toUpperCase()}_THRIFT_COLUMNS = new String[]{#join($t.getColumnsByVisibility('THRIFT') '"$e.name"' ',')};
#constantSupplier($t.asConstantVar("_THRIFT_COLUMNS_LIST"))
    public static final List ${t.name.toUpperCase()}_THRIFT_COLUMN_LIST = Collections.unmodifiableList(Arrays.asList(${t.name.toUpperCase()}_THRIFT_COLUMNS));
#constantSupplier($t.asConstantVar("_THRIFT_COLUMNS_SET"))
    public static final Set ${t.name.toUpperCase()}_THRIFT_COLUMN_SET = Collections.unmodifiableSet(new LinkedHashSet<>($t.name.toUpperCase()_THRIFT_COLUMN_LIST));
#constantSupplier($t.asConstantVar("_JSON_COLUMNS"))
    public static final String[] ${t.name.toUpperCase()}_JSON_COLUMNS = new String[]{#join($t.getColumnsByVisibility('JSON') '"$e.name"' ',')};
#constantSupplier($t.asConstantVar("_JSON_COLUMNS_LIST"))
    public static final List ${t.name.toUpperCase()}_JSON_COLUMN_LIST = Collections.unmodifiableList(Arrays.asList(${t.name.toUpperCase()}_JSON_COLUMNS));
#constantSupplier($t.asConstantVar("_JSON_COLUMNS_SET"))
    public static final Set ${t.name.toUpperCase()}_JSON_COLUMN_SET = Collections.unmodifiableSet(new LinkedHashSet<>($t.name.toUpperCase()_JSON_COLUMN_LIST));

    /** Contains all the pk fields name of the $t.name table.*/
#constantSupplier($t.asConstantVar("_PK_FIELDS"))
    public static final String $t.name.toUpperCase()_PK_FIELDS ="#join($t.primaryKeys '$e.name' '"
                            + ",')";
#constantSupplier($t.asConstantVar("_PK_FIELDS_LIST"))
    public static final List $t.name.toUpperCase()_PK_FIELDS_LIST = #if(${t.primaryKeys.size()} == 0)Collections.emptyList()#{else}Arrays.asList(${t.name.toUpperCase()}_PK_FIELDS.split(","))#end;
    /** Contains all the full fields of the $t.name table.*/
#constantSupplier($t.asConstantVar("_FULL_FIELDS"))
    public static final String $t.name.toUpperCase()_FULL_FIELDS ="#join($t.columns '$e.fullName' '"
                            + ",')";
#constantSupplier($t.asConstantVar("_FULL_FIELDS_LIST"))
    public static final List $t.name.toUpperCase()_FULL_FIELDS_LIST = Collections.unmodifiableList(Arrays.asList(${t.name.toUpperCase()}_FULL_FIELDS.split(",")));
#constantSupplier($t.asConstantVar("_FULL_FIELDS_SET"))
    public static final Set $t.name.toUpperCase()_FULL_FIELDS_SET = Collections.unmodifiableSet(new LinkedHashSet<>($t.name.toUpperCase()_FULL_FIELDS_LIST));
    /** Field that contains the comma separated fields of the $t.name table. */
#constantSupplier($t.asConstantVar("_FIELDS"))
    public static final String $t.name.toUpperCase()_FIELDS = "#join($t.columns '$e.name' '"
                            + ",')";
#constantSupplier($t.asConstantVar("_FIELDS_LIST"))
    public static final List $t.name.toUpperCase()_FIELDS_LIST = Collections.unmodifiableList(Arrays.asList(${t.name.toUpperCase()}_FIELDS.split(",")));
#constantSupplier($t.asConstantVar("_FIELDS_SET"))
    public static final Set $t.name.toUpperCase()_FIELDS_SET = Collections.unmodifiableSet(new LinkedHashSet<>($t.name.toUpperCase()_FIELDS_LIST));
    
#join($t.columns '##
#constantSupplier($e.getNameAssociated())
    public static final String $e.nameConstName = "$e.name";
' '')##

    /** Field that contains the comma separated java fields of the $t.name table. */
#constantSupplier($t.asConstantVar("_JAVA_FIELDS"))
    public static final String $t.name.toUpperCase()_JAVA_FIELDS = "#join($t.columns '$e.varName' '"
                            + ",')";
#constantSupplier($t.asConstantVar("_JAVA_FIELDS_LIST"))
    public static final List $t.name.toUpperCase()_JAVA_FIELDS_LIST = Collections.unmodifiableList(Arrays.asList(${t.name.toUpperCase()}_JAVA_FIELDS.split(",")));
#constantSupplier($t.asConstantVar("_JAVA_FIELDS_SET"))
    public static final Set $t.name.toUpperCase()_JAVA_FIELDS_SET = Collections.unmodifiableSet(new LinkedHashSet<>($t.name.toUpperCase()_JAVA_FIELDS_LIST));

    /** column type names of the $t.name table. */
#constantSupplier($t.asConstantVar("_COLUMN_TYPE_NAMES"))
    public static final String[] $t.name.toUpperCase()_COLUMN_TYPE_NAMES = new String[]{
        #join($t.columns '"${e.typeName}"' ',
        ')};

#constantSupplier($t.asConstantVar("_COLUMN_TYPE_NAME_LIST"))
    public static final List $t.name.toUpperCase()_COLUMN_TYPE_NAME_LIST = Collections.unmodifiableList(Arrays.asList(${t.name.toUpperCase()}_COLUMN_TYPE_NAMES));

    /** Field java types of the $t.name table. */
#constantSupplier($t.asConstantVar("_FIELD_TYPES"))
    public static final Class[] $t.name.toUpperCase()_FIELD_TYPES = new Class[]{
        #join($t.columns '${e.getJavaType()}.class' ',
        ')};
    /** Field size of the $t.name table. */
#constantSupplier($t.asConstantVar("_FIELD_SIZES"))
    public static final int[] $t.name.toUpperCase()_FIELD_SIZES = new int[]{
        #join($t.columns '${e.size}' ',
        ')};
    /** Field SQL types of the $t.name table. */
#constantSupplier($t.asConstantVar("_FIELD_SQL_TYPES"))
    public static final int[] $t.name.toUpperCase()_FIELD_SQL_TYPES = new int[]{
        #join($t.columns '${e.type}/*${e.javaTypeAsTypeName}*/' ',
        ')};
#end
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy