[rules-users] Smart Templates

ChrisMu christopher.mullard at credit-suisse.com
Wed Jun 1 11:06:28 EDT 2011


Ideally:
Load the data from a DB and instantiate Java objects with that. Then generate the rule set using a template.
 
The DB data would provide the list of permitted values per field. 
The rule results are generated based on the inputs.
 
This avoids users having to enter one rule for every single currency and commodity type (using the example below) when there are only 2 underlying 'rules'.
If another currency is then added to the data in the DB, the new rule will be automatically generated.

________________________________

From: FrankVhh [via Drools] [mailto:ml-node+3011148-1318721408-404175 at n3.nabble.com] 
Sent: 01 June 2011 15:57
To: Mullard, Christopher
Subject: RE: [rules-users] Smart Templates


Hi, 

Basically, you have 2 options. 

1) You call the function getType() from your .drl file. The function will be executed at runtime. 

header 
name 
value 

TEMPLATE 
WHEN 
blabla 
THEN 
$type.setName($service.getType("@{value}")); 

2) Execute the function before you compile your rules with Rule Templates. I.e. make sure your objects have an attribute whose value will be set by getType() and use this value in the Template. 

header 
name 
value 
type 

TEMPLATE 
WHEN 
blabla 
THEN 
$type.setName("@{type}"); 

Hope this helps. 

Btw, am I understanding it correctly that you do not want to use a Decision Table because you are worried about manageability of your ruleset? And, in stead, you want to create rules directly from Java objects, using templates. If this is correct, could you tell me how you are going to manage these objects? 

