<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-6-25 上午10:01:05  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.config_id,
                    t1.layout_code,
                    t1.tab_code,
                    lower(t1.column_name) column_name,
                    t1.data_type,
                    t1.system_flag,
                    NVL(t1.enabled_flag, 'N') enabled_flag,
                    NVL(t1.display_flag, 'N') display_flag,
                    t1.display_order,
                    (
                        CASE
                            WHEN t1.column_name = 'SALES_YEAR1'
                            THEN '销售额('
                                ||(TO_CHAR(sysdate,'yyyy')-3)
                                ||'年)'
                            WHEN t1.column_name = 'SALES_YEAR2'
                            THEN '销售额('
                                ||(TO_CHAR(sysdate,'yyyy')-2)
                                ||'年)'
                            WHEN t1.column_name = 'SALES_YEAR3'
                            THEN '销售额('
                                ||(TO_CHAR(sysdate,'yyyy')-1)
                                ||'年)'
                            WHEN t1.column_name = 'SALES_YEAR4'
                            THEN '销售额('
                                ||TO_CHAR(sysdate,'yyyy')
                                ||'年)'
                            ELSE t1.prompt
                        END) prompt,
                    t1.input_mode,
                    DECODE(t1.input_mode, 'REQUIRED', 'TRUE','REQUIRED_ONLY_ADD','TRUE','FALSE') required_input_mode,
                    (
                        CASE
                            WHEN ${@maintain_type}='READONLY' OR
                                lt.query_only     ='Y'
                            THEN 'TRUE'
                            ELSE DECODE(t1.input_mode, 'READONLY', 'TRUE', 'FALSE')
                        END) readonly_input_mode,
                    (
                        CASE
                            WHEN t1.validation_type IN ('COMBOBOX','LOV','TREE','LOV_D')
                            THEN DECODE(NVL(t1.lov_return_vcode, 'N'),'N',t1.validation_type,t1.validation_type
                                ||'_C')
                            ELSE t1.validation_type
                        END)validation_type,
                    NVL(t1.clob_validation_sql,t1.validation_sql) validation_sql,
                    NVL(t1.precision, 2) PRECISION,
                    NVL(t1.zero_fill, 'FALSE') zero_fill,
                    NVL(t1.allow_format, 'FALSE') allow_format,
                    NVL(t1.allow_decimal, 'FALSE') allow_decimal,
                    t1.percent,
                    hls_document_save_pkg.get_default_value(p_default_value=>t1.default_value,p_validation_type=>t1.validation_type,p_user_id =>${/session/@user_id}) default_value,
                    hls_document_save_pkg.get_default_value_name(p_layout_code =>t1.layout_code, p_tab_code =>t1.tab_code, p_column_name =>t1.column_name, p_validation_type =>t1.validation_type, p_user_id =>${/session/@user_id},p_session_id=>${/session/@session_id}) default_value_name,
                    t1.upper_limit,
                    t1.lower_limit,
                    (
                        CASE
                            WHEN lt.tab_type='FIELDBOXCOLUMN'
                            THEN NVL(t1.width, lt.field_width)
                            ELSE NVL(t1.width, 120)
                        END)width,
                    t1.key_field_flag,
                    NVL(t1.alignment,'center') alignment,
                    NVL(t1.lov_return_vcode, 'N') lov_return_vcode,
                    t1.copy_from_parent_tab,
                    t1.height,
                    DECODE(${/session/@lov_search_rule},'AUTOCOMPLETE','true','false') autocomplete,
                    DECODE(${/session/@lov_search_rule},'FETCHSINGLE','true','false') fetchsingle,
                    DECODE(t1.footerrenderer,'Y','sumFunction','') footerrenderer,
                    (
                        CASE
                            WHEN t1.validation_type IN ('TEXTFIELD','TEXTAREA')
                            THEN DECODE(sys_parameter_pkg.value('SYS_GRID_SHOW_TITLE',${/session/@user_id},${/session/@role_id},${/session/@company_id}),'Y','true','false')
                            ELSE 'false'
                        END) sys_grid_show_title,
                    lower(t1.lov_cascade_para1) lov_cascade_para1,
                    lower(t1.lov_cascade_para2) lov_cascade_para2,
                    lower(t1.lov_cascade_para3) lov_cascade_para3,
                    t1.field_javascript,
                    t1.underline,
                    t1.field_group,
                    lt.query_only,
                    t1.switchcard_tab_code,
                    t1.base_tab_code,
                    t1.ignore_required,
                    NVL(t1.field_bak_flag,'N') field_bak_flag,
                    NVL(t1.lov_width,600) lov_width,
                    NVL(t1.lov_height,520) lov_height,
                    (NVL(t1.lov_height,520))*0.67 lovgridheight
                FROM
                    hls_doc_layout_config t1,
                    hls_doc_layout_tab lt #WHERE_CLAUSE#
                ORDER BY
                    t1.display_order
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="config_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONFIG_ID"/>
        <bm:field name="layout_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAYOUT_CODE"/>
        <bm:field name="tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAB_CODE"/>
        <bm:field name="column_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COLUMN_NAME"/>
        <bm:field name="data_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DATA_TYPE"/>
        <bm:field name="system_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SYSTEM_FLAG"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG"/>
        <bm:field name="display_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DISPLAY_FLAG"/>
        <bm:field name="display_order" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DISPLAY_ORDER"/>
        <bm:field name="prompt" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROMPT"/>
        <bm:field name="input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="INPUT_MODE"/>
        <bm:field name="required_input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REQUIRED_INPUT_MODE"/>
        <bm:field name="readonly_input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="READONLY_INPUT_MODE"/>
        <bm:field name="validation_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VALIDATION_TYPE"/>
        <bm:field name="validation_sql" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VALIDATION_SQL"/>
        <bm:field name="precision" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PRECISION"/>
        <bm:field name="zero_fill" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ZERO_FILL"/>
        <bm:field name="allow_format" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ALLOW_FORMAT"/>
        <bm:field name="allow_decimal" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ALLOW_DECIMAL"/>
        <bm:field name="percent" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PERCENT"/>
        <bm:field name="default_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DEFAULT_VALUE"/>
        <bm:field name="default_value_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DEFAULT_VALUE_NAME"/>
        <bm:field name="upper_limit" databaseType="NUMBER" datatype="java.lang.Long" physicalName="UPPER_LIMIT"/>
        <bm:field name="lower_limit" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOWER_LIMIT"/>
        <bm:field name="width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WIDTH"/>
        <bm:field name="height" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HEIGHT"/>
        <bm:field name="key_field_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="KEY_FIELD_FLAG"/>
        <bm:field name="alignment" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ALIGNMENT"/>
        <bm:field name="lov_return_vcode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_RETURN_VCODE"/>
        <bm:field name="copy_from_parent_tab" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COPY_FROM_PARENT_TAB"/>
        <bm:field name="autocomplete" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="AUTOCOMPLETE"/>
        <bm:field name="fetchsingle" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FETCHSINGLE"/>
        <bm:field name="footerrenderer" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FOOTERRENDERER"/>
        <bm:field name="sys_grid_show_title" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SYS_GRID_SHOW_TITLE"/>
        <bm:field name="lov_cascade_para1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_CASCADE_PARA1"/>
        <bm:field name="lov_cascade_para2" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_CASCADE_PARA2"/>
        <bm:field name="lov_cascade_para3" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOV_CASCADE_PARA3"/>
        <bm:field name="underline" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="UNDERLINE"/>
        <bm:field name="query_only" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="QUERY_ONLY"/>
        <bm:field name="switchcard_tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SWITCHCARD_TAB_CODE"/>
        <bm:field name="field_javascript" databaseType="CLOB" datatype="java.sql.Clob" physicalName="FIELD_JAVASCRIPT"/>
        <bm:field name="field_group" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FIELD_GROUP"/>
        <bm:field name="base_tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BASE_TAB_CODE"/>
        <bm:field name="field_bak_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIELD_BAK_FLAG"/>
        <bm:field name="ignore_required" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="IGNORE_REQUIRED"/>
        <bm:field name="lov_width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOV_WIDTH"/>
        <bm:field name="lov_height" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOV_HEIGHT"/>
        <bm:field name="lovgridheight" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LOVGRIDHEIGHT"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="layout_code" queryExpression="t1.layout_code=${@layout_code}"/>
        <bm:query-field field="enabled_flag" queryExpression="t1.enabled_flag=${@enabled_flag}"/>
        <bm:query-field field="display_flag" queryExpression="t1.display_flag=${@display_flag}"/>
        <bm:query-field field="tab_code" queryExpression="t1.tab_code=${@tab_code}"/>
        <bm:query-field field="column_name" queryExpression="t1.column_name=upper(${@column_name})"/>
        <bm:query-field field="switchcard_tab_code" queryOperator="="/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="(t1.layout_code=lt.layout_code and t1.tab_code=lt.tab_code)"/>
    </bm:data-filters>
</bm:model>
