<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei  
    $Date: 2015-12-16 下午2:48:24  
    $Revision: 1.0  
    $Purpose: 客户要求指派工作流页面不显示审批通过，
                                           审批拒绝，审批按钮都放到指派页面中，修改按钮获取bm，实非吾愿
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="ZJ_WFL_WORKFLOW_NODE_ACTION">
    <bm:fields>
        <bm:field name="node_action_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NODE_ACTION_ID" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.NODE_ACTION_ID"/>
        <bm:field name="node_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NODE_ID" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.NODE_ID"/>
        <bm:field name="jump_node_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="JUMP_NODE_ID" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.JUMP_NODE_ID"/>
        <bm:field name="jump_node_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="action_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ACTION_TYPE" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.ACTION_TYPE"/>
        <bm:field name="action_type_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="sequence_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SEQUENCE_NUM" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.SEQUENCE_NUM"/>
        <bm:field name="procedure_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROCEDURE_ID" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.PROCEDURE_ID"/>
        <bm:field name="exec_procedure" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="procedure_code" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="procedure_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="service_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SERVICE_ID" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.SERVICE_ID"/>
        <bm:field name="service_name" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="service_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="node_action_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NODE_ACTION_DESC" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.NODE_ACTION_DESC"/>
        <bm:field name="node_action_prompt" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NODE_ACTION_PROMPT" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.NODE_ACTION_PROMPT"/>
        <bm:field name="default_action_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DEFAULT_ACTION_FLAG" prompt="ZJ_WFL_WORKFLOW_NODE_ACTION.DEFAULT_ACTION_FLAG"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    		  select t1.* from  (select a1.node_action_id,
               a1.node_id,
               a1.jump_node_id,
               a1.jump_node_desc,
               a1.action_type,
               a1.action_type_desc,
               a1.sequence_num,
               a1.procedure_id,
               a1.exec_procedure,
               a1.procedure_code,
               a1.procedure_desc,
               a1.service_id,
               a1.service_name,
               a1.service_desc,
               a1.node_action_desc,
               --nvl(a1.node_action_prompt,'您确认吗？') as node_action_prompt,
               prj_project_workflow_pkg.get_node_action_prompt(a1.node_action_id,${/parameter/@instance_id}) node_action_prompt,
               a1.default_action_flag
          from zj_wfl_workflow_node_action_v a1
          where  not exists
          (select 1 from  Zj_Wfl_Workflow_Node_Action_v b where b.node_id=a1.node_id
                   and b.action_type=5 and b.service_name='modules/wfl_screen/sdic_workflow_assigned.lview' )
                   union 
                   select a2.node_action_id,
               a2.node_id,
               a2.jump_node_id,
               a2.jump_node_desc,
               a2.action_type,
               a2.action_type_desc,
               a2.sequence_num,
               a2.procedure_id,
               a2.exec_procedure,
               a2.procedure_code,
               a2.procedure_desc,
               a2.service_id,
               a2.service_name,
               a2.service_desc,
               a2.node_action_desc,
               nvl(a2.node_action_prompt,'您确认吗？') as node_action_prompt,
               a2.default_action_flag
          from zj_wfl_workflow_node_action_v a2
          where  exists
          (select 1 from  Zj_Wfl_Workflow_Node_Action_v b where b.node_id=a2.node_id
                   and b.action_type=5 and b.service_name='modules/wfl_screen/sdic_workflow_assigned.lview' )
                   and a2.action_type not in (1)) t1
				 #WHERE_CLAUSE#
				 order by t1.sequence_num
				  
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            begin
				zj_wfl_workflow_pkg.delete_wfl_node_action
				(
					p_node_action_id          => ${@node_action_id},					
					p_user_id                 => ${/session/@user_id}
				);
			end;
			]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
            begin
				zj_wfl_workflow_pkg.node_action_check
				(
					p_node_id          => ${@node_id},					
					p_user_id          => ${/session/@user_id}
				);
			end;
			]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.node_id = ${@node_id}"/>
    </bm:data-filters>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="node_action_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="node_action_id" queryOperator="="/>
    </bm:query-fields>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="节点序号${@sequence_num}已经存在!"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
