<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: hp  
    $Date: 2013-8-5 下午02:53:23  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="RSC_FIVE_CLASS_RULE_DETAIL">
    <bm:fields>
        <bm:field name="rule_detail_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="RULE_DETAIL_ID" prompt="RSC_FIVE_CLASS_RULE_DETAIL.RULE_DETAIL_ID"/>
        <bm:field name="five_class_rule_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="FIVE_CLASS_RULE_ID" prompt="RSC_FIVE_CLASS_RULE_DETAIL.FIVE_CLASS_RULE_ID"/>
        <bm:field name="sequence_no" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SEQUENCE_NO" prompt="RSC_FIVE_CLASS_RULE_DETAIL.SEQUENCE_NO"/>
        <bm:field name="left_bracket" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LEFT_BRACKET" prompt="RSC_FIVE_CLASS_RULE_DETAIL.LEFT_BRACKET"/>
        <bm:field name="include_target_value" forInsert="false" forUpdate="false"/>
        <bm:field name="five_class_target" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="FIVE_CLASS_TARGET" prompt="RSC_FIVE_CLASS_RULE_DETAIL.FIVE_CLASS_TARGET"/>
        <bm:field name="calculate_symbol" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CALCULATE_SYMBOL" prompt="RSC_FIVE_CLASS_RULE_DETAIL.CALCULATE_SYMBOL"/>
        <bm:field name="calculate_value" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CALCULATE_VALUE" prompt="RSC_FIVE_CLASS_RULE_DETAIL.CALCULATE_VALUE"/>
        <bm:field name="calculate_value_desc" forInsert="false" forUpdate="false"/>
        <bm:field name="right_bracket" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RIGHT_BRACKET" prompt="RSC_FIVE_CLASS_RULE_DETAIL.RIGHT_BRACKET"/>
        <bm:field name="logic_calc_symbol" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="LOGIC_CALC_SYMBOL" prompt="RSC_FIVE_CLASS_RULE_DETAIL.LOGIC_CALC_SYMBOL"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    			SELECT T1.rule_detail_id,
				       T1.five_class_rule_id,
				       T1.sequence_no,
				       T1.left_bracket,
				       T1.five_class_target,
				       T1.calculate_symbol,
				       T1.calculate_value,
				       (SELECT t.include_target_value
                        from RSC_FIVE_CLASS_TARGET t
                       where t.five_class_target = t1.five_class_target)include_target_value,
				       decode((SELECT t.include_target_value
				                from RSC_FIVE_CLASS_TARGET t
				               where t.five_class_target = t1.five_class_target),
				              'N',
				              t1.calculate_value,
				              'Y',
				              (select d.value_name from rsc_five_class_target_value d where d.target_value=t1.calculate_value and d.five_class_target=t1.five_class_target)) as calculate_value_desc,
				       T1.right_bracket,
				       T1.logic_calc_symbol
				  FROM rsc_five_class_rule_detail t1
				  #WHERE_CLAUSE#
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:features>
        <o:sequence-pk/>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="rule_detail_id"/>
    </bm:primary-key>
    <bm:query-fields>
        <bm:query-field field="five_class_rule_id" queryOperator="="/>
        <bm:query-field name="lamp_color" queryExpression="(t1.five_class_rule_id = (select r1.five_class_rule_id from rsc_fc_target_signal_lamp r1 where r1.five_class_target=${@five_class_target} and r1.lamp_color=${@lamp_color}))"/>
    </bm:query-fields>
</bm:model>
