use of org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn in project drools-wb by kiegroup.
the class GuidedDecisionTableRHSBuilder method getVariableColumns.
@Override
public List<BRLVariableColumn> getVariableColumns() {
// Sort column builders by column index to ensure columns are added in the correct sequence
final Set<Integer> sortedIndexes = new TreeSet<Integer>(this.valueBuilders.keySet());
final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
for (Integer index : sortedIndexes) {
final ParameterizedValueBuilder vb = this.valueBuilders.get(index);
final List<BRLVariableColumn> vbVariableColumns = addColumn(vb);
for (BRLVariableColumn vbVariableColumn : vbVariableColumns) {
((BRLActionVariableColumn) vbVariableColumn).setHeader(this.columnHeaders.get(index));
}
variableColumns.addAll(vbVariableColumns);
}
return variableColumns;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn in project drools-wb by kiegroup.
the class GuidedDecisionTablePopulater method createRHSChildColumns.
private void createRHSChildColumns(final RuleModel rm, final IAction action, final BRLActionColumn column, final List<BRLVariableColumn> variableColumns) {
final Map<InterpolationVariable, Integer> templateKeys = new HashMap<>();
final RuleModelVisitor rmv = new RuleModelVisitor(rm.lhs, templateKeys);
rmv.visit(action);
final List<InterpolationVariable> ivs = new ArrayList<>(templateKeys.keySet());
for (BRLVariableColumn variableColumn : variableColumns) {
final Iterator<InterpolationVariable> ivsIts = ivs.iterator();
while (ivsIts.hasNext()) {
final InterpolationVariable iv = ivsIts.next();
if (iv.getVarName().equals(variableColumn.getVarName())) {
final BRLActionVariableColumn source = (BRLActionVariableColumn) variableColumn;
final BRLActionVariableColumn target = makeBRLActionVariableColumn(source, iv);
column.getChildColumns().add(target);
ivsIts.remove();
}
}
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn in project drools-wb by kiegroup.
the class GuidedDecisionTablePopulater method addIndirectSourceBuildersData.
private void addIndirectSourceBuildersData(final int maxRowCount) {
final List<ParameterizedValueBuilder> valueBuilders = getOrderedValueBuilders();
final List<BaseColumn> allColumns = dtable.getExpandedColumns();
for (int iColIndex = 0; iColIndex < allColumns.size(); iColIndex++) {
final BaseColumn column = allColumns.get(iColIndex);
if (column instanceof BRLVariableColumn) {
final String varName = ((BRLVariableColumn) column).getVarName();
final String varDataType = ((BRLVariableColumn) column).getFieldType();
assertDecisionTableData(varName, varDataType, valueBuilders, maxRowCount);
}
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn in project drools-wb by kiegroup.
the class GuidedDecisionTableLHSBuilder method addPatternColumn.
// A Pattern column adds constraints to a Pattern. It has a value in the OBJECT row
private List<BRLVariableColumn> addPatternColumn() {
// Sort column builders by column index to ensure columns are added in the correct sequence
final TreeSet<Integer> sortedIndexes = new TreeSet<Integer>(this.valueBuilders.keySet());
final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
// DRL prefix
final StringBuffer drl = new StringBuffer();
drl.append(this.colDefPrefix);
String sep = "";
// DRL fragment
for (Integer index : sortedIndexes) {
final ParameterizedValueBuilder vb = this.valueBuilders.get(index);
for (String parameter : vb.getParameters()) {
final BRLConditionVariableColumn parameterColumn = new BRLConditionVariableColumn(parameter, DataType.TYPE_OBJECT);
parameterColumn.setHeader(this.columnHeaders.get(index));
variableColumns.add(parameterColumn);
}
drl.append(sep).append(vb.getTemplate());
sep = this.andop;
}
// DRL suffix
drl.append(this.colDefSuffix);
// Store DRL fragment for use by GuidedDecisionTableRHSBuilder
drlFragments.add(drl.toString());
return variableColumns;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn in project drools-wb by kiegroup.
the class GuidedDecisionTableLHSBuilder method addExplicitColumns.
// An explicit column does not add constraints to a Pattern. It does not have a value in the OBJECT row
private List<BRLVariableColumn> addExplicitColumns() {
// Sort column builders by column index to ensure Actions are added in the correct sequence
final Set<Integer> sortedIndexes = new TreeSet<Integer>(this.valueBuilders.keySet());
final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
for (Integer index : sortedIndexes) {
final ParameterizedValueBuilder vb = this.valueBuilders.get(index);
final List<BRLVariableColumn> vbVariableColumns = new ArrayList<BRLVariableColumn>();
if (vb instanceof LiteralValueBuilder) {
vbVariableColumns.addAll(addLiteralColumn((LiteralValueBuilder) vb));
for (BRLVariableColumn vbVariableColumn : vbVariableColumns) {
((BRLConditionVariableColumn) vbVariableColumn).setHeader(this.columnHeaders.get(index));
}
} else {
vbVariableColumns.addAll(addBRLFragmentColumn(vb));
for (BRLVariableColumn vbVariableColumn : vbVariableColumns) {
((BRLConditionVariableColumn) vbVariableColumn).setHeader(this.columnHeaders.get(index));
}
}
variableColumns.addAll(vbVariableColumns);
}
return variableColumns;
}
Aggregations