<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: gaoyang 
    $Date: 2015-7-10 下午03:44:00  
    $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
                    a.*
                FROM
                    (SELECT
                        rownum AS row_num,
                        t.*
                    FROM
                        (SELECT
                            instance_id,
                            workflow_name,
                            NVL(instance_desc, workflow_name) instance_desc,
                            workflow_id,
                            workflow_desc,
                            DECODE(status, 1, node_name, NULL) node_name,
                            employee_name,
                            status_name,
                            created_by,
                            created_by_name,
                            record_id,
                            TO_CHAR(creation_date, 'yyyy-mm-dd hh24:mi:ss') AS creation_date,
                            'modules/mobile/wfl_workflow_approved_view_for_mobile.lview?instance_id='
                            ||a.INSTANCE_ID
                            ||'&a='
                            ||dbms_random.random doc_page_url
                        FROM
                            wfl_workflow_instance_tl_v a
                        WHERE
                            EXISTS
                            (SELECT
                                1
                            FROM
                                wfl_approve_record
                            WHERE
                                instance_id = a.instance_id AND
                                created_by  = ${/session/@user_id}
                            ) AND
                            EXISTS
                            (SELECT
                                1
                            FROM
                                wfl_workflow_pages
                            WHERE
                                workflow_id    = a.WORKFLOW_ID AND
                                device_type_id = 'IPHONE'
                            )
                        ORDER BY
                            creation_date DESC
                        ) t #WHERE_CLAUSE#
                    ) a
                WHERE
                    row_num >= to_number(NVL(${/parameter/@index},1)) AND
                    row_num  < (to_number(NVL(${/parameter/@index},1))+to_number(NVL(${/parameter/@length},row_num)))
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="date" queryExpression="to_date(t.creation_date,&apos;yyyy-mm-dd hh24:mi:ss&apos;) &gt; to_date(${@date},&apos;yyyy-MM-dd hh24:mi:ss&apos;)"/>
    </bm:query-fields>
</bm:model>
