use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.
the class LimitedGuidedDecisionTableBuilder method withAction.
public LimitedGuidedDecisionTableBuilder withAction(String boundName, String factField, String typeNumericInteger, DTCellValue52 value) {
LimitedEntryActionSetFieldCol52 ins = new LimitedEntryActionSetFieldCol52();
ins.setBoundName(boundName);
ins.setFactField(factField);
ins.setValue(value);
ins.setType(typeNumericInteger);
table.getActionCols().add(ins);
return this;
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.
the class ActionSetFieldsPageViewImpl method makeNewActionColumn.
private ActionSetFieldCol52 makeNewActionColumn(final AvailableField f) {
final GuidedDecisionTable52.TableFormat format = presenter.getTableFormat();
if (format == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY) {
final ActionSetFieldCol52 a = new ActionSetFieldCol52();
a.setBoundName(availablePatternsSelection.getBoundName());
a.setFactField(f.getName());
a.setType(f.getType());
return a;
} else {
final LimitedEntryActionSetFieldCol52 a = new LimitedEntryActionSetFieldCol52();
a.setBoundName(availablePatternsSelection.getBoundName());
a.setFactField(f.getName());
a.setType(f.getType());
return a;
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.
the class LimitedEntryActionSetFieldCol52DefinitionBuilderTest method simpleActionUpdateField.
@Test
public void simpleActionUpdateField() {
final AtomicBoolean calledBack = new AtomicBoolean(false);
setupLimitedEntryPatternAndCondition();
final LimitedEntryActionSetFieldCol52 asf = new LimitedEntryActionSetFieldCol52();
asf.setBoundName("$p");
asf.setFactField("name");
asf.setValue(new DTCellValue52("Michael"));
asf.setUpdate(true);
model.getActionCols().add(asf);
when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING);
builder.generateDefinition(dtPresenter, asf, (String definition) -> {
calledBack.set(true);
assertEquals("modify( $p ) {<br/>" + "setName( \"Michael\" )<br/>" + "}", definition);
});
assertTrue(calledBack.get());
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools-wb by kiegroup.
the class LimitedEntryActionSetFieldCol52DefinitionBuilderTest method simpleActionSetField.
@Test
public void simpleActionSetField() {
final AtomicBoolean calledBack = new AtomicBoolean(false);
setupPatternAndCondition();
final LimitedEntryActionSetFieldCol52 asf = new LimitedEntryActionSetFieldCol52();
asf.setBoundName("$p");
asf.setFactField("name");
asf.setValue(new DTCellValue52("Michael"));
model.getActionCols().add(asf);
when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING);
builder.generateDefinition(dtPresenter, asf, (String definition) -> {
calledBack.set(true);
assertEquals("$p.setName( \"Michael\" );", definition);
});
assertTrue(calledBack.get());
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryActionSet.
@Test
public void testLimitedEntryActionSet() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
dt.setTableName("limited-entry");
Pattern52 p1 = new Pattern52();
p1.setBoundName("p1");
p1.setFactType("Smurf");
dt.getConditions().add(p1);
LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc1.setFieldType(DataType.TYPE_BOOLEAN);
cc1.setFactField("isSmurf");
cc1.setOperator("==");
cc1.setValue(new DTCellValue52("true"));
p1.getChildColumns().add(cc1);
LimitedEntryActionSetFieldCol52 asf1 = new LimitedEntryActionSetFieldCol52();
asf1.setBoundName("p1");
asf1.setFactField("colour");
asf1.setValue(new DTCellValue52("Blue"));
dt.getActionCols().add(asf1);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true }, new Object[] { 2l, "desc", true, false } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( isSmurf == true )");
assertTrue(index > -1);
index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
assertTrue(index > -1);
index = drl.indexOf("Smurf( isSmurf == true )", index + 1);
assertTrue(index > -1);
index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
assertFalse(index > -1);
}
Aggregations