Search in sources :

Example 6 with UpdateColumnAuditLogEntry

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

the class AuditLogEntryCellHelperTest method getSafeHtml_ActionInsert.

@Test
public void getSafeHtml_ActionInsert() {
    // hide, insert, value list, default value, field, header
    ActionInsertFactCol52 originalColumn = new ActionInsertFactCol52();
    originalColumn.setFactField("field1");
    originalColumn.setInsertLogical(false);
    originalColumn.setValueList("q,w,e");
    originalColumn.setHeader("action1");
    originalColumn.setHideColumn(false);
    originalColumn.setDefaultValue(new DTCellValue52("def1"));
    ActionInsertFactCol52 newColumn = new ActionInsertFactCol52();
    newColumn.setFactField("field2");
    newColumn.setInsertLogical(true);
    newColumn.setValueList("a,s,d");
    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(getActionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) 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)

Example 7 with UpdateColumnAuditLogEntry

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

the class GuidedDecisionTablePresenter_AuditLogTest method updateColumnAddsToLog.

@Test
public void updateColumnAddsToLog() throws VetoException {
    dtPresenter.updateColumn(new ActionCol52(), new ActionCol52());
    dtPresenter.updateColumn(new AttributeCol52(), new AttributeCol52());
    dtPresenter.updateColumn(new ConditionCol52(), new ConditionCol52());
    dtPresenter.updateColumn(new MetadataCol52(), new MetadataCol52());
    dtPresenter.updateColumn(new Pattern52(), new ConditionCol52(), new Pattern52(), new ConditionCol52());
    verify(synchronizer, times(4)).updateColumn(any(BaseColumn.class), any(BaseColumn.class));
    verify(synchronizer).updateColumn(any(Pattern52.class), any(ConditionCol52.class), any(Pattern52.class), any(ConditionCol52.class));
    verify(model, times(5)).getAuditLog();
    assertEquals(5, model.getAuditLog().size());
    for (UpdateColumnAuditLogEntry entry : model.getAuditLog().toArray(new UpdateColumnAuditLogEntry[0])) {
        assertEquals(diffs, entry.getDiffs());
    }
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) UpdateColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Test(org.junit.Test)

Example 8 with UpdateColumnAuditLogEntry

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

the class GuidedDecisionTablePresenter method doUpdateColumn.

private void doUpdateColumn(final BaseColumn originalColumn, final BaseColumn editedColumn, final VetoableUpdateColumnCommand update, final Command callback) throws VetoException {
    if (isReadOnly()) {
        return;
    }
    final List<BaseColumnFieldDiff> diffs = update.execute();
    parent.updateLinks();
    // Log change to column definition
    if (!(diffs == null || diffs.isEmpty())) {
        view.getLayer().draw();
        model.getAuditLog().add(new UpdateColumnAuditLogEntry(identity.getIdentifier(), originalColumn, editedColumn, diffs));
        callback.execute();
    }
}
Also used : UpdateColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)

Example 9 with UpdateColumnAuditLogEntry

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

the class AuditLogEntryCellHelperTest method getSafeHtml_Condition.

@Test
public void getSafeHtml_Condition() {
    ConditionCol52 originalColumn = new ConditionCol52();
    originalColumn.setBinding("bind1");
    originalColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    originalColumn.setFactField("field1");
    originalColumn.setFieldType("FieldType1");
    originalColumn.setOperator("==");
    originalColumn.setValueList("a,b,c");
    originalColumn.setHeader("condition1");
    originalColumn.setHideColumn(false);
    originalColumn.setDefaultValue(new DTCellValue52("def1"));
    ConditionCol52 newColumn = new ConditionCol52();
    newColumn.setBinding("bind2");
    newColumn.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
    newColumn.setFactField("field2");
    newColumn.setFieldType("FieldType2");
    newColumn.setOperator("!=");
    newColumn.setValueList("x,y,z");
    newColumn.setHeader("condition2");
    newColumn.setHideColumn(true);
    newColumn.setDefaultValue(new DTCellValue52("def2"));
    Pattern52 originalPattern = new Pattern52();
    originalPattern.setBoundName("patBind1");
    originalPattern.setFactType("FactType1");
    originalPattern.setEntryPointName("ep1");
    Pattern52 newPattern = new Pattern52();
    newPattern.setBoundName("patBind2");
    newPattern.setFactType("FactType2");
    newPattern.setEntryPointName("ep2");
    List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
    diffs.addAll(originalPattern.diff(newPattern));
    SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
    assertEquals(getConditionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) 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)

Example 10 with UpdateColumnAuditLogEntry

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

the class AuditLogEntryCellHelperTest method getSafeHtml_BrlAction_DefinitionOnly.

@Test
public void getSafeHtml_BrlAction_DefinitionOnly() {
    BRLActionColumn originalColumn = new BRLActionColumn();
    originalColumn.setDefinition(Arrays.asList(new ActionRetractFact("fact1")));
    originalColumn.setHeader("action");
    originalColumn.setHideColumn(false);
    BRLActionColumn newColumn = new BRLActionColumn();
    newColumn.setDefinition(Arrays.asList(new ActionRetractFact("fact2"), new ActionRetractFact("fact3")));
    newColumn.setHeader("action");
    newColumn.setHideColumn(false);
    List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
    SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
    // Definition diffs are currently not supported, maybe #soon?
    // assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
    assertEquals(getHeaderRepre(newColumn.getHeader()) + getDiffRepre(new ArrayList<>()), result.asString());
}
Also used : ActionRetractFact(org.drools.workbench.models.datamodel.rule.ActionRetractFact) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) 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) Test(org.junit.Test)

Aggregations

UpdateColumnAuditLogEntry (org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry)16 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)15 Test (org.junit.Test)15 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)14 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)6 PortableStringParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition)2 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)2 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)2 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)2 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)2 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)2 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)2 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)2 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)2 ActionRetractFact (org.drools.workbench.models.datamodel.rule.ActionRetractFact)1 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)1 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)1 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)1 ActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52)1 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)1