<?xml version="1.0" encoding="UTF-8"?>
<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">
    <bm:fields>
        <bm:field name="node_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NODE_ID"/>
        <bm:field name="workflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WORKFLOW_ID"/>
        <bm:field name="sequence_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SEQUENCE_NUM" prompt="节点顺序"/>
        <bm:field name="node_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NODE_DESC" prompt="工作流描述"/>
        <bm:field name="node_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NODE_TYPE" prompt="节点类型"/>
        <bm:field name="node_type_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="approval_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="APPROVAL_TYPE"/>
        <bm:field name="approval_type_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="can_no_approver_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CAN_NO_APPROVER_FLAG"/>
        <bm:field name="can_no_approver_flag_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="can_transfer_approver_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CAN_TRANSFER_APPROVER_FLAG"/>
        <bm:field name="hide_approve_record_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="HIDE_APPROVE_RECORD_FLAG"/>
        <bm:field name="can_add_approver_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CAN_ADD_APPROVER_FLAG"/>
        <bm:field name="mail_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="MAIL_FLAG"/>
        <bm:field name="mail_flag_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="link_workflow_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="LINK_WORKFLOW_ID"/>
        <bm:field name="link_workflow_code" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="link_workflow_desc" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="notify_template_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NOTIFY_TEMPLATE_ID"/>
        <bm:field name="notify_template_code" databaseType="VARHCAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="notify_template_desc" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="branch_procedure" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BRANCH_PROCEDURE"/>
        <bm:field name="branch_procedure_code" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="branch_procedure_desc" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="branch_exec_procedure" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false"/>
        <bm:field name="approval_type_factor" databaseType="NUMBER" datatype="java.lang.Long" physicalName="APPROVAL_TYPE_FACTOR"/>
        <bm:field name="can_auto_pass_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CAN_AUTO_PASS_FLAG"/>
        <bm:field name="is_self_re_commit_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="IS_SELF_RE_COMMIT_FLAG"/>
        <bm:field name="system_maintain_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SYSTEM_MAINTAIN_FLAG"/>
        <bm:field name="info_complete_rate" databaseType="NUMBER" datatype="java.lang.Long" forInsert="false" forUpdate="false" physicalName="INFO_COMPLETE_RATE"/>
        <bm:field name="info_complete_note" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="INFO_COMPLETE_NOTE"/>
        <bm:field name="node_display_service_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NODE_DISPLAY_SERVICE_ID"/>
        <bm:field name="node_display_service_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="node_display_service_name" forInsert="false" forUpdate="false"/>
        <bm:field name="node_display_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NODE_DISPLAY_TYPE"/>
        <bm:field name="node_display_type_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="show_approve_history_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SHOW_APPROVE_HISTORY_FLAG"/>
        <bm:field name="show_all_approve_ht_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SHOW_ALL_APPROVE_HISTORY_FLAG"/>
        <bm:field name="sms_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SMS_FLAG"/>
        <bm:field name="sms_template_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SMS_TEMPLATE_ID"/>
        <bm:field name="sms_template_code" forInsert="false" forUpdate="false"/>
        <bm:field name="sms_template_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="branch_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BRANCH_METHOD"/>
        <bm:field name="branch_method_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="branch_business_rule" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BRANCH_BUSINESS_RULE"/>
        <bm:field name="branch_business_rule_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="node_display_my_app_svc_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NODE_DISPLAY_MY_APP_SVC_ID"/>
        <bm:field name="node_display_my_app_svc_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="node_display_my_app_svc_name" forInsert="false" forUpdate="false"/>
        <bm:field name="node_display_my_app_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="NODE_DISPLAY_MY_APP_TYPE"/>
        <bm:field name="to_do_limit" databaseType="NUMBER" datatype="java.lang.Double" physicalName="to_do_limit"/>
        <bm:field name="approver_template_id"/>
        <bm:field name="approver_mail_flag"/>
        <bm:field name="approver_mail_template_id"/>
        <bm:field name="approver_sms_flag"/>
        <bm:field name="approver_sms_template_id"/>
        <bm:field name="notice_template_id"/>
        <bm:field name="notice_mail_flag"/>
        <bm:field name="notice_mail_template_id"/>
        <bm:field name="notice_sms_flag"/>
        <bm:field name="notice_sms_template_id"/>
        <bm:field name="approver_template_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="approver_mail_template_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="approver_sms_template_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="notice_template_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="notice_mail_template_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="notice_sms_template_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="notice_display_type"/>
        <bm:field name="notice_display_service_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="notice_display_service_name" forInsert="false" forUpdate="false"/>
        <bm:field name="notice_display_service_id"/>
        <bm:field name="app_approve_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="APP_APPROVE_FLAG"/>
        <bm:field name="app_approve_flag_desc" forInsert="false" forUpdate="false"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select t1.node_id,
				       t1.workflow_id,
				       t1.sequence_num,
				       t1.node_desc,
				       t1.node_type,
				       t1.node_type_desc,
				       t1.approval_type,
				       t1.approval_type_desc,
				       t1.can_no_approver_flag,
				       t1.can_no_approver_flag_desc,
				       t1.can_transfer_approver_flag,
				       t1.hide_approve_record_flag,
				       t1.can_add_approver_flag,
				       t1.mail_flag,
				       t1.mail_flag_desc,
				       t1.link_workflow_id,
				       t1.link_workflow_code,
				       t1.link_workflow_desc,
				       t1.notify_template_id,
				       t1.notify_template_code,
				       t1.notify_template_desc,
				       t1.branch_procedure,
				       t1.branch_exec_procedure,
				       t1.branch_procedure_code,
				       t1.branch_procedure_desc,
				       t1.approval_type_factor,
				       t1.can_auto_pass_flag,
				       t1.is_self_re_commit_flag,
				       t1.system_maintain_flag,
				       t1.info_complete_rate,
				       t1.info_complete_note,
				       t1.node_display_type,
				       t1.node_display_type_desc,
       				   t1.node_display_service_id,
       				   t1.node_display_service_desc,
       				   t1.node_display_service_name,
       				   t1.show_approve_history_flag,
       				   t1.show_all_approve_ht_flag,
       				   t1.app_approve_flag,
       				   t1.app_approve_flag_desc,
       				   t1.sms_flag,
       				   t1.sms_template_id,
       				   t1.sms_template_code,
       				   t1.sms_template_desc,
       				   t1.branch_method,
       				   t1.branch_method_desc,
       				   t1.branch_business_rule,
       				   t1.branch_business_rule_desc,
       				   t1.node_display_my_app_svc_id,
       				   t1.node_display_my_app_svc_desc,
       				   t1.node_display_my_app_svc_name,
       				   t1.node_display_my_app_type,
       				   t1.to_do_limit,
       				   t1.approver_template_id, 
       				   t1.approver_template_desc,
						t1.approver_mail_flag,
						t1.approver_mail_template_id, 
						t1.approver_mail_template_desc,
						t1.approver_sms_flag, 
						t1.approver_sms_template_id,
						t1.approver_sms_template_desc,
						t1.notice_template_id, 
						t1.notice_template_desc,
						t1.notice_mail_flag, 
						t1.notice_mail_template_id, 
						t1.notice_mail_template_desc,
						t1.notice_sms_flag, 
						t1.notice_sms_template_id,
					    t1.notice_sms_template_desc,
					    t1.notice_display_type,
					    t1.notice_display_service_name,
					    t1.notice_display_service_desc,
					    t1.notice_display_service_id
				  from zj_wfl_workflow_node_v t1
				 #WHERE_CLAUSE#
				 order by t1.sequence_num
    		]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="node_id" input="false" output="true" outputPath="@node_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
        		begin
				  zj_wfl_workflow_pkg.node_handle(p_sql_type				   => 'INSERT',
				  								  p_node_id                    => ${@node_id},
				                                  p_workflow_id                => ${@workflow_id},
				                                  p_sequence_num               => ${@sequence_num},
				                                  p_node_desc                  => ${@node_desc},
				                                  p_node_type                  => ${@node_type},
				                                  p_approval_type              => ${@approval_type},
				                                  p_mail_flag                  => ${@mail_flag},
				                                  p_link_workflow_id           => ${@link_workflow_id},
				                                  p_notify_template_id         => ${@notify_template_id},
				                                  p_branch_procedure           => ${@branch_procedure},
				                                  p_can_no_approver_flag       => ${@can_no_approver_flag},
				                                  p_user_id                    => ${/session/@user_id},
				                                  p_approval_type_factor       => ${@approval_type_factor},
				                                  p_can_auto_pass_flag         => ${@can_auto_pass_flag},
				                                  p_is_self_re_commit_flag     => ${@is_self_re_commit_flag},
				                                  p_system_maintain_flag       => ${@system_maintain_flag},
				                                  p_info_complete_rate         => ${@info_complete_rate},
				                                  p_info_complete_note         => ${@info_complete_note},
				                                  p_can_transfer_approver_flag => ${@can_transfer_approver_flag},
				                                  p_hide_approve_record_flag   => ${@hide_approve_record_flag},
				                                  p_can_add_approver_flag      => ${@can_add_approver_flag},
				                                  p_node_display_type          => ${@node_display_type},
				                                  p_node_display_service_id    => ${@node_display_service_id},
				                                  p_show_approve_history_flag  => ${@show_approve_history_flag},
				                                  p_show_all_approve_ht_flag   => ${@show_all_approve_ht_flag},
				                                  p_sms_flag				   => ${@sms_flag},
				                                  p_sms_template_id			   => ${@sms_template_id},
				                                  p_branch_method			   => ${@branch_method},
				                                  p_branch_business_rule	   => ${@branch_business_rule},
				                                  p_node_display_my_app_svc_id => ${@node_display_my_app_svc_id},
						                          p_node_display_my_app_type   => ${@node_display_my_app_type},
						                          p_to_do_limit				   => ${@to_do_limit},
						                          p_approver_template_id       => ${@approver_template_id},
							                      p_approver_mail_flag         => ${@approver_mail_flag},
							                      p_approver_mail_template_id  => ${@approver_mail_template_id},
							                      p_approver_sms_flag          => ${@approver_sms_flag},
							                      p_approver_sms_template_id   => ${@approver_sms_template_id},
							                      p_notice_template_id         => ${@notice_template_id},
							                      p_notice_mail_flag           => ${@notice_mail_flag},
							                      p_notice_mail_template_id    => ${@notice_mail_template_id},
							                      p_notice_sms_flag            => ${@notice_sms_flag},
							                      p_notice_sms_template_id     => ${@notice_sms_template_id},
							                      p_notice_display_type	       => ${@notice_display_type},
							                      p_notice_display_service_id  => ${@notice_display_service_id},
							                      p_app_approve_flag           => ${@app_approve_flag});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
				  zj_wfl_workflow_pkg.node_handle(p_sql_type				   => 'UPDATE',
				  								  p_node_id                    => ${@node_id},
				                                  p_workflow_id                => ${@workflow_id},
				                                  p_sequence_num               => ${@sequence_num},
				                                  p_node_desc                  => ${@node_desc},
				                                  p_node_type                  => ${@node_type},
				                                  p_approval_type              => ${@approval_type},
				                                  p_mail_flag                  => ${@mail_flag},
				                                  p_link_workflow_id           => ${@link_workflow_id},
				                                  p_notify_template_id         => ${@notify_template_id},
				                                  p_branch_procedure           => ${@branch_procedure},
				                                  p_can_no_approver_flag       => ${@can_no_approver_flag},
				                                  p_user_id                    => ${/session/@user_id},
				                                  p_approval_type_factor       => ${@approval_type_factor},
				                                  p_can_auto_pass_flag         => ${@can_auto_pass_flag},
				                                  p_is_self_re_commit_flag     => ${@is_self_re_commit_flag},
				                                  p_system_maintain_flag       => ${@system_maintain_flag},
				                                  p_info_complete_rate         => ${@info_complete_rate},
				                                  p_info_complete_note         => ${@info_complete_note},
				                                  p_can_transfer_approver_flag => ${@can_transfer_approver_flag},
				                                  p_hide_approve_record_flag   => ${@hide_approve_record_flag},
				                                  p_can_add_approver_flag      => ${@can_add_approver_flag},
				                                  p_node_display_type          => ${@node_display_type},
				                                  p_node_display_service_id    => ${@node_display_service_id},
				                                  p_show_approve_history_flag  => ${@show_approve_history_flag},
				                                  p_show_all_approve_ht_flag   => ${@show_all_approve_ht_flag},
				                                  p_sms_flag				   => ${@sms_flag},
				                                  p_sms_template_id			   => ${@sms_template_id},
				                                  p_branch_method			   => ${@branch_method},
				                                  p_branch_business_rule	   => ${@branch_business_rule},
				                                  p_node_display_my_app_svc_id => ${@node_display_my_app_svc_id},
						                          p_node_display_my_app_type   => ${@node_display_my_app_type},
						                          p_to_do_limit				   => ${@to_do_limit},
						                          p_approver_template_id       => ${@approver_template_id},
							                      p_approver_mail_flag         => ${@approver_mail_flag},
							                      p_approver_mail_template_id  => ${@approver_mail_template_id},
							                      p_approver_sms_flag          => ${@approver_sms_flag},
							                      p_approver_sms_template_id   => ${@approver_sms_template_id},
							                      p_notice_template_id         => ${@notice_template_id},
							                      p_notice_mail_flag           => ${@notice_mail_flag},
							                      p_notice_mail_template_id    => ${@notice_mail_template_id},
							                      p_notice_sms_flag            => ${@notice_sms_flag},
							                      p_notice_sms_template_id     => ${@notice_sms_template_id},
							                      p_notice_display_type	       => ${@notice_display_type},
							                      p_notice_display_service_id  => ${@notice_display_service_id},
							                      p_app_approve_flag           => ${@app_approve_flag});
				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
            begin
				zj_wfl_workflow_pkg.delete_wfl_node
				(
					p_node_id        	      => ${@node_id},					
					p_user_id                 => ${/session/@user_id}
				);
			end;
			]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="node_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="node_id" queryOperator="="/>
    </bm:query-fields>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.workflow_id = ${@workflow_id}"/>
    </bm:data-filters>
    <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>
