use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_ActionWorkItemExecute_Complex.
@Test
public void getSafeHtml_ActionWorkItemExecute_Complex() {
ActionWorkItemCol52 originalColumn = new ActionWorkItemCol52();
originalColumn.setHeader("action1");
originalColumn.setHideColumn(false);
ActionWorkItemCol52 newColumn = new ActionWorkItemCol52();
newColumn.setHeader("action2");
newColumn.setHideColumn(true);
PortableStringParameterDefinition param1 = new PortableStringParameterDefinition();
param1.setName("param1");
param1.setValue("value1");
PortableStringParameterDefinition param2 = new PortableStringParameterDefinition();
param2.setName("param2");
param2.setValue("value2");
PortableWorkDefinition def1 = new PortableWorkDefinition();
def1.setName("def1name");
def1.addParameter(param1);
def1.addParameter(param2);
PortableStringParameterDefinition param3 = new PortableStringParameterDefinition();
param3.setName("param3");
param3.setValue("value3");
PortableStringParameterDefinition param4 = new PortableStringParameterDefinition();
param4.setName("param1");
param4.setValue("value1");
PortableStringParameterDefinition param5 = new PortableStringParameterDefinition();
param5.setName("param5");
param5.setBinding("binding5");
PortableStringParameterDefinition param6 = new PortableStringParameterDefinition();
param6.setName("param2");
param6.setValue("value6");
PortableWorkDefinition def2 = new PortableWorkDefinition();
def2.setName("def2name");
def2.addParameter(param3);
def2.addParameter(param4);
def2.addParameter(param5);
def2.addParameter(param6);
originalColumn.setWorkItemDefinition(def1);
newColumn.setWorkItemDefinition(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());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_BrlAction.
@Test
public void getSafeHtml_BrlAction() {
// Definition diffs are currently not supported, maybe #soon?
BRLActionColumn originalColumn = new BRLActionColumn();
// originalColumn.setDefinition(Arrays.asList(new ActionRetractFact("fact1")));
originalColumn.setHeader("action1");
originalColumn.setHideColumn(false);
BRLActionColumn newColumn = new BRLActionColumn();
// newColumn.setDefinition(Arrays.asList(new ActionRetractFact("fact2"), new ActionRetractFact("fact3")));
newColumn.setHeader("action2");
newColumn.setHideColumn(true);
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());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class AttributeColumnSynchronizer 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 AttributeCol52 originalColumn = (AttributeCol52) originalMetaData.getColumn();
final AttributeCol52 editedColumn = (AttributeCol52) editedMetaData.getColumn();
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
update(originalColumn, editedColumn);
final boolean isAttributeUpdated = BaseColumnFieldDiffImpl.hasChanged(AttributeCol52.FIELD_ATTRIBUTE, diffs);
final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(DTColumnConfig52.FIELD_HIDE_COLUMN, diffs);
if (isAttributeUpdated) {
clearColumnData(originalColumn);
}
synchroniseUpdateColumn(originalColumn);
if (isAttributeUpdated) {
setColumnHeader(originalColumn, originalColumn.getAttribute());
}
if (isHideUpdated) {
setColumnVisibility(originalColumn, originalColumn.isHideColumn());
}
return diffs;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff 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<>();
for (BRLActionVariableColumn variable : originalColumn.getChildColumns()) {
int iColumnIndex = model.getExpandedColumns().indexOf(variable);
final List<DTCellValue52> originalColumnData = new ArrayList<>();
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;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionInsertFactColumnSynchronizer 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 ActionInsertFactCol52 originalColumn = (ActionInsertFactCol52) originalMetaData.getColumn();
final ActionInsertFactCol52 editedColumn = (ActionInsertFactCol52) editedMetaData.getColumn();
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
update(originalColumn, editedColumn);
final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionInsertFactCol52.FIELD_HIDE_COLUMN, diffs);
final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionInsertFactCol52.FIELD_HEADER, diffs);
final boolean isBoundNameUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionInsertFactCol52.FIELD_BOUND_NAME, diffs);
final boolean isFactTypeUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionInsertFactCol52.FIELD_FACT_TYPE, diffs);
final boolean isFactFieldUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionInsertFactCol52.FIELD_FACT_FIELD, diffs);
if (isBoundNameUpdated || isFactTypeUpdated || isFactFieldUpdated) {
clearColumnData(originalColumn);
} else {
cleanColumnData(originalColumn, editedColumn, diffs);
}
synchroniseUpdateColumn(originalColumn);
if (isHideUpdated) {
setColumnVisibility(originalColumn, originalColumn.isHideColumn());
}
if (isHeaderUpdated) {
setColumnHeader(originalColumn, originalColumn.getHeader());
}
return diffs;
}
Aggregations