Search in sources :

Example 6 with BaseColumnFieldDiff

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

the class ConditionColumnSynchronizerTest method testUpdate6.

@Test
public void testUpdate6() throws VetoException {
    // Single Pattern, single Condition
    final Pattern52 pattern = spy(boundApplicantPattern("$a"));
    final ConditionCol52 condition = spy(ageEqualsCondition());
    modelSynchronizer.appendColumn(pattern, condition);
    final Pattern52 editedPattern = boundApplicantPattern("$a");
    final ConditionCol52 editedCondition = ageEqualsCondition();
    editedCondition.setWidth(condition.getWidth());
    editedCondition.setOperator("!=");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern, condition, editedPattern, editedCondition);
    assertEquals(1, diffs.size());
    verify(pattern).diff(editedPattern);
    verify(condition).diff(editedCondition);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertEquals(1, model.getConditionPattern("$a").getChildColumns().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof IntegerUiColumn);
    assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
    assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
}
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) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 7 with BaseColumnFieldDiff

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

the class ConditionColumnSynchronizerTest method testUpdate4.

@Test
public void testUpdate4() throws VetoException {
    // Multiple Patterns, multiple Conditions
    final Pattern52 pattern1 = spy(boundApplicantPattern("$a"));
    final ConditionCol52 condition1 = spy(ageEqualsCondition());
    modelSynchronizer.appendColumn(pattern1, condition1);
    final Pattern52 editedPattern = boundAddressPattern("$d");
    final ConditionCol52 editedCondition = new ConditionCol52();
    editedCondition.setWidth(condition1.getWidth());
    editedCondition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    editedCondition.setHeader("col1");
    editedCondition.setFactField("country");
    editedCondition.setOperator("==");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(pattern1, condition1, editedPattern, editedCondition);
    assertEquals(3, diffs.size());
    verify(pattern1).diff(editedPattern);
    verify(condition1).diff(editedCondition);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getConditions().size());
    assertNull(model.getConditionPattern("$a"));
    assertEquals(1, model.getConditionPattern("$d").getChildColumns().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
    assertEquals(editedPattern.getBoundName() + " : " + editedPattern.getFactType(), uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
    assertEquals(editedCondition.getHeader(), uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Example 8 with BaseColumnFieldDiff

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

the class AuditLogEntryCellHelper method buildColumnDetailsUpdate.

private void buildColumnDetailsUpdate(final LimitedEntryActionSetFieldColumnDetails details, final LimitedEntryActionSetFieldColumnDetails originalDetails, final List<BaseColumnFieldDiff> diffs, final SafeHtmlBuilder sb) {
    sb.append(TEMPLATE.commentHeader(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogUpdateAction(details.getColumnHeader())));
    SafeHtmlBuilder sbFields = null;
    // Show changed fields too.
    if (diffs != null && !diffs.isEmpty()) {
        sbFields = new SafeHtmlBuilder();
        for (BaseColumnFieldDiff diff : diffs) {
            String changedFieldName = diff.getFieldName();
            // if (changedFieldName.equals(ActionInsertFactCol52.FIELD_TYPE)) buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Binding(), diff.getOldValue(), diff.getValue(), sb);
            if (changedFieldName.equals(DTColumnConfig52.FIELD_HEADER)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.ColumnHeader(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(LimitedEntryActionSetFieldCol52.FIELD_VALUE)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Value(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionInsertFactCol52.FIELD_BOUND_NAME)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Binding(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionInsertFactCol52.FIELD_FACT_FIELD)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Field(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionInsertFactCol52.FIELD_IS_INSERT_LOGICAL)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.LogicallyInsert(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionInsertFactCol52.FIELD_VALUE_LIST)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.ValueList(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(DTColumnConfig52.FIELD_DEFAULT_VALUE)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.DefaultValue(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(DTColumnConfig52.FIELD_HIDE_COLUMN)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.HideThisColumn(), diff.getOldValue(), diff.getValue(), sbFields);
            }
        }
    }
    if (sbFields != null) {
        sb.append(TEMPLATE.updatedFields(sbFields.toSafeHtml(), labelClass));
    }
}
Also used : BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 9 with BaseColumnFieldDiff

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

the class AuditLogEntryCellHelper method buildColumnDetailsUpdate.

private void buildColumnDetailsUpdate(final MetadataColumnDetails details, final MetadataColumnDetails originalDetails, final List<BaseColumnFieldDiff> diffs, final SafeHtmlBuilder sb) {
    sb.append(TEMPLATE.commentHeader(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogUpdateColumn(details.getColumnHeader())));
    SafeHtmlBuilder sbFields = null;
    // Show changed fields too.
    if (diffs != null && !diffs.isEmpty()) {
        sbFields = new SafeHtmlBuilder();
        for (BaseColumnFieldDiff diff : diffs) {
            String changedFieldName = diff.getFieldName();
            if (changedFieldName.equals(DTColumnConfig52.FIELD_DEFAULT_VALUE)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.DefaultValue(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(MetadataCol52.FIELD_METADATA)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Metadata1(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(DTColumnConfig52.FIELD_HEADER)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.ColumnHeader(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(DTColumnConfig52.FIELD_HIDE_COLUMN)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.HideThisColumn(), diff.getOldValue(), diff.getValue(), sbFields);
            }
        }
    }
    if (sbFields != null) {
        sb.append(TEMPLATE.updatedFields(sbFields.toSafeHtml(), labelClass));
    }
}
Also used : BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 10 with BaseColumnFieldDiff

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

the class AuditLogEntryCellHelper method buildColumnDetailsUpdate.

private void buildColumnDetailsUpdate(final ActionSetFieldColumnDetails details, final ActionSetFieldColumnDetails originalDetails, final List<BaseColumnFieldDiff> diffs, final SafeHtmlBuilder sb) {
    sb.append(TEMPLATE.commentHeader(GuidedDecisionTableConstants.INSTANCE.DecisionTableAuditLogUpdateAction(details.getColumnHeader())));
    SafeHtmlBuilder sbFields = null;
    // Show changed fields too.
    if (diffs != null && !diffs.isEmpty()) {
        sbFields = new SafeHtmlBuilder();
        for (BaseColumnFieldDiff diff : diffs) {
            String changedFieldName = diff.getFieldName();
            // if (changedFieldName.equals(ActionInsertFactCol52.FIELD_TYPE)) buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Binding(), diff.getOldValue(), diff.getValue(), sb);
            if (changedFieldName.equals(DTColumnConfig52.FIELD_HEADER)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.ColumnHeader(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionSetFieldCol52.FIELD_BOUND_NAME)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Binding(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionSetFieldCol52.FIELD_FACT_FIELD)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.Field(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionInsertFactCol52.FIELD_IS_INSERT_LOGICAL)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.LogicallyInsert(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionSetFieldCol52.FIELD_VALUE_LIST)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.ValueList(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(DTColumnConfig52.FIELD_DEFAULT_VALUE)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.DefaultValue(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(DTColumnConfig52.FIELD_HIDE_COLUMN)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.HideThisColumn(), diff.getOldValue(), diff.getValue(), sbFields);
            } else if (changedFieldName.equals(ActionSetFieldCol52.FIELD_UPDATE)) {
                buildColumnUpdateFields(GuidedDecisionTableConstants.INSTANCE.UpdateEngineWithChanges(), diff.getOldValue(), diff.getValue(), sbFields);
            }
        }
    }
    if (sbFields != null) {
        sb.append(TEMPLATE.updatedFields(sbFields.toSafeHtml(), labelClass));
    }
}
Also used : BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

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