2

I am working on a project, using templates to generate all my rules. I have one problem though, I wanna parse my arguments to the template as a ArrayList, and do somthing like this:

template header

 ruleId
 args

package dk.prks 
import com.poc.entity.Bill;
import com.poc.entity.BillLine;
import com.poc.entity.Description;
import java.util.ArrayList;

template "01"


rule "@{ruleId}_@{row.rowNumber}"
  dialect "mvel" 
    when 
      $bill : Bill ($line : lines) and
      BillLine( service == @{args.get(0)}, $lineNr : lineNr) from $line and
      BillLine( service == @{args.get(1)}, lineNr < $lineNr) from $line          
    then
      $bill.setColor(1);

end

end template

However, this is not possible. Furthermore I want to stretch that performance is an issue, and i want the generated file to only contain the values from the list, and not make any look ups in the array when running my rules

  • I don't have much experience with drools templates, but as far as I remember, there is not too much 'magic' going on there. If you can't use drools-templates for some reason, I would recommend you to use another template mechanism/framework such as velocity, antlr stringtemplate, etc. – Esteban Aliverti Nov 21 '13 at 07:42
  • Well, the choice of using drools templates is really not mine to make, but you are right that not that much is supported yet.. – Peter Troelsen Nov 21 '13 at 13:11

0 Answers0