use of org.drools.workbench.models.datamodel.rule.InterpolationVariable in project drools-wb by kiegroup.
the class DefaultGuidedDecisionTableLinkManager method hasTemplateKeys.
private boolean hasTemplateKeys(final BRLActionColumn column) {
final Map<InterpolationVariable, Integer> ivs = new HashMap<>();
final RuleModel rm = new RuleModel();
column.getDefinition().forEach(rm::addRhsItem);
final RuleModelVisitor rmv = new RuleModelVisitor(ivs);
rmv.visit(rm);
return ivs.size() > 0;
}
use of org.drools.workbench.models.datamodel.rule.InterpolationVariable in project drools-wb by kiegroup.
the class AbstractDecoratedTemplateDataGridWidget method setupInternalModel.
private void setupInternalModel(TemplateModel model, List<DynamicColumn<TemplateDataColumn>> columns, DynamicData data) {
// Get interpolation variables
InterpolationVariable[] vars = model.getInterpolationVariablesList();
if (vars.length == 0) {
return;
}
int colIndex = 0;
String[][] modelData = model.getTableAsArray();
// to be enough rows to receive the columns data
for (int iRow = 0; iRow < modelData.length; iRow++) {
data.addRow();
}
// Add corresponding columns to table
for (InterpolationVariable var : vars) {
TemplateDataColumn col = new TemplateDataColumn(var.getVarName(), var.getDataType(), var.getFactType(), var.getFactField());
DynamicColumn<TemplateDataColumn> column = new DynamicColumn<TemplateDataColumn>(col, cellFactory.getCell(col), colIndex, eventBus);
columns.add(column);
data.addColumn(colIndex, makeColumnData(modelData, col, colIndex++), true);
}
}
use of org.drools.workbench.models.datamodel.rule.InterpolationVariable in project drools-wb by kiegroup.
the class TemplateDataCellValueFactory method makeUIRowData.
/**
* Construct a new row of data for the MergableGridWidget
*
* @return
*/
@Override
public DynamicDataRow makeUIRowData() {
DynamicDataRow data = new DynamicDataRow();
InterpolationVariable[] variables = model.getInterpolationVariablesList();
for (InterpolationVariable var : variables) {
TemplateDataColumn column = makeModelColumn(var);
String dcv = makeModelCellValue(column);
CellValue<? extends Comparable<?>> cell = convertModelCellValue(column, dcv);
data.add(cell);
}
return data;
}
use of org.drools.workbench.models.datamodel.rule.InterpolationVariable in project drools-wb by kiegroup.
the class TemplateDataTableWidget method onUpdateModel.
public void onUpdateModel(UpdateModelEvent event) {
// Copy data into the underlying model
Map<Coordinate, List<List<CellValue<? extends Comparable<?>>>>> updates = event.getUpdates();
for (Map.Entry<Coordinate, List<List<CellValue<? extends Comparable<?>>>>> e : updates.entrySet()) {
// Coordinate of change
Coordinate originCoordinate = e.getKey();
int originRowIndex = originCoordinate.getRow();
int originColumnIndex = originCoordinate.getCol();
// Changed data
List<List<CellValue<? extends Comparable<?>>>> data = e.getValue();
InterpolationVariable[] vars = model.getInterpolationVariablesList();
for (int iRow = 0; iRow < data.size(); iRow++) {
List<CellValue<? extends Comparable<?>>> rowData = data.get(iRow);
int targetRowIndex = originRowIndex + iRow;
for (int iCol = 0; iCol < rowData.size(); iCol++) {
int targetColumnIndex = originColumnIndex + iCol;
CellValue<? extends Comparable<?>> changedCell = rowData.get(iCol);
InterpolationVariable var = vars[targetColumnIndex];
TemplateDataColumn col = new TemplateDataColumn(var.getVarName(), var.getDataType(), var.getFactType(), var.getFactField());
String dcv = cellValueFactory.convertToModelCell(col, changedCell);
List<String> columnData = model.getTable().get(var.getVarName());
columnData.set(targetRowIndex, dcv);
}
}
}
}
use of org.drools.workbench.models.datamodel.rule.InterpolationVariable in project drools-wb by kiegroup.
the class TemplateDropDownManager method getDependentColumnIndexes.
@Override
public Set<Integer> getDependentColumnIndexes(final Context context) {
final int iBaseColIndex = context.getColumn();
final Set<Integer> dependentColumnIndexes = new HashSet<Integer>();
// Get variable for the column being edited
final InterpolationVariable[] allVariables = this.model.getInterpolationVariablesList();
final InterpolationVariable baseVariable = allVariables[iBaseColIndex];
final String baseVariableName = baseVariable.getVarName();
// Get other variables (and literals) in the same scope as the base variable
final RuleModelPeerVariableVisitor peerVariableVisitor = new RuleModelPeerVariableVisitor(model, baseVariableName);
List<RuleModelPeerVariableVisitor.ValueHolder> peerVariables = peerVariableVisitor.getPeerVariables();
// Add other variables values
for (RuleModelPeerVariableVisitor.ValueHolder valueHolder : peerVariables) {
switch(valueHolder.getType()) {
case TEMPLATE_KEY:
final int iCol = getVariableColumnIndex(valueHolder.getValue());
final InterpolationVariable variable = allVariables[iCol];
final String field = variable.getFactField();
if (oracle.isDependentEnum(baseVariable.getFactType(), baseVariable.getFactField(), field)) {
dependentColumnIndexes.add(iCol);
}
break;
}
}
return dependentColumnIndexes;
}
Aggregations