Search in sources :

Example 1 with RuleAttribute

use of org.drools.verifier.core.index.model.RuleAttribute in project drools-wb by kiegroup.

the class RuleBuilder method resolveColumns.

private void resolveColumns() throws BuildException {
    int columnIndex = 0;
    List<BaseColumn> expandedColumns = model.getExpandedColumns();
    for (final BaseColumn baseColumn : expandedColumns) {
        try {
            if (baseColumn instanceof AttributeCol52) {
                final String attribute = ((AttributeCol52) baseColumn).getAttribute();
                final DTCellValue52 realCellValue = getRealCellValue((AttributeCol52) baseColumn, row.get(columnIndex));
                final Optional<RuleAttribute> ruleAttribute = AttributeBuilder.build(columnIndex, configuration, attribute, realCellValue);
                if (ruleAttribute.isPresent()) {
                    rule.addRuleAttribute(ruleAttribute.get());
                }
            } else if (baseColumn instanceof ConditionCol52) {
                final Condition condition = builderFactory.getConditionBuilder().with((ConditionCol52) baseColumn).with(rule).with(row).with(columnIndex).build();
                rule.getConditions().add(condition);
            } else if (baseColumn instanceof ActionCol52) {
                final Action action = builderFactory.getActionBuilder().with(rule).with((ActionCol52) baseColumn).with(row).with(columnIndex).build();
                rule.getActions().add(action);
            }
            columnIndex++;
        } catch (BuildException e) {
            throw e;
        } catch (Exception e) {
            throw new BuildException("Could not resolve column: Index: " + columnIndex + " header: " + baseColumn.getHeader() + " error message: " + e.getMessage());
        }
    }
}
Also used : Condition(org.drools.verifier.core.index.model.Condition) Action(org.drools.verifier.core.index.model.Action) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) RuleAttribute(org.drools.verifier.core.index.model.RuleAttribute) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Aggregations

Action (org.drools.verifier.core.index.model.Action)1 Condition (org.drools.verifier.core.index.model.Condition)1 RuleAttribute (org.drools.verifier.core.index.model.RuleAttribute)1 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)1 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)1