<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="instance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="INSTANCE_ID"/>
        <bm:field name="workflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WORKFLOW_ID"/>
        <bm:field name="workflow_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WORKFLOW_CODE"/>
        <bm:field name="workflow_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="WORKFLOW_DESC"/>
        <bm:field name="current_seq" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CURRENT_SEQ"/>
        <bm:field name="current_node_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CURRENT_NODE_DESC"/>
        <bm:field name="last_approve_date" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LAST_APPROVE_DATE"/>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="company_info" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="instance_status" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="instance_status_desc" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="approve_user_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="APPROVE_USER_CODE"/>
        <bm:field name="approve_user_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="APPROVE_USER_NAME"/>
        <bm:field name="created_by"/>
        <bm:field name="submitted_by"/>
        <bm:field name="document_info"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            	select t1.instance_id,
				       t1.workflow_id,
				       t1.workflow_code,
				       t1.workflow_desc,
				       t1.current_seq,
				       t1.created_by,
				       t1.submitted_by,
				       t1.instance_status,
				       t1.instance_status_desc,
				       t1.current_node_desc,
				       t1.last_approve_date,
				       t1.company_id,
				       t1.company_info,
				       t1.approve_user_code,
				       t1.approve_user_name,
				       t1.document_info
				  from zj_wfl_workflow_instance_v t1
					#WHERE_CLAUSE#
				  order by t1.instance_id desc
			]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="instance_id" queryExpression="t1.instance_id = ${@instance_id}"/>
        <bm:query-field name="document_info" queryExpression="t1.document_info like &apos;%&apos;||${@document_info}||&apos;%&apos;"/>
        <bm:query-field name="submitted_by" queryExpression="t1.submitted_by=${/session/@user_id}"/>
        <bm:query-field name="instance_status" queryExpression="t1.instance_status = ${@instance_status}"/>
        <bm:query-field name="workflow_code" queryExpression="t1.workflow_code like ${@workflow_code}"/>
        <bm:query-field name="node_desc" queryExpression="(t1.current_node_desc like ${@node_desc} or t1.current_seq like ${@node_desc})"/>
        <bm:query-field name="company_id" queryExpression="t1.company_id = ${/session/@company_id}"/>
        <bm:query-field name="approve_user_name" queryExpression="t1.approve_user_name like ${@approve_user_name}"/>
        <bm:query-field name="approve_user_code" queryExpression="t1.approve_user_code like ${@approve_user_code}"/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter name="query" expression="( (${/session/@role_id} = (select role_id from sys_role where role_code = '0006') and t1.workflow_code in (&apos;CONTRACT_INCEPT_WFL&apos;, &apos;DCFL_CSH_PAYMENT_REQ&apos;)) or (${/session/@role_id} in (select role_id from sys_role where role_code in ('0012', '0013', '0014')) and t1.workflow_code in (&apos;DCFL_CSH_PAYMENT_REQ&apos;, &apos;DEPOSIT_RETURN&apos;)) or (${/session/@role_id} = (select role_id from sys_role where role_code = '0005') and t1.workflow_code in (&apos;PROJECT_WFL&apos;)) or (${/session/@role_id} = (select role_id from sys_role where role_code = '0008') and t1.workflow_code in (&apos;CON_ET_WFL&apos;,&apos;TENANT_CHANGE_WFL&apos;,&apos;CON_BUYBACK_WFL&apos;,&apos;DEPOSIT_RETURN&apos;)) or (${/session/@role_id} not in (select role_id from sys_role where role_code in('0005', '0006', '0008', '0012', '0013', '0014')) and 1 = 1))"/>
    </bm:data-filters>
</bm:model>
