<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-9-5 下午02:31:29  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (
            	select sc.result_id,
				       sc.sc_score_id,
				       sc.template_type,
                       sc.last_updated_by,
                      (select u.user_name from sys_user u where u.user_id=sc.last_updated_by) last_update_name,
				       (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'FND_SC_TEMPLATE_TYPE'
				           and v.code_value = sc.template_type) as template_type_desc,
				       sc.object_id,
				       decode(sc.template_type,
				              'LGD',
				              (select prj.project_name
				                 from prj_project prj
				                where prj.project_id = sc.object_id),
				              'PD',
				              (select bp.bp_name
				                 from hls_bp_master bp
				                where bp.bp_id = sc.object_id),
				              '') object_name,
				       sc.score_template_id,
				       (select te.score_template_name
				          from fnd_score_template te
				         where te.score_template_id = sc.score_template_id) template_name,
				       sc.internal_period_num,
				       sc.score_date,
				       sc.description,
				       sc.score_result,
				       sc.status,
				       (select v.code_value_name
				          from sys_code_values_v v
				         where v.code = 'FND_SCORE_CARD_APPROVAL_STATUS'
				           and sc.status = v.code_value) status_desc,
				           fnd_score_target_pkg.get_evaluate_level(sc.result_id) evaluate_level,
				        fnd_score_target_pkg.get_evaluate_level_desc(sc.result_id) evaluate_level_desc,
				        h.bp_id
				  from fnd_sc_score_result sc,hls_bp_master h  where h.result_id = sc.result_id) t1
				  #WHERE_CLAUSE#
 
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:fields>
        <bm:field name="sc_score_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SC_SCORE_ID"/>
        <bm:field name="result_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RESULT_ID"/>
        <bm:field name="template_type"/>
        <bm:field name="template_name"/>
        <bm:field name="template_type_desc"/>
        <bm:field name="object_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="OBJECT_ID"/>
        <bm:field name="object_name"/>
        <bm:field name="last_updated_by" databaseType="NUMBER" datatype="java.lang.Long"/>
        <bm:field name="last_update_name" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="score_template_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SCORE_TEMPLATE_ID"/>
        <bm:field name="internal_period_num" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="score_result" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="score_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String"/>
        <bm:field name="status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS"/>
        <bm:field name="evaluate_level"/>
        <bm:field name="evaluate_level_desc"/>
        <bm:field name="bp_id"/>
    </bm:fields>
    <bm:query-fields>
        <bm:query-field field="object_id" queryOperator="="/>
        <bm:query-field field="object_name" queryOperator="like"/>
        <bm:query-field field="result_id" queryOperator="="/>
    </bm:query-fields>
</bm:model>
