<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (
                SELECT
                    hls_sys_upload_pkg.get_atm_file_href(p_table_pk_value => pcc.check_id, p_source_type => 'PRJ_CDD_ITEM_CHECK_CHANGE', p_user_id => ${/session/@user_id}) AS attach_file_name,
                    pci.note,
                    pci.description,
                    pci.cdd_item_id,
                    pcc.check_id,
                    pcr.doc_ref_id,
                    pcr.document_id,
                    pcr.record_id,
                    pcr.function_code
                FROM
                    prj_cdd_item_change pci,
                    prj_cdd_item_check_change pcc,
                    prj_cdd_item_doc_ref_change pcr
                WHERE
                    pci.cdd_item_id = pcc.cdd_item_id AND
                    pcc.check_id    = pcr.check_id
                    ) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
            begin
            hn_atm_complement_pkg.prj_project_cdd_item_ins(p_document_id =>${@document_id},
                                     p_record_id   =>${@record_id},
                                     p_description =>${@description},
                                     p_note        =>${@note},
                                     p_user_id     =>${/session/@user_id},
                                     p_tab_group =>${@tab_group},
                                     p_function_code =>${@function_code});
            end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin
            hn_atm_complement_pkg.prj_project_cdd_item_upd(p_doc_ref_id =>${@doc_ref_id},
                                     p_description =>${@description},
                                     p_note        =>${@note},
                                     p_user_id     =>${/session/@user_id});
            end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
            begin
            hn_atm_complement_pkg.prj_project_cdd_item_submit(p_record_id =>${@record_id},
                                        p_company_id =>${/session/@company_id},
                                        p_user_id    =>${/session/@user_id});
            end;
            ]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            begin
            hn_atm_complement_pkg.prj_project_cdd_item_del(p_doc_ref_id =>${@doc_ref_id},
                                     p_user_id     =>${/session/@user_id});
            end;
            ]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.record_id=${@record_id}"/>
        <bm:data-filter enforceOperations="query" expression="t1.document_id=${@document_id}"/>
        <bm:data-filter enforceOperations="query" expression="nvl(t1.function_code,&apos;HN1010&apos;)=nvl(${@function_code},&apos;HN1010&apos;)"/>
    </bm:data-filters>
</bm:model>
