<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2015-01-06 下午6:54:19  
    $Revision: 1.0  
    $Purpose:  
-->
<bm:model xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="HLS_STANDARD_HISTORY" defaultOrderBy="t1.standard_history_id desc">
    <bm:fields>
        <bm:field name="standard_history_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="STANDARD_HISTORY_ID" prompt="HLS_STANDARD_HISTORY.STANDARD_HISTORY_ID"/>
        <bm:field name="table_name_comments" expression="(select a.COMMENTS from all_tab_comments a where a.OWNER= USER and a.table_name=t1.table_name)"/>
        <bm:field name="table_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TABLE_NAME" prompt="HLS_STANDARD_HISTORY.TABLE_NAME"/>
        <bm:field name="table_pk_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TABLE_PK_VALUE" prompt="HLS_STANDARD_HISTORY.TABLE_PK_VALUE"/>
        <bm:field name="parent_table" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARENT_TABLE" prompt="HLS_STANDARD_HISTORY.PARENT_TABLE"/>
        <bm:field name="parent_table_pk_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARENT_TABLE_PK_VALUE" prompt="HLS_STANDARD_HISTORY.PARENT_TABLE_PK_VALUE"/>
        <bm:field name="source_table" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SOURCE_TABLE" prompt="HLS_STANDARD_HISTORY.SOURCE_TABLE"/>
        <bm:field name="source_table_comments" expression="(select a.COMMENTS from all_tab_comments a where a.OWNER=USER and a.table_name=t1.source_table)"/>
        <bm:field name="source_table_pk_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SOURCE_TABLE_PK_VALUE" prompt="HLS_STANDARD_HISTORY.SOURCE_TABLE_PK_VALUE"/>
        <bm:field name="layout_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAYOUT_CODE" prompt="HLS_STANDARD_HISTORY.LAYOUT_CODE"/>
        <bm:field name="tab_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TAB_CODE" prompt="HLS_STANDARD_HISTORY.TAB_CODE"/>
        <bm:field name="column_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="COLUMN_NAME" prompt="HLS_STANDARD_HISTORY.COLUMN_NAME"/>
        <bm:field name="from_column_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FROM_COLUMN_VALUE" prompt="HLS_STANDARD_HISTORY.FROM_COLUMN_VALUE"/>
        <bm:field name="to_column_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TO_COLUMN_VALUE" prompt="HLS_STANDARD_HISTORY.TO_COLUMN_VALUE"/>
        <bm:field name="operation_date" databaseType="DATE" datatype="java.util.Date" physicalName="OPERATION_DATE" prompt="HLS_STANDARD_HISTORY.OPERATION_DATE"/>
        <bm:field name="confirm_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONFIRM_FLAG" prompt="HLS_STANDARD_HISTORY.CONFIRM_FLAG"/>
        <bm:field name="column_prompt" expression="(SELECT c.prompt FROM hls_doc_layout_config c WHERE c.layout_code = t1.layout_code AND c.tab_code = t1.tab_code AND c.column_name = t1.column_name)"/>
        <bm:field name="to_value" expression="(select  hls_standard_history_pkg.get_default_value_name(t1.table_name, t1.table_pk_value,nvl(${@layout_code},t1.layout_code),nvl(${@tab_code},t1.tab_code),  t1.column_name, t1.to_column_value, ${/session/@user_id}, ${/session/@session_id}) from dual)"/>
        <bm:field name="from_value" expression="(select  hls_standard_history_pkg.get_default_value_name(t1.table_name, t1.table_pk_value,nvl(${@layout_code},t1.layout_code),nvl(${@tab_code},t1.tab_code),  t1.column_name, t1.from_column_value, ${/session/@user_id}, ${/session/@session_id}) from dual)"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field name="table_name" queryExpression="upper(t1.table_name)=upper(${@table_name})"/>
        <bm:query-field name="table_pk_value" queryExpression="t1.table_pk_value=${@table_pk_value}"/>
        <bm:query-field name="source_table" queryExpression="t1.source_table=${@source_table}"/>
        <bm:query-field name="source_table_pk_value" queryExpression="t1.source_table_pk_value=${@source_table_pk_value}"/>
    </bm:query-fields>
    <bm:primary-key>
        <bm:pk-field name="standard_history_id"/>
    </bm:primary-key>
    <bm:data-filters>
        <bm:data-filter name="confirm_flag" enforceOperations="query" expression="t1.confirm_flag=&apos;N&apos;"/>
    </bm:data-filters>
</bm:model>
