<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang  
    $Date: 2013-9-9 下午05:44:21  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="id" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="text" databaseType="CLOB" datatype="java.sql.Clob"/>
        <bm:field name="pid" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="ilvl" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="indfirstline" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="indleft" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="toc" databaseType="VARCHAR" datatype="java.lang.Boolean"/>
        <bm:field name="type" databaseType="VARCHAR2" datatype="java.lang.String"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    l.templet_line_id id,
                    l.parent_line_id pid,
                    con_contract_content_pkg.get_content_parameter_value(t.clause_text_cn, ${@contract_id},${@bp_id},${@mortgage_id},${@content_id}, ${/session/@user_id}) text,
                    DECODE(t.content_number_flag,'Y',(level - 1),'') ilvl,
                    DECODE(t.content_flag,'Y',1,0) toc,
                    t.indfirstline_number indfirstline,
                    t.indleft_number indleft,
                    lower(t.clause_style) type
                FROM
                    con_basic_clause t,
                    con_clause_templet_line l
                WHERE
                    l.templet_id       = ${@templet_id} AND
                    l.clause_id        = t.clause_id AND
                    t.clause_usage     = ${@clause_usage} AND
                    t.enabled_flag     = 'Y' AND
                    t.approval_status  = 'APPROVED' START
                WITH l.parent_line_id IS NULL CONNECT BY l.parent_line_id = prior l.templet_line_id
                ORDER BY
                    con_contract_content_pkg.con_basic_clause_index(l.templet_line_id)
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
</bm:model>
