[rules-users] Smart Templates

ChrisMu christopher.mullard at credit-suisse.com
Tue May 31 11:30:58 EDT 2011


Hi,

 I'm trying to get a template (.drt) to generate 2 rules (.drl) from 2
datasets but by doing a little bit more work than direct substitution.

Data (service,value):
DC, AAA
DC, XYZ

Idea for the template - if value is of type1 then create Type object with
'Type1' as name. If value is of type2, use 'Type2' as name:

rule "DC_@{row.rowNumber}"
when 
    Service(name == "DC")    
then 
    Type.setName(eval(Service.getType(@{value})))
    Type.setAtt(0,@{value})
end template

eval(Service.getType(@{arg0})) should take 'AAA' or 'XYZ' etc as arg and
return a string Type1/Type2 etc.

This would then generate 2 rules that look like:

rule "DC_0"
when 
    Service(name == "DC", value == "AAA")    
then 
    RiskType.setName("Type1")
    RiskType.setAtt(0,"AAA")

rule "DC_1"
when 
    Service(name == "DC", value == "XYZ")    
then 
    RiskType.setName("Type2")
    RiskType.setAtt(0,"XYZ")

...is this possible at all? I'm trying to avoid the eval step being done in
the actual rule (.drl) .

Thanks

Chris

--
View this message in context: http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006479.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list