Search in sources :

Example 81 with DTCellValue52

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

the class SalienceSynchronizer method setSalienceByRowNumbers.

private void setSalienceByRowNumbers(final AttributeCol52 modelColumn, final int iModelColumn) {
    // If Salience values are reverse order derive them and update column
    int salience = (modelColumn.isReverseOrder() ? model.getData().size() : 1);
    for (int rowNumber = 0; rowNumber < model.getData().size(); rowNumber++) {
        final List<DTCellValue52> modelRow = model.getData().get(rowNumber);
        final DTCellValue52 modelCell = modelRow.get(iModelColumn);
        modelCell.setNumericValue(salience);
        uiModel.setCellValueInternal(rowNumber, iModelColumn, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
        if (modelColumn.isReverseOrder()) {
            salience--;
        } else {
            salience++;
        }
    }
    uiModel.indexColumn(iModelColumn);
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 82 with DTCellValue52

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

the class BRLActionColumnDefinitionBuilder method makeRowData.

private List<DTCellValue52> makeRowData(final ColumnUtilities columnUtilities, final BRLActionColumn brlColumn) {
    final List<DTCellValue52> row = new ArrayList<>();
    row.add(new DTCellValue52(1));
    row.add(new DTCellValue52("desc"));
    for (BRLActionVariableColumn brlVariableColumn : brlColumn.getChildColumns()) {
        final DataType.DataTypes dataType = columnUtilities.getDataType(brlVariableColumn);
        row.add(makeCell(dataType));
    }
    return row;
}
Also used : ArrayList(java.util.ArrayList) DataType(org.kie.soup.project.datamodel.oracle.DataType) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 83 with DTCellValue52

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

the class BRLActionColumnSynchronizer method update.

@Override
public List<BaseColumnFieldDiff> update(final ColumnMetaData originalMetaData, final ColumnMetaData editedMetaData) throws VetoException {
    // Check operation is supported
    if (!(handlesUpdate(originalMetaData) && handlesUpdate(editedMetaData))) {
        return Collections.emptyList();
    }
    final BRLActionColumn originalColumn = (BRLActionColumn) originalMetaData.getColumn();
    final BRLActionColumn editedColumn = (BRLActionColumn) editedMetaData.getColumn();
    final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
    // Copy existing data for re-use if applicable
    final Map<String, List<DTCellValue52>> originalColumnsData = new HashMap<String, List<DTCellValue52>>();
    for (BRLActionVariableColumn variable : originalColumn.getChildColumns()) {
        int iColumnIndex = model.getExpandedColumns().indexOf(variable);
        final List<DTCellValue52> originalColumnData = new ArrayList<DTCellValue52>();
        final String key = makeUpdateBRLActionColumnKey(variable);
        for (List<DTCellValue52> row : model.getData()) {
            originalColumnData.add(row.get(iColumnIndex));
        }
        originalColumnsData.put(key, originalColumnData);
    }
    // Insert new columns setting data from that above, if applicable. Column visibility is handled here too.
    model.getActionCols().add(model.getActionCols().indexOf(originalColumn), editedColumn);
    for (BRLActionVariableColumn childModelColumn : editedColumn.getChildColumns()) {
        final String key = makeUpdateBRLActionColumnKey(childModelColumn);
        if (originalColumnsData.containsKey(key)) {
            final List<DTCellValue52> originalColumnData = originalColumnsData.get(key);
            synchroniseAppendColumn(childModelColumn, originalColumnData);
        } else {
            synchroniseAppendColumn(childModelColumn);
        }
    }
    // Delete columns for the original definition
    delete(originalMetaData);
    return diffs;
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) HashMap(java.util.HashMap) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 84 with DTCellValue52

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

the class DTCellValueWidgetFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    ApplicationPreferences.setUp(new HashMap<String, String>() {

        {
            put(ApplicationPreferences.DATE_FORMAT, "dd-MM-yyyy");
        }
    });
    when(model.getTableFormat()).thenReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    factory = DTCellValueWidgetFactory.getInstance(model, oracle, false, false);
    insertFactCol52 = new ActionInsertFactCol52();
    cellValue = new DTCellValue52();
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Before(org.junit.Before)

Example 85 with DTCellValue52

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

the class AuditLogEntryCellHelperTest method getSafeHtml_ActionRetract.

@Test
public void getSafeHtml_ActionRetract() {
    ActionRetractFactCol52 originalColumn = new ActionRetractFactCol52();
    originalColumn.setHeader("action1");
    originalColumn.setHideColumn(false);
    originalColumn.setDefaultValue(new DTCellValue52("def1"));
    ActionRetractFactCol52 newColumn = new ActionRetractFactCol52();
    newColumn.setHeader("action2");
    newColumn.setHideColumn(true);
    newColumn.setDefaultValue(new DTCellValue52("def2"));
    List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
    SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
    assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
Also used : ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) UpdateColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

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