Drools Kie - Rule Templates
Drools Guvnor - Rule Templates
Copyright Notice
Copyright © 2004-2025 by NobleProg Limited All rights reserved.
This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise.
Copy existing project and tests。⌘
- Copy npproj2 to npproj3
- Remove Decision Table
- Keep Data Objects and Tests
Create New Rule Template 新建规则模板 。⌘
- Create New -> New Rule Template
Create New Rule Template - Source 新建规则模板 - 源码 。⌘
Source should look like that: <source> package nppack;
rule "Progressive Discount Rule Template_3" dialect "mvel" when $sc : ShoppingCart( totalPrice >= 80000B , totalPrice < 99999999999B , discountRate == null ) then modify( $sc ) { setDiscountRate( 0.15 ) } end
rule "Progressive Discount Rule Template_2" dialect "mvel" when $sc : ShoppingCart( totalPrice >= 50000B , totalPrice < 80000B , discountRate == null ) then modify( $sc ) { setDiscountRate( 0.12 ) } end
rule "Progressive Discount Rule Template_1" dialect "mvel" when $sc : ShoppingCart( totalPrice >= 10000B , totalPrice < 50000B , discountRate == null ) then modify( $sc ) { setDiscountRate( 0.1 ) } end
rule "Progressive Discount Rule Template_0" dialect "mvel" when $sc : ShoppingCart( totalPrice >= 0B , totalPrice < 10000B , discountRate == null ) then modify( $sc ) { setDiscountRate( 0 ) } end </source>
Testing ⌘
- Disable Decision Table
- Use the same test and in the Drools Guvnor - Decision Table section
测试 。
- 关闭决策表
- 在 Drools Guvnor - Decision Table 部分使用相同的测试