<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-4-2 上午9:38:57  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:e="leaf.service.exception" xmlns:f="leaf.database.features" xmlns:bm="http://www.leaf-framework.org/schema/bm" alias="t1" baseTable="FND_SCORE_TEMPLATE">
    <bm:fields>
        <bm:field name="score_template_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SCORE_TEMPLATE_ID" prompt="FND713.FND_SCORE_TEMPLATE.SCORE_TEMPLATE_ID"/>
        <bm:field name="score_template_code" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="SCORE_TEMPLATE_CODE" prompt="FND713.FND_SCORE_TEMPLATE.SCORE_TEMPLATE_CODE"/>
        <bm:field name="score_template_name" databaseType="VARCHAR2" datatype="java.lang.String" forDisplay="true" forQuery="true" physicalName="SCORE_TEMPLATE_NAME" prompt="FND713.FND_SCORE_TEMPLATE.SCORE_TEMPLATE_NAME"/>
        <bm:field name="target_type_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TARGET_TYPE_CODE"/>
        <bm:field name="target_type_name" forInsert="false" forUpdate="false" prompt="FND713.FND_SCORE_TEMPLATE.TARGET_TYPE_CODE"/>
        <bm:field name="total_score_value" databaseType="NUMBER" datatype="java.lang.Long" physicalName="TOTAL_SCORE_VALUE" prompt="FND713.FND_SCORE_TEMPLATE.TOTAL_SCORE_VALUE"/>
        <bm:field name="score_method_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="score_method" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SCORE_METHOD" prompt="FND713.FND_SCORE_TEMPLATE.SCORE_METHOD"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="FND713.FND_SCORE_TEMPLATE.ENABLED_FLAG"/>
        <bm:field name="template_type" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="TEMPLATE_TYPE"/>
        <!--  <bm:field name="grade_from" databaseType="NUMBER" datatype="java.lang.Long" physicalName="GRADE_FROM" prompt="FND713.FND_SCORE_TEMPLATE.GRADE_FROM"/>
        <bm:field name="grade_to" databaseType="NUMBER" datatype="java.lang.Long" physicalName="GRADE_TO" prompt="FND713.FND_SCORE_TEMPLATE.GRADE_TO"/>
        <bm:field name="step" databaseType="NUMBER" datatype="java.lang.Long" physicalName="STEP" prompt="FND713.FND_SCORE_TEMPLATE.STEP"/>
   -->
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.score_template_id,
                    t1.score_template_code,
                    t1.score_template_name,
                    t1.target_type_code,
                    t1.template_type,
                    (SELECT
                        t.target_type_name
                    FROM
                        fnd_score_target_type t
                    WHERE
                        t.target_type_code = t1.target_type_code
                    ) AS target_type_name,
                    t1.total_score_value,
                    t1.enabled_flag,
                    t1.score_method,
                    (SELECT
                        s.code_value_name
                    FROM
                        sys_code_values_v s
                    WHERE
                        s.code       = 'FND_SCORE_SCORE_METHOD' AND
                        s.code_value = t1.SCORE_METHOD
                    )score_method_desc
                FROM
                    fnd_score_template t1 #WHERE_CLAUSE#
                ORDER BY
                    t1.score_template_code
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="score_template_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="score_template_id" queryOperator="="/>
        <bm:query-field field="score_template_code" queryOperator="like"/>
        <bm:query-field field="score_template_name" queryOperator="like"/>
    </bm:query-fields>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="FND713.ERROR_MESSAGE.SCORE_TEMPLATE_CODE_REPEATED"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
