<?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,
                    s.layout_code,
                    NVL(lower(s.column_name),'DIV') 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,
                    t1.prompt,
                    DECODE(t1.input_mode, 'REQUIRED', '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 s.column_name IS NULL
                            THEN 'DIV'
                            WHEN s.column_name     IS NOT NULL AND
                                t1.validation_type IN ('COMBOBOX','LOV','TREE')
                            THEN DECODE(NVL(t1.lov_return_vcode, 'N'),'N',t1.validation_type,t1.validation_type
                                ||'_C')
                            ELSE t1.validation_type
                        END) validation_type,
                    t1.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,
                    t1.default_value,
                    hls_document_save_pkg.get_default_value_name(p_layout_code =>s.layout_code, p_tab_code =>s.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,
                    NVL(t1.width, NVL(lt.field_width,120)) width,
                    NVL(s.colspan,1) colspan,
                    NVL(s.rowspan,1) rowspan,
                    t1.key_field_flag,
                    t1.alignment,
                    NVL(t1.lov_return_vcode, 'N') lov_return_vcode,
                    s.tab_code,
                    NVL(t1.height,100) height,
                    t1.field_javascript,
                    DECODE(${/session/@lov_search_rule},'AUTOCOMPLETE','true','false') autocomplete,
                    DECODE(${/session/@lov_search_rule},'FETCHSINGLE','true','false') fetchsingle
                FROM
                    hls_doc_layout_config t1,
                    hls_doc_layout_screen s,
                    hls_doc_layout_tab lt #WHERE_CLAUSE#
                ORDER BY
                    s.order_seq
            ]]></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="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="required_input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REQUIRED_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="colspan" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COLSPAN"/>
        <bm:field name="rowspan" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ROWSPAN"/>
        <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="tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAB_CODE"/>
        <bm:field name="readonly_input_mode" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="READONLY_INPUT_MODE"/>
        <bm:field name="field_javascript" databaseType="CLOB" datatype="java.sql.Clob" physicalName="FIELD_JAVASCRIPT"/>
        <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:fields>
    <bm:query-fields>
        <bm:query-field field="layout_code" queryExpression="s.layout_code=${@layout_code}"/>
        <bm:query-field field="tab_code" queryExpression="s.tab_code=${@tab_code}"/>
        <bm:query-field name="form_tab_code" queryExpression="s.tab_code=${@form_tab_code}"/>
        <bm:query-field name="grid_tab_code" queryExpression="s.tab_code=${@grid_tab_code}"/>
        <bm:query-field field="column_name" queryExpression="s.column_name=upper(${@column_name})"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="column_name" enforceOperations="query" expression="(t1.layout_code(+) = s.layout_code and t1.column_name(+) = s.column_name and t1.tab_code(+)=s.tab_code and s.tab_code=lt.tab_code and s.layout_code=lt.layout_code)"/>
    </bm:data-filters>
</bm:model>
