<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="HN_EXP_SCORE" defaultOrderBy="owner_user_desc,score_user_desc,unit_name,position_name">
    <bm:fields>
        <bm:field name="exp_score_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="EXP_SCORE_ID" prompt="HN_EXP_SCORE.EXP_SCORE_ID"/>
        <bm:field name="score_year_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SCORE_YEAR_ID" prompt="HN_EXP_SCORE.SCORE_YEAR_ID"/>
        <bm:field name="owner_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OWNER_USER_ID" prompt="HN_EXP_SCORE.OWNER_USER_ID"/>
        <bm:field name="score_user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SCORE_USER_ID" prompt="HN_EXP_SCORE.SCORE_USER_ID"/>
        <bm:field name="score_sum" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SCORE_SUM" prompt="HN_EXP_SCORE.SCORE_SUM"/>
        <bm:field name="submit_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SUBMIT_FLAG" prompt="HN_EXP_SCORE.SUBMIT_FLAG"/>
        <bm:field name="user_name" expression="(select description from sys_user su where su.user_id = t1.score_user_id)"/>
        <bm:field name="position_name" expression="(select v.position_name from exp_employee_assigns_v v,sys_user su where v.employee_id=su.employee_id and v.primary_position_flag = &apos;Y&apos; and v.employee_enabled=&apos;Y&apos; and su.user_id= t1.score_user_id)"/>
        <bm:field name="unit_name" expression="(select v.unit_name from exp_employee_assigns_v v,sys_user su where v.employee_id=su.employee_id and v.primary_position_flag = &apos;Y&apos; and v.employee_enabled=&apos;Y&apos; and su.user_id= t1.score_user_id)"/>
        <bm:field name="submit_flag_n" expression="(select v.code_value_name from sys_code_values_v v where v.code=&apos;YES_NO&apos; and v.code_value=t1.submit_flag)"/>
        <bm:field name="owner_user_desc"/>
        <bm:field name="score_user_desc"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="exp_score_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="execute">
            <bm:update-sql><![CDATA[
            	begin
            	hn_exp_score_pkg.submit_exp_score(p_score_year_id =>${@score_year_id},  
            	                                p_owner_user_id =>${/session/@user_id});
            	end;
    		]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
            	begin
            	hn_exp_score_pkg.init_exp_score(p_score_year_id =>${@score_year_id},
                           p_owner_user_id =>${/session/@user_id});
            	end;
    		]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="score_user_desc" queryExpression="t1.score_user_desc like &apos;%&apos;||${@score_user_desc}||&apos;%&apos;"/>
        <bm:query-field name="owner_user_desc" queryExpression="t1.owner_user_desc like &apos;%&apos;||${@owner_user_desc}||&apos;%&apos;"/>
        <bm:query-field name="owner_user_id" queryExpression="t1.owner_user_id=${@owner_user_id}"/>
        <bm:query-field name="score_year_id" queryExpression="t1.score_year_id = ${@score_year_id}"/>
        <bm:query-field name="user_name" queryExpression="(select description from sys_user su where su.user_id = t1.score_user_id) like &apos;%&apos;||${@user_name}||&apos;%&apos;"/>
        <bm:query-field name="position_name" queryExpression="(select v.position_name from exp_employee_assigns_v v,sys_user su where v.employee_id=su.employee_id and v.primary_position_flag = &apos;Y&apos; and v.employee_enabled=&apos;Y&apos; and su.user_id= t1.score_user_id) like &apos;%&apos;||${@position_name}||&apos;%&apos;"/>
        <bm:query-field name="unit_name" queryExpression="(select v.unit_name from exp_employee_assigns_v v,sys_user su where v.employee_id=su.employee_id and v.primary_position_flag = &apos;Y&apos; and v.employee_enabled=&apos;Y&apos; and su.user_id= t1.score_user_id) like &apos;%&apos;||${@unit_name}||&apos;%&apos;"/>
        <bm:query-field name="submit_flag_n" queryExpression="t1.submit_flag=${@submit_flag}"/>
        <bm:query-field name="score_sum_from" queryExpression="t1.score_sum &gt;=${@score_sum_from}"/>
        <bm:query-field name="score_sum_to" queryExpression="t1.score_sum &lt;=${@score_sum_to}"/>
    </bm:query-fields>
</bm:model>
