Search in sources :

Example 1 with SnippetBuilder

use of org.drools.template.model.SnippetBuilder 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;
}
Also used : Condition(org.drools.template.model.Condition) SnippetBuilder(org.drools.template.model.SnippetBuilder)

Example 2 with SnippetBuilder

use of org.drools.template.model.SnippetBuilder 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);
}
Also used : Condition(org.drools.template.model.Condition) SnippetBuilder(org.drools.template.model.SnippetBuilder)

Example 3 with SnippetBuilder

use of org.drools.template.model.SnippetBuilder in project drools by kiegroup.

the class DefaultTemplateColumn method createColumnCondition.

private void createColumnCondition(final Rule rule, final String value) {
    SnippetBuilder colSnip = new SnippetBuilder("$param : Column(name == \"$param\")");
    Condition colCondition = new Condition();
    colCondition.setSnippet(colSnip.build(value));
    rule.addCondition(colCondition);
}
Also used : Condition(org.drools.template.model.Condition) SnippetBuilder(org.drools.template.model.SnippetBuilder)

Example 4 with SnippetBuilder

use of org.drools.template.model.SnippetBuilder in project drools by kiegroup.

the class LhsBuilder method addCellValue.

public void addCellValue(int row, int column, String value) {
    this.hasValues = true;
    Integer key = new Integer(column);
    String content = this.constraints.get(key);
    if (content == null) {
        throw new DecisionTableParseException("No code snippet for CONDITION in cell " + RuleSheetParserUtil.rc2name(this.headerRow + 2, this.headerCol));
    }
    SnippetBuilder snip = new SnippetBuilder(content);
    String result = snip.build(fixValue(column, value));
    this.values.add(result);
}
Also used : DecisionTableParseException(org.drools.template.parser.DecisionTableParseException) SnippetBuilder(org.drools.template.model.SnippetBuilder)

Example 5 with SnippetBuilder

use of org.drools.template.model.SnippetBuilder in project drools by kiegroup.

the class RhsBuilder method addCellValue.

public void addCellValue(int row, int column, String value) {
    hasValues = true;
    String template = (String) this.templates.get(new Integer(column));
    if (template == null) {
        throw new DecisionTableParseException("No code snippet for " + this.actionTypeCode + ", above cell " + RuleSheetParserUtil.rc2name(this.headerRow + 2, this.headerCol));
    }
    SnippetBuilder snip = new SnippetBuilder(template);
    this.values.add(snip.build(value));
}
Also used : DecisionTableParseException(org.drools.template.parser.DecisionTableParseException) SnippetBuilder(org.drools.template.model.SnippetBuilder)

Aggregations

SnippetBuilder (org.drools.template.model.SnippetBuilder)6 Condition (org.drools.template.model.Condition)3 DecisionTableParseException (org.drools.template.parser.DecisionTableParseException)2 Consequence (org.drools.template.model.Consequence)1