Search in sources :

Example 26 with ActionWorkItemCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testRHSActionWorkItemSetFields2.

@Test
public // Test only Actions set to "true" are correctly converted to RuleModel
void testRHSActionWorkItemSetFields2() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] { "1", "desc", "true", "true", "false" };
    List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
    allColumns.add(new RowNumberCol52());
    allColumns.add(new DescriptionCol52());
    List<ActionCol52> cols = new ArrayList<ActionCol52>();
    ActionWorkItemCol52 awi = new ActionWorkItemCol52();
    PortableWorkDefinition pwd = new PortableWorkDefinition();
    pwd.setName("WorkItem");
    awi.setWorkItemDefinition(pwd);
    PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
    p1.setName("BooleanResult");
    pwd.addResult(p1);
    PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
    p2.setName("FloatResult");
    pwd.addResult(p2);
    cols.add(awi);
    ActionWorkItemSetFieldCol52 asf1 = new ActionWorkItemSetFieldCol52();
    asf1.setBoundName("$r");
    asf1.setFactField("ResultBooleanField");
    asf1.setType(DataType.TYPE_BOOLEAN);
    asf1.setWorkItemName("WorkItem");
    asf1.setWorkItemResultParameterName("BooleanResult");
    asf1.setParameterClassName(Boolean.class.getName());
    cols.add(asf1);
    ActionWorkItemSetFieldCol52 asf2 = new ActionWorkItemSetFieldCol52();
    asf2.setBoundName("$r");
    asf2.setFactField("ResultFloatField");
    asf2.setType(DataType.TYPE_NUMERIC_FLOAT);
    asf2.setWorkItemName("WorkItem");
    asf2.setWorkItemResultParameterName("FloatResult");
    asf2.setParameterClassName(Float.class.getName());
    cols.add(asf2);
    RuleModel rm = new RuleModel();
    allColumns.addAll(cols);
    List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row);
    TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData);
    p.doActions(allColumns, cols, rowDataProvider, rowData, rm);
    assertEquals(2, rm.rhs.length);
    // Examine RuleModel actions
    ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
    assertNotNull(aw);
    ActionSetField asf = (ActionSetField) rm.rhs[1];
    assertNotNull(asf);
    // Check ActionExecuteWorkItem
    PortableWorkDefinition mpwd = aw.getWorkDefinition();
    assertNotNull(mpwd);
    assertEquals(2, mpwd.getResults().size());
    PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult("BooleanResult");
    assertNotNull(mp1);
    PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult("FloatResult");
    assertNotNull(mp2);
    // Check ActionSetField
    assertEquals(asf.getVariable(), "$r");
    assertEquals(1, asf.getFieldValues().length);
    ActionFieldValue fv1 = asf.getFieldValues()[0];
    assertNotNull(fv1);
    assertTrue(fv1 instanceof ActionWorkItemFieldValue);
    ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
    assertEquals("ResultBooleanField", wifv1.getField());
    assertEquals(DataType.TYPE_BOOLEAN, wifv1.getType());
    assertEquals("WorkItem", wifv1.getWorkItemName());
    assertEquals("BooleanResult", wifv1.getWorkItemParameterName());
    assertEquals(Boolean.class.getName(), wifv1.getWorkItemParameterClassName());
}
Also used : ActionWorkItemFieldValue(org.drools.workbench.models.datamodel.rule.ActionWorkItemFieldValue) PortableFloatParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ArrayList(java.util.ArrayList) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) PortableBooleanParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition) ActionExecuteWorkItem(org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ActionSetField(org.drools.workbench.models.datamodel.rule.ActionSetField) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 27 with ActionWorkItemCol52

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

the class AuditLogEntryCellHelperTest method getSafeHtml_ActionWorkItemExecute_Simple.

@Test
public void getSafeHtml_ActionWorkItemExecute_Simple() {
    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");
    PortableWorkDefinition def1 = new PortableWorkDefinition();
    def1.setName("def1name");
    def1.addParameter(param1);
    PortableStringParameterDefinition param3 = new PortableStringParameterDefinition();
    param3.setName("param3");
    param3.setValue("value3");
    PortableWorkDefinition def2 = new PortableWorkDefinition();
    def2.setName("def2name");
    def2.addParameter(param3);
    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());
}
Also used : PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) UpdateColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Example 28 with ActionWorkItemCol52

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

the class PluginHandlerTest method testEditWhenColumnIsAnActionWorkItemCol52.

@Test
public void testEditWhenColumnIsAnActionWorkItemCol52() {
    final ActionWorkItemCol52 originalColumn = mock(ActionWorkItemCol52.class);
    final ActionWorkItemPlugin plugin = spy(new ActionWorkItemPlugin(additionalInfoPage, workItemPage, event, translationService));
    testEditActionColumn(plugin, actionWorkItemPlugin, originalColumn);
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionWorkItemPlugin(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.ActionWorkItemPlugin) Test(org.junit.Test)

Example 29 with ActionWorkItemCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52 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(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof BooleanUiColumn);
    assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
    assertEquals(false, uiModel.getColumns().get(2).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)

Example 30 with ActionWorkItemCol52

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

the class ActionWorkItemExecuteColumnSynchronizerTest method testDelete.

@Test
public void testDelete() throws VetoException {
    final ActionWorkItemCol52 column = new ActionWorkItemCol52();
    column.setHeader("col1");
    modelSynchronizer.appendColumn(column);
    assertEquals(1, model.getActionCols().size());
    assertEquals(3, uiModel.getColumns().size());
    modelSynchronizer.deleteColumn(column);
    assertEquals(0, model.getActionCols().size());
    assertEquals(2, uiModel.getColumns().size());
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) Test(org.junit.Test)

Aggregations

ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)38 Test (org.junit.Test)25 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)17 ArrayList (java.util.ArrayList)8 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)8 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)7 PortableStringParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition)7 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)7 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)7 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)6 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)6 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)6 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)6 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)6 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)6 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)6 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)6 ActionWorkItemInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52)5 ActionWorkItemSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52)5 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)5