Search in sources :

Example 36 with BaseColumnFieldDiff

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

the class MetaDataColumnSynchronizer method update.

@Override
public List<BaseColumnFieldDiff> update(final BaseColumnSynchronizer.ColumnMetaData originalMetaData, final BaseColumnSynchronizer.ColumnMetaData editedMetaData) throws VetoException {
    // Check operation is supported
    if (!(handlesUpdate(originalMetaData) && handlesUpdate(editedMetaData))) {
        return Collections.emptyList();
    }
    final MetadataCol52 originalColumn = (MetadataCol52) originalMetaData.getColumn();
    final MetadataCol52 editedColumn = (MetadataCol52) editedMetaData.getColumn();
    final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
    update(originalColumn, editedColumn);
    final boolean isMetaDataUpdated = BaseColumnFieldDiffImpl.hasChanged(MetadataCol52.FIELD_METADATA, diffs);
    final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(DTColumnConfig52.FIELD_HIDE_COLUMN, diffs);
    if (isMetaDataUpdated) {
        setColumnHeader(originalColumn, originalColumn.getMetadata());
    }
    if (isHideUpdated) {
        setColumnVisibility(originalColumn, originalColumn.isHideColumn());
    }
    return diffs;
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)

Example 37 with BaseColumnFieldDiff

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

the class ActionRetractFactColumnSynchronizer 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();
    }
    // Get differences between original and edited column
    final ActionRetractFactCol52 originalColumn = (ActionRetractFactCol52) originalMetaData.getColumn();
    final ActionRetractFactCol52 editedColumn = (ActionRetractFactCol52) editedMetaData.getColumn();
    final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
    update(originalColumn, editedColumn);
    final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionRetractFactCol52.FIELD_HIDE_COLUMN, diffs);
    final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionRetractFactCol52.FIELD_HEADER, diffs);
    synchroniseUpdateColumn(originalColumn);
    if (isHideUpdated) {
        setColumnVisibility(originalColumn, originalColumn.isHideColumn());
    }
    if (isHeaderUpdated) {
        setColumnHeader(originalColumn, originalColumn.getHeader());
    }
    return diffs;
}
Also used : ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)

Example 38 with BaseColumnFieldDiff

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

the class ActionWorkItemExecuteColumnSynchronizer 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();
    }
    // Get differences between original and edited column
    final ActionWorkItemCol52 originalColumn = (ActionWorkItemCol52) originalMetaData.getColumn();
    final ActionWorkItemCol52 editedColumn = (ActionWorkItemCol52) editedMetaData.getColumn();
    final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
    update(originalColumn, editedColumn);
    // ActionWorkItem columns are always represented with a BooleanUiColumn
    final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemCol52.FIELD_HIDE_COLUMN, diffs);
    final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemCol52.FIELD_HEADER, diffs);
    if (isHideUpdated) {
        setColumnVisibility(originalColumn, originalColumn.isHideColumn());
    }
    if (isHeaderUpdated) {
        setColumnHeader(originalColumn, originalColumn.getHeader());
    }
    return diffs;
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)

Example 39 with BaseColumnFieldDiff

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

the class BRLConditionColumnSynchronizerTest method testUpdate3.

@Test
public void testUpdate3() throws VetoException {
    // Single Column, multiple variables
    final BRLConditionColumn column = spy(new BRLConditionColumn());
    final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    final BRLConditionVariableColumn columnV1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column.getChildColumns().add(columnV0);
    column.getChildColumns().add(columnV1);
    column.setHeader("col1");
    columnV0.setHeader("col1v0");
    columnV1.setHeader("col1v1");
    modelSynchronizer.appendColumn(column);
    assertEquals(5, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(5, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof IntegerUiColumn);
    assertTrue(uiModel.getColumns().get(4) instanceof StringUiColumn);
    assertEquals("$age", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
    final BRLConditionColumn edited = new BRLConditionColumn();
    final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$s", DataType.TYPE_NUMERIC_LONG, "Applicant", "salary");
    edited.getChildColumns().add(editedColumnV0);
    edited.setHideColumn(true);
    edited.setHeader("updated");
    editedColumnV0.setHeader("updated");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
    assertEquals(6, // header, hide, field name, field type, binding, removed column
    diffs.size());
    verify(column).diff(edited);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof LongUiColumn);
    assertEquals("updated", uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
    assertEquals(false, uiModel.getColumns().get(3).isVisible());
    assertEquals("$s", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) LongUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.LongUiColumn) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Example 40 with BaseColumnFieldDiff

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

the class ActionWorkItemExecuteColumnSynchronizerTest method testUpdate.

@Test
public void testUpdate() throws VetoException {
    final ActionWorkItemCol52 column = spy(new ActionWorkItemCol52());
    column.setHeader("col1");
    modelSynchronizer.appendColumn(column);
    final ActionWorkItemCol52 edited = new ActionWorkItemCol52();
    edited.setWidth(column.getWidth());
    edited.setHideColumn(true);
    edited.setHeader("updated");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
    assertEquals(2, diffs.size());
    verify(column).diff(edited);
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof BooleanUiColumn);
    assertEquals("updated", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
    assertEquals(false, uiModel.getColumns().get(3).isVisible());
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Aggregations

BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)66 Test (org.junit.Test)39 UpdateColumnAuditLogEntry (org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry)15 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)14 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)13 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)12 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)12 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)12 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)10 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)8 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)6 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)6 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)4 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)4 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)4 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)4 ArrayList (java.util.ArrayList)3 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)3 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)3 ActionWorkItemInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52)3