<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-7-25 上午10:49:53  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CON_BASIC_CLAUSE" defaultOrderBy="t1.order_seq">
    <bm:fields>
        <bm:field name="clause_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CLAUSE_ID" prompt="CON_BASIC_CLAUSE.CLAUSE_ID"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" insertExpression="${/session/@company_id}" physicalName="COMPANY_ID" prompt="CON_BASIC_CLAUSE.COMPANY_ID" updateExpression="${/session/@company_id}"/>
        <bm:field name="clause_code" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="150" forDisplay="true" forQuery="true" physicalName="CLAUSE_CODE" prompt="CON201.CON_BASIC_CLAUSE.CLAUSE_CODE"/>
        <bm:field name="clause_usage" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CLAUSE_USAGE" prompt="CON_BASIC_CLAUSE.CLAUSE_USAGE"/>
        <bm:field name="clause_usage_name" expression="(select s.code_value_name from sys_code_values_v s where s.code = &apos;CON_TMPLET_USAGE&apos; and s.code_value=t1.clause_usage)" forInsert="false" forUpdate="false" prompt="CON_BASIC_CLAUSE.APPROVAL_STATUS"/>
        <bm:field name="parent_clause_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PARENT_CLAUSE_ID" prompt="CON_BASIC_CLAUSE.PARENT_CLAUSE_ID"/>
        <bm:field name="parent_clause_code" expression="(select cbc.clause_code from con_basic_clause cbc where cbc.CLAUSE_ID=t1.PARENT_CLAUSE_ID)" forInsert="false" forUpdate="false" prompt="CON_BASIC_CLAUSE.PARENT_CLAUSE_ID"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="150" forDisplay="true" forQuery="true" physicalName="DESCRIPTION" prompt="CON201.CON_BASIC_CLAUSE.DESCRIPTION"/>
        <bm:field name="approval_status" databaseType="VARCHAR2" datatype="java.lang.String" insertExpression="&apos;APPROVED&apos;" physicalName="APPROVAL_STATUS" prompt="CON_BASIC_CLAUSE.APPROVAL_STATUS"/>
        <bm:field name="approval_status_name" expression="(select s.code_value_name from sys_code_values_v s where s.code = &apos;CON_TERMS_APPROVE_STATUS&apos; and s.code_value=t1.approval_status)" forInsert="false" forUpdate="false" prompt="CON_BASIC_CLAUSE.APPROVAL_STATUS"/>
        <bm:field name="order_seq" databaseType="NUMBER" datatype="java.lang.Long" physicalName="ORDER_SEQ" prompt="CON_BASIC_CLAUSE.ORDER_SEQ"/>
        <bm:field name="expand_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EXPAND_FLAG" prompt="CON_BASIC_CLAUSE.EXPAND_FLAG"/>
        <bm:field name="clause_text_cn" databaseType="CLOB" datatype="java.sql.Clob" physicalName="CLAUSE_TEXT_CN" prompt="CON_BASIC_CLAUSE.CLAUSE_TEXT_CN"/>
        <bm:field name="clause_text_en" databaseType="CLOB" datatype="java.sql.Clob" physicalName="CLAUSE_TEXT_EN" prompt="CON_BASIC_CLAUSE.CLAUSE_TEXT_EN"/>
        <bm:field name="clause_text_jp" databaseType="CLOB" datatype="java.sql.Clob" physicalName="CLAUSE_TEXT_JP" prompt="CON_BASIC_CLAUSE.CLAUSE_TEXT_JP"/>
        <bm:field name="content_number_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTENT_NUMBER_FLAG" prompt="CON_BASIC_CLAUSE.CONTENT_NUMBER_FLAG"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="CON_BASIC_CLAUSE.ENABLED_FLAG"/>
        <bm:field name="content_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTENT_FLAG" prompt="CON_BASIC_CLAUSE.CONTENT_FLAG"/>
        <bm:field name="indfirstline_number" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INDFIRSTLINE_NUMBER" prompt="CON_BASIC_CLAUSE.INDFIRSTLINE_NUMBER"/>
        <bm:field name="indleft_number" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INDLEFT_NUMBER" prompt="CON_BASIC_CLAUSE.INDLEFT_NUMBER"/>
        <bm:field name="clause_style" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="CON_CLAUSE_STYLE" lookupField="clause_style_name" physicalName="CLAUSE_STYLE" prompt="CON_BASIC_CLAUSE.CLAUSE_STYLE"/>
        <bm:field name="clause_style_name" forInsert="false" forUpdate="false" physicalName="CLAUSE_STYLE_NAME"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:operations>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
        		BEGIN
        		    con_basic_clause_pkg.con_basic_clause_delete(p_clause_id =>${@clause_id} ,p_user_id =>${/session/@user_id} );
        		END;
    		]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:primary-key>
        <bm:pk-field name="clause_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="clause_code" queryOperator="like"/>
        <bm:query-field field="clause_usage" queryOperator="="/>
        <bm:query-field field="description" queryOperator="like"/>
        <bm:query-field field="approval_status" queryOperator="="/>
        <bm:query-field name="enabled_flag" queryExpression="(t1.enabled_flag=${@enabled_flag} or ${@enabled_flag}=&apos;ALL&apos;)"/>
        <bm:query-field name="not_clause_code" queryExpression="(not exists(select 1 from CON_BASIC_CLAUSE c where c.clause_code=${@not_clause_code} and t1.parent_clause_id=c.clause_id) and t1.clause_code !=${@not_clause_code})"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.company_id =${/session/@company_id}"/>
    </bm:data-filters>
</bm:model>
