<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hand  
    $Date: 2016-7-18 上午11:03:30  
    $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
                    t.project_id,
                    t.project_number,
                    t.bp_name,
                    t.creation_date,
                    t.project_status,
                    t.project_status_n
                FROM
                    prj_project_lv t #WHERE_CLAUSE#
                ORDER BY
                    t.project_number DESC
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="project_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROJECT_ID" required="true"/>
        <bm:field name="project_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_NUMBER" required="true"/>
        <bm:field name="bp_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BP_NAME"/>
        <bm:field name="project_status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_STATUS"/>
        <bm:field name="project_status_n" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROJECT_STATUS_N"/>
        <bm:field name="creation_date" databaseType="DATE" datatype="java.util.Date" physicalName="CREATION_DATE"/>
    </bm:fields>
    <bm:data-filters>
        <bm:data-filter name="user_id" enforceOperations="query" expression="exists  (select 1 from aut_trx_user_authorize a1, aut_owner_user_authorize a2 where a1.trx_category = &apos;PROJECT&apos; and a1.trx_id = t.project_id and trunc(sysdate) between a1.start_date and  nvl(a1.end_date, trunc(sysdate)) and a1.user_id = a2.owner_user_id and a1.trx_category = a2.trx_category            and a2.authorized_user_id = nvl(${/session/@user_id},${@user_id}) and trunc(sysdate) between a2.start_date and nvl(a2.end_date, trunc(sysdate)))"/>
    </bm:data-filters>
    <bm:query-fields>
        <bm:query-field field="project_number" matchany="true" queryOperator="like"/>
        <bm:query-field field="bp_name" matchany="true" queryOperator="like"/>
        <bm:query-field field="creation_date" queryExpression="trunc(t.creation_date) = to_date(${@creation_date},&apos;yyyy-mm-dd&apos;)"/>
    </bm:query-fields>
</bm:model>