<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="BGFL_OA_AUTO">
    <bm:fields>
        <bm:field name="oa_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OA_ID" prompt="BGFL_OA_AUTO.OA_ID"/>
        <bm:field name="oa_type" databaseType="VARCHAR2" datatype="java.lang.String" lookupCode="OA_TYPE" lookupField="oa_type_n" physicalName="OA_TYPE"/>
        <bm:field name="oa_type_n"/>
        <bm:field name="reason" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="REASON"/>
        <bm:field name="wfl_instance_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="WFL_INSTANCE_ID" prompt="BGFL_OA_AUTO.WFL_INSTANCE_ID"/>
        <bm:field name="status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS" prompt="BGFL_OA_AUTO.STATUS"/>
        <bm:field name="status_desc" expression="(select scv.code_value_name from sys_codes_vl sc, sys_code_values_vl scv where sc.code_id = scv.code_id and sc.code=&apos;OTHER_WFL_WORKFLOW_STATUS&apos; and scv.code_value=t1.status)"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="BGFL_OA_AUTO.DESCRIPTION"/>
        <bm:field name="auto_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="AUTO_FLAG" prompt="BGFL_OA_AUTO.AUTO_FLAG"/>
        <bm:field name="auto_flag_desc" expression="(select scv.code_value_name from sys_codes_vl sc, sys_code_values_vl scv where sc.code_id = scv.code_id and sc.code=&apos;YES_NO&apos; and scv.code_value=t1.auto_flag)"/>
        <bm:field name="config_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="CONFIG_ID" prompt="BGFL_OA_AUTO.CONFIG_ID"/>
        <bm:field name="config_id_desc" expression="(select description from bgfl_oa_auto_config t where t.config_id=t1.config_id)"/>
        <bm:field name="oa_parameter1" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OA_PARAMETER1" prompt="BGFL_OA_AUTO.OA_PARAMETER1"/>
        <bm:field name="oa_parameter1_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OA_PARAMETER1_DESC" prompt="BGFL_OA_AUTO.OA_PARAMETER1_DESC"/>
        <bm:field name="oa_parameter2" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OA_PARAMETER2" prompt="BGFL_OA_AUTO.OA_PARAMETER2"/>
        <bm:field name="oa_parameter2_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OA_PARAMETER2_DESC" prompt="BGFL_OA_AUTO.OA_PARAMETER2_DESC"/>
        <bm:field name="oa_parameter3" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OA_PARAMETER3" prompt="BGFL_OA_AUTO.OA_PARAMETER3"/>
        <bm:field name="oa_parameter3_desc" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="OA_PARAMETER3_DESC" prompt="BGFL_OA_AUTO.OA_PARAMETER3_DESC"/>
        <bm:field name="process_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROCESS_FLAG" prompt="BGFL_OA_AUTO.PROCESS_FLAG"/>
        <bm:field name="process_flag_desc" expression="(select scv.code_value_name from sys_codes_vl sc, sys_code_values_vl scv where sc.code_id = scv.code_id and sc.code=&apos;YES_NO&apos; and scv.code_value=t1.process_flag)"/>
        <bm:field name="process_suggestion" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PROCESS_SUGGESTION" prompt="BGFL_OA_AUTO.PROCESS_SUGGESTION"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="insert">
            <bm:update-sql><![CDATA[
			begin
			  -- Call the procedure
			  bgfl_oa_auto_config_pkg.bgfl_oa_auto_insert(p_description => ${@description},
			                                              p_oa_type => ${@oa_type},
			                                              p_reason => ${@reason},
			                                              p_auto_flag => ${@auto_flag},
			                                              p_config_id => ${@config_id},
			                                              p_oa_parameter1 => ${@oa_parameter1},
			                                              p_oa_parameter1_desc => ${@oa_parameter1_desc},
			                                              p_oa_parameter2 => ${@oa_parameter2},
			                                              p_oa_parameter2_desc => ${@oa_parameter2_desc},
			                                              p_oa_parameter3 => ${@oa_parameter3},
			                                              p_oa_parameter3_desc => ${@oa_parameter3_desc},
			                                              p_user_id => ${/session/@user_id});
			end;
			]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            begin
				bgfl_oa_auto_config_pkg.bgfl_oa_auto_update(p_oa_id         =>${@oa_id},
															p_oa_type            =>${@oa_type},
    														p_reason             =>${@reason},
															p_description   =>${@description},
                                                            p_auto_flag     =>${@auto_flag},
                                                            p_config_id     =>${@config_id},
                                                            p_oa_parameter1 =>${@oa_parameter1},
                                                            p_oa_parameter1_desc =>${@oa_parameter1_desc},
                                                            p_oa_parameter2 =>${@oa_parameter2},
                                                            p_oa_parameter2_desc =>${@oa_parameter2_desc},
                                                            p_oa_parameter3 =>${@oa_parameter3},
                                                            p_oa_parameter3_desc =>${@oa_parameter3_desc},
                                                            p_user_id       =>${/session/@user_id});
			end;
			]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="oa_id" queryOperator="="/>
        <bm:query-field field="oa_type" queryOperator="="/>
        <bm:query-field name="reason" queryExpression="reason like &apos;%&apos;||upper(${@reason})||&apos;%&apos;"/>
        <bm:query-field name="config_id_desc" queryExpression="config_id = ${@config_id}"/>
        <bm:query-field name="auto_flag_desc" queryExpression="auto_flag=${@auto_flag}"/>
        <bm:query-field name="status_desc" queryExpression="status=${@status}"/>
        <bm:query-field name="process_flag_desc" queryExpression="process_flag=${@process_flag}"/>
        <bm:query-field name="description" queryExpression="description like &apos;%&apos;||upper(${@description})||&apos;%&apos;"/>
        <bm:query-field name="process_suggestion" queryExpression="process_suggestion like &apos;%&apos;||upper(${@process_suggestion})||&apos;%&apos;"/>
        <bm:query-field name="oa_parameter1_desc" queryExpression="oa_parameter1_desc like &apos;%&apos;||upper(${@oa_parameter1_desc})||&apos;%&apos;"/>
    </bm:query-fields>
    <bm:primary-key>
        <bm:pk-field name="oa_id"/>
    </bm:primary-key>
</bm:model>
