<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Mouse Chow  
    $Date: 2012-1-6 下午01:31:09  
    $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 'Y' as IS_VALID from dual
            where 
            	exists
            	(
				select 1 from wfl_notification_record r where r.instance_id = ${/parameter/@instance_id} and r.user_id = ${/session/@user_id}
				)
				or exists 
				(
				select 1 from wfl_instance_node_recipient t where t.instance_id = ${/parameter/@instance_id} and t.user_id = ${/session/@user_id} 
				)
				or exists
				(
				select 1 from wfl_workflow_instance i where i.instance_id = ${/parameter/@instance_id} and i.created_by = ${/session/@user_id}
				)
				or exists
				(
				select 1 from wfl_approve_record war where war.instance_id = ${/parameter/@instance_id} and war.created_by = ${/session/@user_id}
				)
				or exists
				(
				select 1 from sys_role_function r ,sys_function  f where r.function_id = f.function_id and f.function_code = 'WFL3010'
				and r.role_id = ${/session/@role_id}
				)
				or exists
				(
				select 1 from sys_role_function r ,sys_function  f where r.function_id = f.function_id and 
				f.function_code in ('CSH5050','CSH5060','CSH3110',
				'CSH5030','CSH5080','CSH3200','CSH5020','EXP5060','EXP3130','EXP5360','EXP5400','EXP6110',
				'EXP5140','EXP5250','EXP5260','EXP5240','EXP5190','EXP5121','EXP5150','EXP5201','EXP6310',
				'EXP5200','EXP5210','EXP3110','EXP3700','CSH3040','CSH3060','CSH5250','ACP5030','ACP3100',
				'ACP5040','ACP5050','CSH5210','CSH5230','CSH5220','CSH5221','CSH5330')
				and r.role_id = ${/session/@role_id}
				)
			
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="IS_VALID"/>
    </bm:fields>
</bm:model>