Regards, 
Frank 




	ChrisMu wrote:
	Sorry - you're losing me - could you give an example please? 
	
	Thanks 
	
	________________________________ 
	
	From: Wolfgang Laun-2 [via Drools] [mailto:[hidden email]] 
	Sent: 01 June 2011 15:25 
	To: Mullard, Christopher 
	Subject: Re: [rules-users] Smart Templates 
	
	
	It's just like a Java static method. Call JAva code if you don't want to put it all into DRL function, or import from Java in the first place. Both "import" and "function" can be used in spreadsheets. 
	-W 
	
	
	
	2011/6/1 ChrisMu <[hidden email]> 
	
	
	        Agreed, but this was just an example - if the function required something more complicated - say a DB lookup, could it be done? 
	
	________________________________ 
	
	        From: Wolfgang Laun-2 [via Drools] [mailto:[hidden email] <http://user/SendEmail.jtp?type=node&node=3010490&i=0> ] 
	        Sent: 01 June 2011 12:40 
	        To: Mullard, Christopher 
	        Subject: Re: [rules-users] Smart Templates 
	        
	        
	        If there are just 2 types (IRDELTA, COMLEASEDELTA) you can add a function that computes this from the 3-letter name. 
	        -W 
	        
	        
	        
	        2011/6/1 ChrisMu <[hidden email] <http://user/SendEmail.jtp?type=node&node=3010275&i=0> > 
	        
	
	                Possibly. Let me try again with what I'm trying to achieve. 
	                Given this excerpt from a decision table: 
	                  
	                
	                  
	                Basically I want to be able to specify a template that says 'If Arg0 is a currency, output RiskType IRDELTA (and currency), if Arg0 is a commodity (begins with 'X') then output RiskType COMLEASEDELTA (and commodity). 
	                  
	                When fed with data, this would generate the rules: 
	                  
	                when Arg0 = USD, output RiskType IRDELTA, USD 
	                when Arg0 = GBP, output RiskType IRDELTA, GBP 
	                etc 
	                when Arg0 = XAU, output RiskType COMLEASEDELTA, XAU 
	                etc 
	                  
	                In this way theRiskType name is inferred from the data when the rules are generated. It can be done by explicitly stating all possible combinations as in the decision table above but that gets tedious quickly. I wanted to have a more general template that could generate all the specific rules instances. 
	                  
	                Does that make more sense? 
	                  
	                Thanks 
	                Chris 
	                  
	
	________________________________ 
	
	                From: Wolfgang Laun-2 [via Drools] [mailto:[hidden email] <http://user/SendEmail.jtp?type=node&node=3010119&i=0> ] 
	                Sent: 01 June 2011 11:21 
	                To: Mullard, Christopher 
	                Subject: Re: [rules-users] Smart Templates 
	                
	                
	                I don't want to confuse you, but have you considered not using templates at all? If you can generate N rules from N objects containing different literals for matching a fact or for updating a fact field, then you can achieve the same thing with a single rule and additional facts containing those literal values. 
	                
	                rule "one 4 all" 
	                when 
	                Â Â  Service( $name: name, $value: value ) 
	                Â Â  $sb: ServiceBean( name == $name, value == $value ) 
	                then 
	                Â Â  # RiskType ... is what? 
	                Â Â  ...$value..., ...$sb.getType()... 
	                end 
	                
	                -W 
	                
	                
	                _______________________________________________ 
	                rules-users mailing list 
	                [hidden email] <http://user/SendEmail.jtp?type=node&node=3010097&i=0>  
	                https://lists.jboss.org/mailman/listinfo/rules-users
	                
	                
	                
	________________________________ 
	
	                If you reply to this email, your message will be added to the discussion below: 
	                http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010097.html  
	                To unsubscribe from Smart Templates, click here. 
	
	
	                ============================================================================== 
	                Please access the attached hyperlink for an important electronic communications disclaimer: 
	                http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
	                ============================================================================== 
	
	
	
	________________________________ 
	
	                View this message in context: RE: [rules-users] Smart Templates <http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010119.html>  
	                Sent from the Drools: User forum mailing list archive <http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html>  at Nabble.com. 
	                
	                _______________________________________________ 
	                rules-users mailing list 
	                [hidden email] <http://user/SendEmail.jtp?type=node&node=3010275&i=1>  
	                https://lists.jboss.org/mailman/listinfo/rules-users
	                
	                
	
	
	
	        _______________________________________________ 
	        rules-users mailing list 
	        [hidden email] <http://user/SendEmail.jtp?type=node&node=3010275&i=2>  
	        https://lists.jboss.org/mailman/listinfo/rules-users
	        
	        
	        
	________________________________ 
	
	        If you reply to this email, your message will be added to the discussion below: 
	        http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010275.html  
	        To unsubscribe from Smart Templates, click here. 
	
	
	        ============================================================================== 
	        Please access the attached hyperlink for an important electronic communications disclaimer: 
	        http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
	        ============================================================================== 
	
	
	
	________________________________ 
	
	        View this message in context: RE: [rules-users] Smart Templates <http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010490.html>  
	        Sent from the Drools: User forum mailing list archive <http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html>  at Nabble.com. 
	        
	        _______________________________________________ 
	        rules-users mailing list 
	        [hidden email] 
	        https://lists.jboss.org/mailman/listinfo/rules-users
	        
	        
	
	
	
	_______________________________________________ 
	rules-users mailing list 
	[hidden email] 
	https://lists.jboss.org/mailman/listinfo/rules-users
	
	
	
	________________________________ 
	
	If you reply to this email, your message will be added to the discussion below: 
	http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010989.html  
	To unsubscribe from Smart Templates, click here <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3006479&code=Y2hyaXN0b3BoZXIubXVsbGFyZEBjcmVkaXQtc3Vpc3NlLmNvbXwzMDA2NDc5fDE5NzczMDY1MzE=> . 
	
	=============================================================================== 
	Please access the attached hyperlink for an important electronic communications disclaimer: 
	http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html  
	=============================================================================== 



________________________________

If you reply to this email, your message will be added to the discussion below:
http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3011148.html 
To unsubscribe from Smart Templates, click here <http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3006479&code=Y2hyaXN0b3BoZXIubXVsbGFyZEBjcmVkaXQtc3Vpc3NlLmNvbXwzMDA2NDc5fDE5NzczMDY1MzE=> . 

=============================================================================== 
Please access the attached hyperlink for an important electronic communications disclaimer: 
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html 
=============================================================================== 



--
View this message in context: http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3011200.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110601/578ff6f6/attachment.html 


More information about the rules-users mailing list