use of org.drools.workbench.models.datamodel.rule.visitors.RuleModelVisitor in project drools by kiegroup.
the class GuidedDTDRLPersistence method doCondition.
private void doCondition(List<BaseColumn> allColumns, BRLConditionColumn column, List<IPattern> patterns, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) {
// Check whether the parameter-less BRL fragment needs inclusion
if (!hasVariables(column)) {
final BRLConditionVariableColumn variableColumn = column.getChildColumns().get(0);
final int index = allColumns.indexOf(variableColumn);
final DTCellValue52 dcv = row.get(index);
if (dcv != null && dcv.getBooleanValue()) {
for (IPattern pattern : column.getDefinition()) {
patterns.add(pattern);
}
}
} else {
for (IPattern pattern : column.getDefinition()) {
boolean addPattern = false;
// Get interpolation variables used by the Pattern
Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>();
RuleModelVisitor rmv = new RuleModelVisitor(pattern, ivs);
rmv.visit(pattern);
if (ivs.size() == 0) {
addPattern = true;
} else if (ivs.size() > 0) {
int templateKeyCount = 0;
for (InterpolationVariable variable : ivs.keySet()) {
String value = rowDataProvider.getTemplateKeyValue(variable.getVarName());
if (!"".equals(value)) {
templateKeyCount++;
}
}
// Ensure at least one key has a value (FreeFormLines need all values to be provided)
if (pattern instanceof FreeFormLine) {
addPattern = templateKeyCount == ivs.size();
} else if (templateKeyCount > 0) {
addPattern = true;
}
}
if (addPattern) {
patterns.add(pattern);
}
}
}
}
use of org.drools.workbench.models.datamodel.rule.visitors.RuleModelVisitor in project drools by kiegroup.
the class GuidedDTDRLPersistence method hasVariables.
private boolean hasVariables(BRLConditionColumn column) {
Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>();
RuleModel rm = new RuleModel();
for (IPattern pattern : column.getDefinition()) {
rm.addLhsItem(pattern);
}
RuleModelVisitor rmv = new RuleModelVisitor(ivs);
rmv.visit(rm);
return ivs.size() > 0;
}
use of org.drools.workbench.models.datamodel.rule.visitors.RuleModelVisitor in project drools by kiegroup.
the class TemplateModel method getInterpolationVariables.
private Map<InterpolationVariable, Integer> getInterpolationVariables() {
Map<InterpolationVariable, Integer> result = new HashMap<InterpolationVariable, Integer>();
new RuleModelVisitor(result).visit(this);
InterpolationVariable id = new InterpolationVariable(ID_COLUMN_NAME, DataType.TYPE_NUMERIC_LONG);
result.put(id, result.size());
return result;
}
use of org.drools.workbench.models.datamodel.rule.visitors.RuleModelVisitor in project drools-wb by kiegroup.
the class BRLActionColumnPlugin method getDefinedVariables.
boolean getDefinedVariables(RuleModel ruleModel) {
Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>();
RuleModelVisitor rmv = new RuleModelVisitor(ivs);
rmv.visit(ruleModel);
// Update column and UI
editingCol.setChildColumns(convertInterpolationVariables(ivs));
return ivs.size() > 0;
}
use of org.drools.workbench.models.datamodel.rule.visitors.RuleModelVisitor in project drools-wb by kiegroup.
the class BRLConditionColumnPlugin method getDefinedVariables.
boolean getDefinedVariables(RuleModel ruleModel) {
Map<InterpolationVariable, Integer> ivs = new HashMap<InterpolationVariable, Integer>();
RuleModelVisitor rmv = new RuleModelVisitor(ivs);
rmv.visit(ruleModel);
// Update column and UI
editingCol.setChildColumns(convertInterpolationVariables(ivs));
return ivs.size() > 0;
}
Aggregations