<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-8-27 下午3:40:34  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="ZJ_WFL_WORKFLOW_NODE_SVC_PARA">
    <bm:fields>
        <bm:field name="node_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="NODE_ID" prompt="ZJ_WFL_WORKFLOW_NODE_SVC_PARA.NODE_ID"/>
        <bm:field name="sequence_num" forInsert="false" forUpdate="false"/>
        <bm:field name="parameter_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="PARAMETER_ID" prompt="ZJ_WFL_WORKFLOW_NODE_SVC_PARA.PARAMETER_ID"/>
        <bm:field name="parameter_code" forInsert="false" forUpdate="false"/>
        <bm:field name="parameter_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="parameter_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_TYPE" prompt="ZJ_WFL_WORKFLOW_NODE_SVC_PARA.PARAMETER_TYPE"/>
        <bm:field name="parameter_value_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="parameter_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PARAMETER_VALUE" prompt="ZJ_WFL_WORKFLOW_NODE_SVC_PARA.PARAMETER_VALUE"/>
        <bm:field name="source_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SOURCE_TYPE" prompt="ZJ_WFL_WORKFLOW_NODE_SVC_PARA.SOURCE_TYPE"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			select t1.service_para_id as parameter_id,
				       ${@node_id} as node_id,
				       ${@source_type} as source_type,
				       t1.sequence_num,
				       t1.parameter_code,
				       t1.parameter_desc,
				       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_SERVICE_PARA t1, ZJ_WFL_WORKFLOW_NODE_SVC_PARA p
				 where t1.service_id = ${@service_id}
				   and p.node_id(+) = ${@node_id}
				   and p.source_type(+) = ${@source_type}
				   and p.parameter_id(+) = t1.service_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.node_service_save(p_node_id       	=> ${@node_id},
				  										p_source_type		=> ${@source_type},
														p_parameter_id      => ${@parameter_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:model>
