Search in sources :

Example 31 with BaseColumnFieldDiff

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

the class ModelSynchronizerImpl method updateColumn.

@Override
@SuppressWarnings("unchecked")
public List<BaseColumnFieldDiff> updateColumn(final BaseColumn originalColumn, final BaseColumn editedColumn) throws VetoException {
    final MetaData originalMetaData = new BaseColumnSynchronizer.ColumnMetaDataImpl(originalColumn);
    final MetaData editedMetaData = new BaseColumnSynchronizer.ColumnMetaDataImpl(editedColumn);
    for (Synchronizer synchronizer : synchronizers) {
        if (synchronizer.handlesUpdate(originalMetaData)) {
            final List<BaseColumnFieldDiff> diffs = synchronizer.update(originalMetaData, editedMetaData);
            final boolean isSalienceUseRowNumberUpdated = BaseColumnFieldDiffImpl.hasChanged(AttributeCol52.FIELD_USE_ROW_NUMBER, diffs);
            final boolean isSalienceUseReverseOrderUpdated = BaseColumnFieldDiffImpl.hasChanged(AttributeCol52.FIELD_REVERSE_ORDER, diffs);
            if (isSalienceUseRowNumberUpdated || isSalienceUseReverseOrderUpdated) {
                systemControlledColumnValuesSynchronizer.updateSystemControlledColumnValues();
            }
            return diffs;
        }
    }
    return Collections.emptyList();
}
Also used : Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) PatternConditionMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.PatternConditionMetaData) MoveRowToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveRowToMetaData) MetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.MetaData) MoveColumnToMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.MoveColumnToMetaData) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)

Example 32 with BaseColumnFieldDiff

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

the class ActionWorkItemSetFieldColumnSynchronizer 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 ActionWorkItemSetFieldCol52 originalColumn = (ActionWorkItemSetFieldCol52) originalMetaData.getColumn();
    final ActionWorkItemSetFieldCol52 editedColumn = (ActionWorkItemSetFieldCol52) 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(ActionWorkItemSetFieldCol52.FIELD_HIDE_COLUMN, diffs);
    final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemSetFieldCol52.FIELD_HEADER, diffs);
    if (isHideUpdated) {
        setColumnVisibility(originalColumn, originalColumn.isHideColumn());
    }
    if (isHeaderUpdated) {
        setColumnHeader(originalColumn, originalColumn.getHeader());
    }
    return diffs;
}
Also used : BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52)

Example 33 with BaseColumnFieldDiff

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

the class ConditionColumnSynchronizer method update.

@Override
public List<BaseColumnFieldDiff> update(final PatternConditionMetaData originalMetaData, final PatternConditionMetaData editedMetaData) throws VetoException {
    // Check operation is supported
    if (!(handlesUpdate(originalMetaData) && handlesUpdate(editedMetaData))) {
        return Collections.emptyList();
    }
    // Get differences between original and edited column
    final Pattern52 originalPattern = originalMetaData.getPattern();
    final Pattern52 editedPattern = editedMetaData.getPattern();
    final ConditionCol52 originalColumn = (ConditionCol52) originalMetaData.getColumn();
    final ConditionCol52 editedColumn = (ConditionCol52) editedMetaData.getColumn();
    final List<BaseColumnFieldDiff> patternDiffs = originalPattern.diff(editedPattern);
    final List<BaseColumnFieldDiff> columnDiffs = originalColumn.diff(editedColumn);
    final List<BaseColumnFieldDiff> diffs = new ArrayList<BaseColumnFieldDiff>();
    if (patternDiffs != null) {
        diffs.addAll(patternDiffs);
    }
    if (columnDiffs != null) {
        diffs.addAll(columnDiffs);
    }
    // Changes to the Pattern create the new column and remove the old column
    final boolean isNewPattern = isNewPattern(editedPattern);
    final boolean isBoundNameUpdated = BaseColumnFieldDiffImpl.hasChanged(Pattern52.FIELD_BOUND_NAME, diffs);
    final boolean isEntryPointNameUpdated = BaseColumnFieldDiffImpl.hasChanged(Pattern52.FIELD_ENTRY_POINT_NAME, diffs);
    final boolean isUpdatedCondition = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_BINDING, diffs);
    // Check if pattern change can be applied to model
    if (isUpdatedCondition) {
        if (!isPotentialConditionDeletionSafe(originalColumn)) {
            throw new VetoUpdatePatternInUseException();
        }
    }
    if (isBoundNameUpdated) {
        if (!isPotentialPatternDeletionSafe(originalPattern)) {
            throw new VetoUpdatePatternInUseException();
        }
    }
    // Perform update
    if (isNewPattern || isBoundNameUpdated) {
        append(editedMetaData);
        copyColumnData(originalColumn, editedColumn, diffs);
        delete(originalMetaData);
        return diffs;
    }
    if (isEntryPointNameUpdated) {
        originalPattern.setEntryPointName(editedPattern.getEntryPointName());
    }
    // Changes to the Condition, but Pattern remains unchanged
    update(originalColumn, editedColumn);
    final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_HIDE_COLUMN, diffs);
    final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_HEADER, diffs);
    final boolean isFactTypeUpdated = BaseColumnFieldDiffImpl.hasChanged(Pattern52.FIELD_FACT_TYPE, diffs);
    final boolean isFactFieldUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_FACT_FIELD, diffs);
    final boolean isFieldTypeUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_FIELD_TYPE, diffs);
    final boolean isConstraintValueTypeUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_CONSTRAINT_VALUE_TYPE, diffs);
    if (isFactTypeUpdated || isFactFieldUpdated || isFieldTypeUpdated || isConstraintValueTypeUpdated) {
        clearColumnData(originalColumn);
    } else {
        cleanColumnData(originalColumn, editedColumn, diffs);
    }
    synchroniseUpdateColumn(originalColumn);
    if (isHideUpdated) {
        setColumnVisibility(originalColumn, originalColumn.isHideColumn());
    }
    if (isHeaderUpdated) {
        setColumnHeader(originalColumn, originalColumn.getHeader());
    }
    return diffs;
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) ArrayList(java.util.ArrayList) VetoUpdatePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoUpdatePatternInUseException)

Example 34 with BaseColumnFieldDiff

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

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

Example 35 with BaseColumnFieldDiff

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

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

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