<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features">
    <bm:fields>
        <bm:field name="procedure_para_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PROCEDURE_PARA_ID"/>
        <bm:field name="sequence_num" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SEQUENCE_NUM"/>
        <bm:field name="parameter_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_CODE"/>
        <bm:field name="parameter_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_DESC"/>
        <bm:field name="parameter_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_TYPE"/>
        <bm:field name="parameter_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_VALUE"/>
        <bm:field name="parameter_value_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_VALUE_DESC"/>
        <bm:field name="workflow_procedure_id"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            	select t1.procedure_para_id,
				       t1.sequence_num,
				       t1.parameter_code,
				       t1.parameter_desc,
				       ${@workflow_procedure_id} as workflow_procedure_id,
				       p.parameter_type,
				       p.parameter_value,
				       decode(p.parameter_type,
				              'DEFAULT',
				              p.parameter_value,
				              'WFL_INSTANCE_PARA',
				              (select v.code_value_name
				                 from sys_code_values_v v
				                where v.code_value = p.parameter_value
				                  and v.code = 'ZJ_WFL_INSTANCE_PARA_VALUES'),
				              'WFL_TYPE_PARA',
				              (select tp.parameter_desc
				                 from zj_wfl_workflow_type_parameter tp
				                where tp.workflow_type_para_id = p.parameter_value),
				              null) parameter_value_desc
				  from zj_wfl_workflow_procedure_para t1, ZJ_WFL_WORKFLOW_END_PROC_PARA p
				 where t1.procedure_id = ${@procedure_id}
				   and p.workflow_procedure_id(+) = ${@workflow_procedure_id}
				   and p.procedure_para_id(+) = t1.procedure_para_id
				 order by t1.sequence_num
		    ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin
				zj_wfl_workflow_pkg.save_wfl_end_procedure_para
				(
					p_workflow_procedure_id   => ${@workflow_procedure_id},
					p_procedure_para_id       => ${@procedure_para_id},
					p_parameter_type          => ${@parameter_type},
					p_parameter_value         => ${@parameter_value},
					p_user_id                 => ${/session/@user_id}
				);
			end; 
			]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:query-fields>
        <bm:query-field name="workflow_procedure_id" queryExpression="t1.workflow_procedure_id = ${/parameter/@workflow_procedure_id}"/>
    </bm:query-fields>
</bm:model>
