<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: xiaobo  
    $Date: 2012-12-17 上午10:35:13  
    $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
                    t1.REPORT_HEADER_ID,
                    t1.REPORT_HEADER_NAME,
                    t1.REPORT_HEADER_DESCRIPTION,
                    t1.REPORT_OWNER,
                    t1.VIEW_RANGE,
                    t1.REPORT_TYPE,
                    t1.SQL_STATEMENT,
                    t1.report_creation_date,
                    t1.FIXED_TIME_FLAG,
                    t1.start_date,
                    t1.PUSH_CYCLE,
                    t1.OTHER_REPORT_FLAG,
                    t1.OTHER_REPORT_HEADER_ID,
                    t1.layout_code,
                    (SELECT
                        d.description
                    FROM
                        hls_doc_layout d
                    WHERE
                        d.layout_code=t1.layout_code
                    ) layout_code_desc,
                    t.report_header_name other_report_header_name
                FROM
                    PSR_REPORT_HEADERS t1,
                    PSR_REPORT_HEADERS t #WHERE_CLAUSE#
                ORDER BY
                    report_creation_date
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="report_header_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REPORT_HEADER_ID" required="true"/>
        <bm:field name="report_header_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REPORT_HEADER_NAME"/>
        <bm:field name="report_header_description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REPORT_HEADER_DESCRIPTION"/>
        <bm:field name="report_owner" databaseType="NUMBER" datatype="java.lang.Long" physicalName="REPORT_OWNER"/>
        <bm:field name="view_range" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="VIEW_RANGE"/>
        <bm:field name="report_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REPORT_TYPE"/>
        <bm:field name="sql_statement" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SQL_STATEMENT"/>
        <bm:field name="report_creation_date" databaseType="DATE" datatype="java.util.Date" physicalName="REPORT_CREATION_DATE"/>
        <bm:field name="fixed_time_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIXED_TIME_FLAG"/>
        <bm:field name="start_date" databaseType="DATE" datatype="java.util.Date" physicalName="START_DATE"/>
        <bm:field name="push_cycle" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PUSH_CYCLE"/>
        <bm:field name="other_report_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OTHER_REPORT_FLAG"/>
        <bm:field name="other_report_header_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OTHER_REPORT_HEADER_ID"/>
        <bm:field name="other_report_header_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="other_report_header_name"/>
        <bm:field name="layout_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAYOUT_CODE"/>
        <bm:field name="layout_code_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAYOUT_CODE_DESC"/>
    </bm:fields>
    <bm:data-filters>
        <bm:data-filter name="report_owner" enforceOperations="query" expression="(t1.report_owner = ${/session/@user_id} or t1.view_range = &apos;PUBLIC&apos;)"/>
        <bm:data-filter name="other_report_header_id" enforceOperations="query" expression="t1.other_report_header_id = t.report_header_id(+)"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field name="report_header_name" queryExpression="t1.report_header_name like &apos;%&apos;||${/parameter/@report_header_name}||&apos;%&apos;"/>
        <bm:query-field name="report_type" queryExpression="t1.report_type = ${/parameter/@report_type}"/>
        <bm:query-field name="report_header_id" queryExpression="t1.report_header_id = ${/parameter/@report_header_id}"/>
    </bm:query-fields>
</bm:model>
