use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSIsNullOperator.
@Test
public void testLimitedEntryLHSIsNullOperator() {
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_STRING);
cc1.setFactField("name");
cc1.setOperator("== null");
p1.getChildColumns().add(cc1);
LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
cc2.setFactField("age");
cc2.setOperator("== null");
p1.getChildColumns().add(cc2);
LimitedEntryConditionCol52 cc3 = new LimitedEntryConditionCol52();
cc3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc3.setFieldType(DataType.TYPE_DATE);
cc3.setFactField("dateOfBirth");
cc3.setOperator("== null");
p1.getChildColumns().add(cc3);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true, true }, new Object[] { 2l, "desc", false, false, false } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( name == null , age == null , dateOfBirth == null )");
assertTrue(index > -1);
index = drl.indexOf("Smurf( )", index + 1);
assertFalse(index > -1);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSNotInOperator.
@Test
public void testLimitedEntryLHSNotInOperator() {
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_STRING);
cc1.setFactField("name");
cc1.setOperator("not in");
cc1.setValue(new DTCellValue52("Pupa, Brains"));
p1.getChildColumns().add(cc1);
LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
cc2.setFactField("age");
cc2.setOperator("not in");
cc2.setValue(new DTCellValue52("55, 66"));
p1.getChildColumns().add(cc2);
dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true }, new Object[] { 2l, "desc", false, false } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
int index = -1;
index = drl.indexOf("Smurf( name not in ( \"Pupa\", \"Brains\" ) , age not in ( 55, 66 ) )");
assertTrue(index > -1);
index = drl.indexOf("Smurf( )", index + 1);
assertFalse(index > -1);
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools-wb by kiegroup.
the class LimitedGuidedDecisionTableBuilder method withIntegerColumn.
public LimitedGuidedDecisionTableBuilder withIntegerColumn(final String boundName, final String factType, final String field, final String operator, final int value) {
final Pattern52 pattern = findPattern(boundName, factType);
final LimitedEntryConditionCol52 condition = new LimitedEntryConditionCol52();
condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
condition.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
condition.setFactField(field);
condition.setHeader("Some header");
condition.setOperator(operator);
condition.setValue(new DTCellValue52() {
{
setNumericValue(new Integer(value));
}
});
pattern.getChildColumns().add(condition);
addPattern(pattern);
return this;
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools-wb by kiegroup.
the class ConditionColumnPlugin method clone.
ConditionCol52 clone(final ConditionCol52 column) {
final ConditionCol52 clone;
if (tableFormat() == LIMITED_ENTRY) {
clone = new LimitedEntryConditionCol52() {
{
setValue(cloneDTCellValue(((LimitedEntryCol) column).getValue()));
}
};
} else {
clone = new ConditionCol52();
}
clone.setConstraintValueType(column.getConstraintValueType());
clone.setFactField(column.getFactField());
clone.setFieldType(column.getFieldType());
clone.setHeader(column.getHeader());
clone.setOperator(column.getOperator());
clone.setValueList(column.getValueList());
clone.setDefaultValue(cloneDTCellValue(column.getDefaultValue()));
clone.setHideColumn(column.isHideColumn());
clone.setParameters(column.getParameters());
clone.setWidth(column.getWidth());
clone.setBinding(column.getBinding());
return clone;
}
use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52 in project drools-wb by kiegroup.
the class FactPatternConstraintsPageViewImpl method makeNewConditionColumn.
private ConditionCol52 makeNewConditionColumn(final AvailableField f) {
final GuidedDecisionTable52.TableFormat format = presenter.getTableFormat();
if (format == GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY) {
final ConditionCol52 c = new ConditionCol52();
c.setFactField(f.getName());
c.setFieldType(f.getType());
c.setConstraintValueType(f.getCalculationType());
return c;
} else {
final LimitedEntryConditionCol52 c = new LimitedEntryConditionCol52();
c.setFactField(f.getName());
c.setFieldType(f.getType());
c.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
return c;
}
}
Aggregations