use of org.drools.template.model.Condition in project drools by kiegroup.
the class RuleMatrixSheetListener method createCondition.
private Condition createCondition(final String value, final String conditionTemplate) {
SnippetBuilder snip = new SnippetBuilder(conditionTemplate);
String result = snip.build(value);
Condition condition = new Condition();
condition.setSnippet(result);
return condition;
}
use of org.drools.template.model.Condition in project drools by kiegroup.
the class DefaultTemplateColumn method createCellCondition.
private void createCellCondition(final Rule rule) {
StringBuffer conditionString = new StringBuffer();
Column column = templateContainer.getColumn(columnName);
column.getCondition(condition, index);
if (notCondition) {
conditionString.append("not ");
}
conditionString.append("exists ");
conditionString.append(column.getCondition(condition, index));
SnippetBuilder snip = new SnippetBuilder(conditionString.toString());
Condition condition = new Condition();
condition.setSnippet(snip.build(columnName));
rule.addCondition(condition);
}
use of org.drools.template.model.Condition in project drools by kiegroup.
the class RuleWorksheetParseTest method testQuoteEscapingDisabled.
@Test
public void testQuoteEscapingDisabled() throws Exception {
final InputStream stream = RuleWorksheetParseTest.class.getResourceAsStream("/data/QuoteEscapeDisabledWorkbook.xls");
final RuleSheetListener listener = getRuleSheetListener(stream);
final Package ruleset = listener.getRuleSet();
assertNotNull(ruleset);
DRLOutput dout = new DRLOutput();
ruleset.renderDRL(dout);
String drl = dout.getDRL();
System.out.println(drl);
// check rules
Rule rule = (Rule) ruleset.getRules().get(0);
Condition cond = (Condition) rule.getConditions().get(0);
assertEquals("Foo(myObject.getColour().equals(red), myObject.size () > \"12\")", cond.getSnippet());
rule = ruleset.getRules().get(1);
cond = rule.getConditions().get(0);
assertEquals("Foo(myObject.getColour().equals(blue), myObject.size () > 12\")", cond.getSnippet());
}
use of org.drools.template.model.Condition in project drools by kiegroup.
the class RuleWorksheetParseTest method testQuoteEscapingEnabled.
@Test
public void testQuoteEscapingEnabled() throws Exception {
final InputStream stream = RuleWorksheetParseTest.class.getResourceAsStream("/data/QuoteEscapeEnabledWorkbook.xls");
final RuleSheetListener listener = getRuleSheetListener(stream);
final Package ruleset = listener.getRuleSet();
assertNotNull(ruleset);
DRLOutput dout = new DRLOutput();
ruleset.renderDRL(dout);
String drl = dout.getDRL();
System.out.println(drl);
// check rules
Rule rule = ruleset.getRules().get(0);
Condition cond = rule.getConditions().get(0);
assertEquals("Foo(myObject.getColour().equals(red), myObject.size () > 12\\\")", cond.getSnippet());
}
use of org.drools.template.model.Condition in project drools by kiegroup.
the class DefaultTemplateRuleBase method createTemplateRule.
private void createTemplateRule(org.drools.template.model.Package p, int index, RuleTemplate template) {
Rule rule = new Rule(template.getName(), null, index);
Condition condition = new Condition();
condition.setSnippet("r : Row()");
rule.addCondition(condition);
createColumnConditions(template, rule);
rule.addConsequence(createConsequence(template));
p.addRule(rule);
}
Aggregations