use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52 in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldColumnConverter method makeHeaderMetaData.
@Override
public List<GridColumn.HeaderMetaData> makeHeaderMetaData(final BaseColumn column) {
final String workItemName = ((ActionWorkItemSetFieldCol52) column).getWorkItemName();
return new ArrayList<GridColumn.HeaderMetaData>() {
{
add(new BaseHeaderMetaData(workItemName, ActionCol52.class.getName()));
add(new BaseHeaderMetaData(column.getHeader(), workItemName + "-set"));
}
};
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52 in project drools-wb by kiegroup.
the class PluginHandlerTest method testEditWhenColumnIsAnActionWorkItemSetFieldCol52.
@Test
public void testEditWhenColumnIsAnActionWorkItemSetFieldCol52() {
final ActionWorkItemSetFieldCol52 originalColumn = mock(ActionWorkItemSetFieldCol52.class);
final ActionWorkItemSetFieldPlugin plugin = spy(new ActionWorkItemSetFieldPlugin(patternPage, fieldPage, additionalInfoPage, workItemPage, event, translationService));
doReturn(wizard).when(wizardManagedInstance).get();
doReturn(plugin).when(actionWorkItemSetFieldPlugin).get();
pluginHandler.edit(originalColumn);
verify(plugin).setOriginalColumnConfig52(originalColumn);
verify(pluginHandler).openWizard(plugin);
verify(wizard).start(plugin);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52 in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldColumnSynchronizerTest method testMoveColumnTo_MoveRight.
@Test
public void testMoveColumnTo_MoveRight() throws VetoException {
// Add a Pattern to be updated
final Pattern52 pattern = new Pattern52();
pattern.setBoundName("$a");
pattern.setFactType("Applicant");
final ConditionCol52 condition = new ConditionCol52();
condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
condition.setHeader("col1");
condition.setFactField("age");
condition.setOperator("==");
modelSynchronizer.appendColumn(pattern, condition);
final ActionWorkItemSetFieldCol52 column1 = new ActionWorkItemSetFieldCol52();
column1.setWorkItemName(WORK_ITEM_NAME);
column1.setBoundName("$a");
column1.setFactField("age");
column1.setHeader("wid1");
final ActionWorkItemSetFieldCol52 column2 = new ActionWorkItemSetFieldCol52();
column2.setWorkItemName(WORK_ITEM_NAME);
column2.setBoundName("$a");
column2.setFactField("name");
column2.setHeader("wid2");
modelSynchronizer.appendColumn(column1);
modelSynchronizer.appendColumn(column2);
modelSynchronizer.appendRow();
uiModel.setCellValue(0, 5, new BaseGridCellValue<Boolean>(true));
uiModel.setCellValue(0, 6, new BaseGridCellValue<Boolean>(false));
assertEquals(3, model.getActionCols().size());
assertEquals(column1, model.getActionCols().get(1));
assertEquals(column2, model.getActionCols().get(2));
assertEquals(true, model.getData().get(0).get(5).getBooleanValue());
assertEquals(false, model.getData().get(0).get(6).getBooleanValue());
assertEquals(7, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(5);
final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(6);
assertEquals("wid1", uiModelColumn1_1.getHeaderMetaData().get(1).getTitle());
assertEquals("wid2", uiModelColumn2_1.getHeaderMetaData().get(1).getTitle());
assertTrue(uiModelColumn1_1 instanceof BooleanUiColumn);
assertTrue(uiModelColumn2_1 instanceof BooleanUiColumn);
assertEquals(5, uiModelColumn1_1.getIndex());
assertEquals(6, uiModelColumn2_1.getIndex());
assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
uiModel.moveColumnTo(6, uiModelColumn1_1);
assertEquals(3, model.getActionCols().size());
assertEquals(column2, model.getActionCols().get(1));
assertEquals(column1, model.getActionCols().get(2));
assertEquals(false, model.getData().get(0).get(5).getBooleanValue());
assertEquals(true, model.getData().get(0).get(6).getBooleanValue());
assertEquals(7, uiModel.getColumns().size());
final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(5);
final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(6);
assertEquals("wid2", uiModelColumn1_2.getHeaderMetaData().get(1).getTitle());
assertEquals("wid1", uiModelColumn2_2.getHeaderMetaData().get(1).getTitle());
assertTrue(uiModelColumn1_2 instanceof BooleanUiColumn);
assertTrue(uiModelColumn2_2 instanceof BooleanUiColumn);
assertEquals(6, uiModelColumn1_2.getIndex());
assertEquals(5, uiModelColumn2_2.getIndex());
assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testRHSActionWorkItemSetFields1.
@Test
public // Test all Actions setting fields are correctly converted to RuleModel
void testRHSActionWorkItemSetFields1() {
GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
String[] row = new String[] { "1", "desc", "true", "true", "true", "true", "true" };
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);
PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
p3.setName("IntegerResult");
pwd.addResult(p3);
PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
p4.setName("StringResult");
pwd.addResult(p4);
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);
ActionWorkItemSetFieldCol52 asf3 = new ActionWorkItemSetFieldCol52();
asf3.setBoundName("$r");
asf3.setFactField("ResultIntegerField");
asf3.setType(DataType.TYPE_NUMERIC_INTEGER);
asf3.setWorkItemName("WorkItem");
asf3.setWorkItemResultParameterName("IntegerResult");
asf3.setParameterClassName(Integer.class.getName());
cols.add(asf3);
ActionWorkItemSetFieldCol52 asf4 = new ActionWorkItemSetFieldCol52();
asf4.setBoundName("$r");
asf4.setFactField("ResultStringField");
asf4.setType(DataType.TYPE_STRING);
asf4.setWorkItemName("WorkItem");
asf4.setWorkItemResultParameterName("StringResult");
asf4.setParameterClassName(String.class.getName());
cols.add(asf4);
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(4, mpwd.getResults().size());
PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult("BooleanResult");
assertNotNull(mp1);
PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult("FloatResult");
assertNotNull(mp2);
PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getResult("IntegerResult");
assertNotNull(mp3);
PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getResult("StringResult");
assertNotNull(mp4);
// Check ActionSetField
assertEquals(asf.getVariable(), "$r");
assertEquals(4, 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());
ActionFieldValue fv2 = asf.getFieldValues()[1];
assertNotNull(fv2);
assertTrue(fv2 instanceof ActionWorkItemFieldValue);
ActionWorkItemFieldValue wifv2 = (ActionWorkItemFieldValue) fv2;
assertEquals("ResultFloatField", wifv2.getField());
assertEquals(DataType.TYPE_NUMERIC_FLOAT, wifv2.getType());
assertEquals("WorkItem", wifv2.getWorkItemName());
assertEquals("FloatResult", wifv2.getWorkItemParameterName());
assertEquals(Float.class.getName(), wifv2.getWorkItemParameterClassName());
ActionFieldValue fv3 = asf.getFieldValues()[2];
assertNotNull(fv3);
assertTrue(fv3 instanceof ActionWorkItemFieldValue);
ActionWorkItemFieldValue wifv3 = (ActionWorkItemFieldValue) fv3;
assertEquals("ResultIntegerField", wifv3.getField());
assertEquals(DataType.TYPE_NUMERIC_INTEGER, wifv3.getType());
assertEquals("WorkItem", wifv3.getWorkItemName());
assertEquals("IntegerResult", wifv3.getWorkItemParameterName());
assertEquals(Integer.class.getName(), wifv3.getWorkItemParameterClassName());
ActionFieldValue fv4 = asf.getFieldValues()[3];
assertNotNull(fv4);
assertTrue(fv4 instanceof ActionWorkItemFieldValue);
ActionWorkItemFieldValue wifv4 = (ActionWorkItemFieldValue) fv4;
assertEquals("ResultStringField", wifv4.getField());
assertEquals(DataType.TYPE_STRING, wifv4.getType());
assertEquals("WorkItem", wifv4.getWorkItemName());
assertEquals("StringResult", wifv4.getWorkItemParameterName());
assertEquals(String.class.getName(), wifv4.getWorkItemParameterClassName());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52 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());
}
Aggregations