<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang 
    $Date: 2015-6-10 下午03:17:55  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    faa.file_name,
                    faa.file_path,
                    faa.file_type_code,
                    (SELECT
                        'Y'
                    FROM
                        fnd_atm_attachment_multi m1
                    WHERE
                        m1.table_name     = 'CON_CONTRACT_ET_CONTENT' AND
                        m1.table_pk_value = ${/parameter/@et_agreement_id}
                    ) file_exists_flag,
                    cc.content_number
                    ||'-'
                    ||cc.bp_name
                    ||'-'
                    ||
                    (SELECT
                        t.project_number
                    FROM
                        con_contract ct,
                        prj_project t
                    WHERE
                        t.project_id   = ct.project_id AND
                        ct.contract_id = cc.contract_id
                    ) to_file_name,
                    lt.pwd,
                    t.templet_id
                FROM
                    fnd_atm_attachment faa,
                    fnd_atm_attachment_multi m,
                    hls_doc_file_templet lt,
                    con_clause_templet t
                WHERE
                    faa.attachment_id = m.attachment_id AND
                    m.table_name      = 'HLS_DOC_FILE_TEMPLET' AND
                    m.table_pk_value  = lt.templet_id AND
                    lt.templet_id     = t.doc_template_id AND
                    t.doc_plugin_flag = 'Y' AND
                    t.TEMPLET_CODE    = DECODE(con_contract_et_pkg.get_et_force_tplt(p_et_agreement_id =>${/parameter/@et_agreement_id}, p_user_id =>${/session/@user_id}),'Y','ET_FORCE','ET_NORMAL') AND
                    t.company_id      = ${/session/@company_id}
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_NAME"/>
        <bm:field name="file_path" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_PATH"/>
        <bm:field name="file_type_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_TYPE_CODE"/>
        <bm:field name="file_exists_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FILE_EXISTS_FLAG"/>
        <bm:field name="to_file_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TO_FILE_NAME"/>
        <bm:field name="pwd" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PWD"/>
        <bm:field name="templet_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TEMPLET_ID"/>
    </bm:fields>
</bm:model>
