<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="LEG_LEGAL_CONTENT" needAccessControl="false">
    <bm:fields>
        <bm:field name="content_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTENT_ID" prompt="LEG_LEGAL_CONTENT.CONTENT_ID"/>
        <bm:field name="contract_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONTRACT_ID" prompt="LEG_LEGAL_CONTENT.CONTRACT_ID"/>
        <bm:field name="law_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LAW_ID" prompt="LEG_LEGAL_CONTENT.LAW_ID"/>
        <bm:field name="clause_usage" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CLAUSE_USAGE" prompt="LEG_LEGAL_CONTENT.CLAUSE_USAGE"/>
        <bm:field name="templet_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TEMPLET_ID" prompt="LEG_LEGAL_CONTENT.TEMPLET_ID"/>
        <bm:field name="con_contract_bp_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CON_CONTRACT_BP_ID" prompt="LEG_LEGAL_CONTENT.CON_CONTRACT_BP_ID"/>
        <bm:field name="mortgage_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MORTGAGE_ID" prompt="LEG_LEGAL_CONTENT.MORTGAGE_ID"/>
        <bm:field name="content_print_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTENT_PRINT_FLAG" prompt="LEG_LEGAL_CONTENT.CONTENT_PRINT_FLAG"/>
        <bm:field name="available_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="AVAILABLE_FLAG" prompt="LEG_LEGAL_CONTENT.AVAILABLE_FLAG"/>
        <bm:field name="ref_v01" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V01" prompt="LEG_LEGAL_CONTENT.REF_V01"/>
        <bm:field name="ref_v02" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V02" prompt="LEG_LEGAL_CONTENT.REF_V02"/>
        <bm:field name="ref_v03" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V03" prompt="LEG_LEGAL_CONTENT.REF_V03"/>
        <bm:field name="ref_v04" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V04" prompt="LEG_LEGAL_CONTENT.REF_V04"/>
        <bm:field name="ref_v05" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REF_V05" prompt="LEG_LEGAL_CONTENT.REF_V05"/>
        <bm:field name="ref_n01" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N01" prompt="LEG_LEGAL_CONTENT.REF_N01"/>
        <bm:field name="ref_n02" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N02" prompt="LEG_LEGAL_CONTENT.REF_N02"/>
        <bm:field name="ref_n03" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N03" prompt="LEG_LEGAL_CONTENT.REF_N03"/>
        <bm:field name="ref_n04" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N04" prompt="LEG_LEGAL_CONTENT.REF_N04"/>
        <bm:field name="ref_n05" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REF_N05" prompt="LEG_LEGAL_CONTENT.REF_N05"/>
        <bm:field name="ref_d01" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D01" prompt="LEG_LEGAL_CONTENT.REF_D01"/>
        <bm:field name="ref_d02" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D02" prompt="LEG_LEGAL_CONTENT.REF_D02"/>
        <bm:field name="ref_d03" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D03" prompt="LEG_LEGAL_CONTENT.REF_D03"/>
        <bm:field name="ref_d04" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D04" prompt="LEG_LEGAL_CONTENT.REF_D04"/>
        <bm:field name="ref_d05" databaseType="DATE" datatype="java.util.Date" physicalName="REF_D05" prompt="LEG_LEGAL_CONTENT.REF_D05"/>
        <bm:field name="content_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTENT_NUMBER" prompt="LEG_LEGAL_CONTENT.CONTENT_NUMBER"/>
        <bm:field name="file_path" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PATH" prompt="LEG_LEGAL_CONTENT.FILE_PATH"/>
        <bm:field name="file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_NAME" prompt="LEG_LEGAL_CONTENT.FILE_NAME"/>
        <bm:field name="print_date" databaseType="DATE" datatype="java.util.Date" physicalName="PRINT_DATE" prompt="LEG_LEGAL_CONTENT.PRINT_DATE"/>
        <bm:field name="check_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CHECK_ID" prompt="LEG_LEGAL_CONTENT.CHECK_ID"/>
        <bm:field name="content_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTENT_TYPE" prompt="LEG_LEGAL_CONTENT.CONTENT_TYPE"/>
        <bm:field name="content_print_flag_name" expression="(decode(t1.content_print_flag, &apos;Y&apos;, &apos;已生成&apos;, &apos;未生成&apos;))" forInsert="false" forUpdate="false"/>
        <bm:field name="bp_name" expression="(select bp_name from hls_bp_master where con_contract_bp_id = bp_id)" forInsert="false" forUpdate="false"/>
        <bm:field name="function" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FUNCTION"/>
        <bm:field name="legal_number" expression="(select l.legal_number from con_contract_law l where l.law_id = t1.law_id)"/>
        <bm:field name="search_term_1" expression="(select search_term_1 from con_contract where contract_id = t1.contract_id)"/>
        <bm:field name="contract_number" expression="(select contract_number from con_contract where contract_id = t1.contract_id)"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="content_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="ref_v01" queryOperator="like"/>
        <bm:query-field field="contract_id" queryOperator="="/>
        <bm:query-field field="law_id" queryOperator="="/>
        <bm:query-field field="content_id" queryOperator="="/>
        <bm:query-field name="function" queryExpression="t1.function = decode(${@function},&apos;ALL&apos;,t1.function,&apos;${:@function}&apos;)"/>
        <!--  <bm:query-field name="function"  queryExpression="t1.function = decode(${@clause_usage},'ALL',t1.function,${@clause_usage})" /> -->
        <bm:query-field name="clause_usage" queryExpression="t1.clause_usage = nvl(${@clause_usage},t1.clause_usage) "/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="query" expression="(exists (select 1 from leg_legal_content_tmp ct where ct.contract_id = t1.contract_id and ct.session_id = ${/session/@session_id}))"/>
    </bm:data-filters>
</bm:model>
