Search in sources :

Example 56 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class RowSynchronizer method append.

@Override
public void append(final RowMetaData metaData) throws VetoException {
    if (!handlesAppend(metaData)) {
        return;
    }
    final List<DTCellValue52> modelRow = new ArrayList<DTCellValue52>();
    model.getData().add(modelRow);
    final GridRow uiModelRow = new BaseGridRow(GuidedDecisionTableView.ROW_HEIGHT);
    uiModel.appendRow(uiModelRow);
    final int rowIndex = uiModel.getRowCount() - 1;
    initialiseRowData(rowIndex);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) ArrayList(java.util.ArrayList) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 57 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class SystemControlledColumnValuesSynchronizer method updateRowNumberColumnValues.

/**
 * Update Row Number column values
 */
private void updateRowNumberColumnValues(final RowNumberCol52 modelColumn, final PostSyncOperation postSyncOperation) {
    final PrioritySynchronizer.RowNumberChanges rowNumberChanges = new PrioritySynchronizer.RowNumberChanges();
    final int iModelColumn = model.getExpandedColumns().indexOf(modelColumn);
    for (int rowNumber = 0; rowNumber < model.getData().size(); rowNumber++) {
        final List<DTCellValue52> modelRow = model.getData().get(rowNumber);
        final DTCellValue52 modelCell = modelRow.get(iModelColumn);
        final int oldRowNumber = (Integer) modelCell.getNumericValue();
        final int newRowNumber = rowNumber + 1;
        rowNumberChanges.put(oldRowNumber, newRowNumber);
        modelCell.setNumericValue(newRowNumber);
        uiModel.setCellValueInternal(rowNumber, iModelColumn, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
    }
    postSyncOperation.execute(iModelColumn, rowNumberChanges);
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 58 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class GuidedDecisionTablePopulater method createActionRetractFactChildColumns.

private void createActionRetractFactChildColumns(final ActionRetractFact arf, final BRLActionColumn column, final List<BRLVariableColumn> variableColumns) {
    // Check whether the ActionRetractFact column has been defined as a parameter in the XLS.
    // This is unsupported in the Guided Rule Editor (Guided Decision Table Editor BRLFragments)
    // and hence the source column needs to be updated to reflect what is supported.
    final String var = arf.getVariableName();
    final Set<String> templateKeys = parameterUtilities.extractTemplateKeys(var);
    final String templateKey = templateKeys.isEmpty() ? var : templateKeys.iterator().next();
    final List<ParameterizedValueBuilder> valueBuilders = getOrderedValueBuilders();
    for (BRLVariableColumn variableColumn : variableColumns) {
        if (templateKey.equals(variableColumn.getVarName())) {
            final BRLActionVariableColumn source = (BRLActionVariableColumn) variableColumn;
            final BRLActionVariableColumn target = new BRLActionVariableColumn(templateKey, DataType.TYPE_BOOLEAN);
            target.setHeader(source.getHeader());
            target.setHideColumn(source.isHideColumn());
            column.getChildColumns().add(target);
            for (GuidedDecisionTableSourceBuilder sb : sourceBuilders) {
                if (sb instanceof GuidedDecisionTableRHSBuilder) {
                    final GuidedDecisionTableRHSBuilder rhs = (GuidedDecisionTableRHSBuilder) sb;
                    for (ParameterizedValueBuilder pvb : rhs.getValueBuilders().values()) {
                        if (pvb.getParameters().contains(templateKey)) {
                            Optional<String> firstBinding = Optional.empty();
                            final int pvbIndex = pvb.getParameters().indexOf(templateKey);
                            final List<List<DTCellValue52>> pvbData = pvb.getColumnData();
                            for (int iRowIndex = 0; iRowIndex < pvbData.size(); iRowIndex++) {
                                final List<DTCellValue52> pvbRow = pvbData.get(iRowIndex);
                                final String binding = pvbRow.get(pvbIndex).getStringValue();
                                if (!(binding == null || binding.isEmpty())) {
                                    if (!arf.getVariableName().equals(binding)) {
                                        final int _rowIndex = ruleRowStartIndex + iRowIndex + 1;
                                        final int _columnIndex = ruleColumnStartIndex + valueBuilders.indexOf(pvb) + 1;
                                        if (firstBinding.isPresent()) {
                                            addConversionMessage("Removing Retract binding for " + binding + ". See previous conversion messages for details.", _rowIndex, _columnIndex);
                                            pvbRow.get(pvbIndex).clearValues();
                                        } else {
                                            addConversionMessage("Setting Retract to use first binding, " + binding + ". Others will be removed.", _rowIndex, _columnIndex);
                                            arf.setVariableName(binding);
                                            pvbRow.get(pvbIndex).setBooleanValue(true);
                                            firstBinding = Optional.of(binding);
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
            break;
        }
    }
}
Also used : GuidedDecisionTableRHSBuilder(org.drools.workbench.screens.dtablexls.backend.server.conversion.builders.GuidedDecisionTableRHSBuilder) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) ParameterizedValueBuilder(org.drools.workbench.screens.dtablexls.backend.server.conversion.builders.ParameterizedValueBuilder) GuidedDecisionTableSourceBuilder(org.drools.workbench.screens.dtablexls.backend.server.conversion.builders.GuidedDecisionTableSourceBuilder) BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) ArrayList(java.util.ArrayList) List(java.util.List) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 59 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class GuidedDecisionTableActivationGroupBuilder method populateDecisionTable.

@Override
public void populateDecisionTable(final GuidedDecisionTable52 dtable, final int maxRowCount) {
    final AttributeCol52 column = new AttributeCol52();
    column.setAttribute(GuidedDecisionTable52.ACTIVATION_GROUP_ATTR);
    dtable.getAttributeCols().add(column);
    if (this.values.size() < maxRowCount) {
        for (int iRow = this.values.size(); iRow < maxRowCount; iRow++) {
            this.values.add(new DTCellValue52(""));
        }
    }
    addColumnData(dtable, column);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 60 with DTCellValue52

use of org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52 in project drools-wb by kiegroup.

the class GuidedDecisionTableAgendaGroupBuilder method populateDecisionTable.

@Override
public void populateDecisionTable(final GuidedDecisionTable52 dtable, final int maxRowCount) {
    final AttributeCol52 column = new AttributeCol52();
    column.setAttribute(GuidedDecisionTable52.AGENDA_GROUP_ATTR);
    dtable.getAttributeCols().add(column);
    if (this.values.size() < maxRowCount) {
        for (int iRow = this.values.size(); iRow < maxRowCount; iRow++) {
            this.values.add(new DTCellValue52(""));
        }
    }
    addColumnData(dtable, column);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Aggregations

DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)244 Test (org.junit.Test)121 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)53 ArrayList (java.util.ArrayList)51 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)46 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)46 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)39 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)39 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)30 List (java.util.List)29 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)28 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)27 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)25 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)24 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)23 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)21 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)20 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)20 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)20 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)20