@Override
public String marshal(RuleModel model) {
TemplateModel tplModel = (TemplateModel) model;
String ruleTemplate = super.marshalRule(model);
log.debug("ruleTemplate:\n{}", ruleTemplate);
DataProviderCompiler tplCompiler = new DataProviderCompiler();
DataProvider dataProvider;
if (tplModel.getRowsCount() > 0) {
dataProvider = new ArrayDataProvider(tplModel.getTableAsArray());
} else {
dataProvider = new ArrayDataProvider(generateEmptyIterator(tplModel));
}
String generatedDRl = tplCompiler.compile(dataProvider, new ByteArrayInputStream(ruleTemplate.getBytes()))
.substring(PACKAGE_DECLARATION.length()).trim();
log.debug("generated drl:\n{}", generatedDRl);
return generatedDRl;
}