<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-6-18 下午3:47:27  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HLS_DOC_LAYOUT_TAB" defaultOrderBy="tab_seq">
    <bm:fields>
        <bm:field name="layout_code" databaseType="VARCHAR2" datatype="java.lang.String" forUpdate="false" physicalName="LAYOUT_CODE" prompt="HLS030.HLS_DOC_LAYOUT.LAYOUT_CODE"/>
        <bm:field name="tab_code" databaseType="VARCHAR2" datatype="java.lang.String" forUpdate="false" physicalName="TAB_CODE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_CODE"/>
        <bm:field name="tab_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAB_DESC" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_DESC"/>
        <bm:field name="tab_seq" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TAB_SEQ" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_SEQ"/>
        <bm:field name="tab_group" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TAB_GROUP" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_GROUP"/>
        <bm:field name="base_table" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BASE_TABLE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.BASE_TABLE"/>
        <bm:field name="query_source" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="QUERY_SOURCE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.QUERY_SOURCE"/>
        <bm:field name="row_count" databaseType="NUMBER" datatype="java.lang.Long" insertExpression="" physicalName="ROW_COUNT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.ROW_COUNT"/>
        <bm:field name="column_count" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COLUMN_COUNT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.COLUMN_COUNT"/>
        <bm:field name="field_width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FIELD_WIDTH" prompt="HLS030.HLS_DOC_LAYOUT_TAB.FIELD_WIDTH"/>
        <bm:field name="label_width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LABEL_WIDTH" prompt="HLS030.HLS_DOC_LAYOUT_TAB.LABEL_WIDTH"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS.ENABLED_FLAG"/>
        <bm:field name="configurable" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONFIGURABLE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.CONFIGURABLE"/>
        <bm:field name="margin_top" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MARGIN_TOP" prompt="HLS030.HLS_DOC_LAYOUT_TAB.MARGIN_TOP"/>
        <bm:field name="margin_height" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MARGIN_HEIGHT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.MARGIN_HEIGHT"/>
        <bm:field name="margin_width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MARGIN_WIDTH" prompt="HLS030.HLS_DOC_LAYOUT_TAB.MARGIN_WIDTH"/>
        <bm:field name="box_width" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BOX_WIDTH" prompt="HLS030.HLS_DOC_LAYOUT_TAB.BOX_WIDTH"/>
        <bm:field name="show_box" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SHOW_BOX" prompt="HLS030.HLS_DOC_LAYOUT_TAB.SHOW_BOX"/>
        <bm:field name="parent_tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARENT_TAB_CODE"/>
        <bm:field name="parent_tab_desc" forInsert="false" forUpdate="false" prompt="HLS030.HLS_DOC_LAYOUT_TAB.PARENT_TAB_CODE"/>
        <bm:field name="tab_type" databasetype="VARCHAR2" datatype="java.lang.String" physicalname="TAB_TYPE"/>
        <bm:field name="repeat_object" databasetype="VARCHAR2" datatype="java.lang.String" physicalname="REPEAT_OBJECT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.REPEAT_OBJECT"/>
        <bm:field name="tree_level" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TREE_LEVEL" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TREE_LEVEL"/>
        <bm:field name="tab_type_desc" forInsert="false" forUpdate="false" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_TYPE"/>
        <bm:field name="base_table_pk" databasetype="VARCHAR2" datatype="java.lang.String" physicalName="BASE_TABLE_PK"/>
        <bm:field name="parent_table" databasetype="VARCHAR2" datatype="java.lang.String" physicalName="PARENT_TABLE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.PARENT_TABLE"/>
        <bm:field name="parent_tab_code_flag" forInsert="false" forUpdate="false"/>
        <bm:field name="parent_table_flag" forInsert="false" forUpdate="false"/>
        <bm:field name="ref_tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_TAB_CODE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.REF_TAB_CODE"/>
        <bm:field name="tab_ref_screen" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAB_REF_SCREEN" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TAB_REF_SCREEN"/>
        <bm:field name="tree_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TREE_CODE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.TREE_CODE"/>
        <bm:field name="tabpannel_marginwidth" forInsert="false" forUpdate="false"/>
        <bm:field name="parent_base_table_pk" forInsert="false" forUpdate="false"/>
        <bm:field name="parent_tree_code" forInsert="false" forUpdate="false"/>
        <bm:field name="setup_height" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SETUP_HEIGHT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.SETUP_HEIGHT"/>
        <bm:field name="setup_width" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SETUP_WIDTH" prompt="HLS030.HLS_DOC_LAYOUT_TAB.SETUP_WIDTH"/>
        <bm:field name="width" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WIDTH" prompt="HLS030.HLS_DOC_LAYOUT_TAB.WIDTH"/>
        <bm:field name="height" databaseType="NUMBER" datatype="java.lang.Long" physicalName="HEIGHT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.HEIGHT"/>
        <bm:field name="setup_height_desc" forInsert="false" forUpdate="false" prompt="HLS030.HLS_DOC_LAYOUT_TAB.SETUP_HEIGHT"/>
        <bm:field name="setup_width_desc" forInsert="false" forUpdate="false" prompt="HLS030.HLS_DOC_LAYOUT_TAB.SETUP_WIDTH"/>
        <bm:field name="repeat_bindertarget_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REPEAT_BINDERTARGET_FLAG" prompt="HLS030.HLS_DOC_LAYOUT_TAB.REPEAT_BINDERTARGET_FLAG"/>
        <bm:field name="root_tree_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ROOT_TREE_CODE" prompt="HLS030.HLS_DOC_LAYOUT_TAB.ROOT_TREE_CODE"/>
        <bm:field name="parent_loaded_object" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARENT_LOADED_OBJECT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.PARENT_LOADED_OBJECT"/>
        <bm:field name="attachment_tab_group" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ATTACHMENT_TAB_GROUP" prompt="HLS030.HLS_DOC_LAYOUT_TAB.ATTACHMENT_TAB_GROUP"/>
        <bm:field name="repeat_bindname_object" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REPEAT_BINDNAME_OBJECT" prompt="HLS030.HLS_DOC_LAYOUT_TAB.REPEAT_BINDNAME_OBJECT"/>
        <bm:field name="query_only" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="attachment_tab_group_code" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="query_tab_code" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="fieldWidth" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="fieldHeight" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="check_before_delete_bm" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="check_after_save_bm" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="switchcard_value" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="recreate_ds_flag" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="fetchall" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="is_selected_flag" databaseType="VARCHAR2" datatype="java.lang.String"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    		select t1.layout_code,
			       t1.tab_code,
			       t1.tab_desc,
			       t1.tab_seq,
			       t1.tab_group,
			       lower(t1.base_table) base_table,
			       t1.query_source,
			       t1.row_count,
			       t1.column_count,
			       t1.enabled_flag,
			       t1.created_by,
			       t1.creation_date,
			       t1.last_updated_by,
			       t1.last_update_date,
			       t1.configurable,
			       t1.field_width,
			       t1.label_width,
			       t1.margin_top,
			       t1.box_width,
			       t1.show_box,
			       t1.parent_tab_code,
			       t1.parent_tab_desc,
			       lower(t1.parent_table) parent_table,
			       t1.base_table_pk,
			       lower(nvl((select d.base_table_pk from hls_doc_layout_tab_v d where d.layout_code=t1.layout_code and d.base_table=t1.parent_table and rownum=1),t1.base_table_pk)) parent_base_table_pk,
			       t1.tab_type,
			       t1.tab_type_desc,
			       decode(t1.base_table,
              		null,
              		'N',
              		decode((select 1
                       from dual
                      where exists (select 1
                               from hls_doc_layout_tab t
                              where t.layout_code = t1.layout_code
                                and t.base_table = t1.base_table
                                and t.tab_seq < t1.tab_seq)),
                     1,
                     'N',
                     'Y')) parent_tab_code_flag,
                    decode(t1.parent_table,'','N','Y') parent_table_flag,
                    t1.tree_code,
                    (select d.parent_tree_code from hls_doc_layout_tree d where d.tree_code=t1.tree_code and d.layout_code=t1.layout_code)parent_tree_code,
                    t1.ref_tab_code,
                    t1.tab_ref_screen,
                    t1.tree_level,
                    70*nvl(t1.tree_level,1) tabpannel_marginwidth,
                    nvl(t1.margin_width,70) margin_width,
                    nvl(t1.margin_height,70) margin_height,
                    t1.repeat_object,
                    t1.setup_height,
                    (select s.code_value_name from sys_code_values_v s where s.code='HLS_SETUP_HEIGHT' and s.code_value=t1.setup_height)setup_height_desc,
                    (select s.code_value_name from sys_code_values_v s where s.code='HLS_SETUP_WIDTH' and s.code_value=t1.setup_width)setup_width_desc,
				    t1.setup_width,
				    t1.width,
				    t1.height,
				    t1.repeat_bindertarget_flag,
       				t1.root_tree_code,
       				t1.parent_loaded_object,
    			    t1.attachment_tab_group,
    			    (select t.tab_group from prj_cdd_item_tab_group t 
    			         where t.tab_group_id=t1.attachment_tab_group)attachment_tab_group_code,
    			    t1.repeat_bindname_object,
    			    t1.query_only,
    			    t1.query_tab_code,
    			    t1.fieldwidth,
    			    t1.fieldheight,
    			    t1.check_before_delete_bm,
          			t1.check_after_save_bm,
          			t1.switchcard_value,
          			t1.recreate_ds_flag,
          			t1.fetchall,
          			t1.is_selected_flag
			  from hls_doc_layout_tab_v t1
			  #WHERE_CLAUSE#
		     order by t1.enabled_flag desc,tab_seq
    	 ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
        		begin
        			  HLS030_SAVE_PKG.tab_manage(p_sql_type                 => 'INSERT',
					                             p_layout_code              => ${@layout_code},
					                             p_tab_code                 => ${@tab_code},
					                             p_tab_type                 => ${@tab_type},
					                             p_tab_desc                 => ${@tab_desc},
					                             p_enabled_flag             => ${@enabled_flag},
					                             p_parent_tab_code          => ${@parent_tab_code},
					                             p_tab_seq                  => ${@tab_seq},
					                             p_tab_group                => ${@tab_group},
					                             p_base_table               => ${@base_table},
					                             p_base_table_pk            => ${@base_table_pk},
					                             p_base_table_field         => ${@base_table_field},
					                             p_query_source             => ${@query_source},
					                             p_parent_table             => ${@parent_table},
					                             p_configurable             => ${@configurable},
					                             p_row_count                => ${@row_count},
					                             p_column_count             => ${@column_count},
					                             p_label_width              => ${@label_width},
					                             p_field_width              => ${@field_width},
					                             p_margin_top               => ${@margin_top},
					                             p_margin_height            => ${@margin_height},
					                             p_margin_width             => ${@margin_width},
					                             p_show_box                 => ${@show_box},
					                             p_box_width                => ${@box_width},
					                             p_tree_code                => ${@tree_code},
					                             p_tree_level               => ${@tree_level},
					                             p_repeat_object            => ${@repeat_object},
					                             p_ref_tab_code             => ${@ref_tab_code},
					                             p_tab_ref_screen           => ${@tab_ref_screen},
					                             p_user_id                  => ${/session/@user_id},
					                             p_repeat_bindertarget_flag => ${@repeat_bindertarget_flag},
					                             p_root_tree_code           => ${@root_tree_code},
					                             p_setup_height             => ${@setup_height},
					                             p_height                   => ${@height},
					                             p_setup_width              => ${@setup_width},
					                             p_width                    => ${@width},
					                             p_parent_loaded_object     => ${@parent_loaded_object},
					                             p_attachment_tab_group     => ${@attachment_tab_group},
					                             p_repeat_bindname_object   => ${@repeat_bindname_object},
					                             p_query_only               => ${@query_only},
					                             p_query_tab_code           =>${@query_tab_code},
					                             p_fieldwidth               =>${@fieldwidth},
					                             p_fieldheight              =>${@fieldheight},
					                             p_check_before_delete_bm   =>${@check_before_delete_bm},
					                             p_check_after_save_bm      =>${@check_after_save_bm},
					                             p_switchcard_value         =>${@switchcard_value},
					                             p_recreate_ds_flag         =>${@recreate_ds_flag},
					                             p_fetchall                 =>${@fetchall},
					                             p_is_selected_flag         =>${@is_selected_flag});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            	begin
        			  HLS030_SAVE_PKG.tab_manage(p_sql_type                 => 'UPDATE',
					                             p_layout_code              => ${@layout_code},
					                             p_tab_code                 => ${@tab_code},
					                             p_tab_type                 => ${@tab_type},
					                             p_tab_desc                 => ${@tab_desc},
					                             p_enabled_flag             => ${@enabled_flag},
					                             p_parent_tab_code          => ${@parent_tab_code},
					                             p_tab_seq                  => ${@tab_seq},
					                             p_tab_group                => ${@tab_group},
					                             p_base_table               => ${@base_table},
					                             p_base_table_pk            => ${@base_table_pk},
					                             p_base_table_field         => ${@base_table_field},
					                             p_query_source             => ${@query_source},
					                             p_parent_table             => ${@parent_table},
					                             p_configurable             => ${@configurable},
					                             p_row_count                => ${@row_count},
					                             p_column_count             => ${@column_count},
					                             p_label_width              => ${@label_width},
					                             p_field_width              => ${@field_width},
					                             p_margin_top               => ${@margin_top},
					                             p_margin_height            => ${@margin_height},
					                             p_margin_width             => ${@margin_width},
					                             p_show_box                 => ${@show_box},
					                             p_box_width                => ${@box_width},
					                             p_tree_code                => ${@tree_code},
					                             p_tree_level               => ${@tree_level},
					                             p_repeat_object            => ${@repeat_object},
					                             p_ref_tab_code             => ${@ref_tab_code},
					                             p_tab_ref_screen           => ${@tab_ref_screen},
					                             p_user_id                  => ${/session/@user_id},
					                             p_repeat_bindertarget_flag => ${@repeat_bindertarget_flag},
					                             p_root_tree_code           => ${@root_tree_code},
					                             p_setup_height             => ${@setup_height},
					                             p_height                   => ${@height},
					                             p_setup_width              => ${@setup_width},
					                             p_width                    => ${@width},
					                             p_parent_loaded_object     => ${@parent_loaded_object},
					                             p_attachment_tab_group     => ${@attachment_tab_group},
					                             p_repeat_bindname_object   => ${@repeat_bindname_object},
					                             p_query_only               => ${@query_only},
					                             p_query_tab_code           =>${@query_tab_code},
					                             p_fieldwidth               =>${@fieldwidth},
					                             p_fieldheight              =>${@fieldheight},
					                             p_check_before_delete_bm   =>${@check_before_delete_bm},
					                             p_check_after_save_bm      =>${@check_after_save_bm},
					                             p_switchcard_value         =>${@switchcard_value},
					                             p_recreate_ds_flag         =>${@recreate_ds_flag},
					                             p_fetchall                 =>${@fetchall},
					                             p_is_selected_flag         =>${@is_selected_flag});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
        		begin
        			null;
        		end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
        		begin
        			HLS030_SAVE_PKG.update_tree_level(p_layout_code		 => ${@layout_code},
        											  p_user_id			 => ${/session/@user_id});
        		end;
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="layout_code"/>
        <bm:pk-field name="tab_code"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="tab_code" queryOperator="="/>
        <bm:query-field name="query_tab_code" queryExpression="t1.tab_code like ${@query_tab_code}"/>
        <bm:query-field field="parent_table" queryOperator="="/>
        <bm:query-field name="enabled_flag" queryExpression="(t1.enabled_flag=${@enabled_flag} or ${@enabled_flag}=&apos;ALL&apos;)"/>
        <bm:query-field field="tree_code" queryOperator="="/>
        <bm:query-field field="tab_type" queryOperator="="/>
        <bm:query-field field="parent_tab_code" queryOperator="="/>
        <bm:query-field field="tab_desc" queryOperator="like"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.layout_code=${@layout_code}"/>
    </bm:data-filters>
</bm:model>
