use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.ConditionCol52FieldConstraintAdaptor in project drools by kiegroup.
the class BRLRuleModel method getLHSBoundField.
@Override
public SingleFieldConstraint getLHSBoundField(final String var) {
for (CompositeColumn<? extends BaseColumn> col : dtable.getConditions()) {
if (col instanceof Pattern52) {
final Pattern52 p = (Pattern52) col;
for (ConditionCol52 cc : p.getChildColumns()) {
if (cc.isBound() && cc.getBinding().equals(var)) {
final ConditionCol52FieldConstraintAdaptor sfcAdaptor = new ConditionCol52FieldConstraintAdaptor(cc);
sfcAdaptor.setFactType(p.getFactType());
return sfcAdaptor;
}
}
} else if (col instanceof BRLConditionColumn) {
// Delegate to super class's implementation
final RuleModel rm = new RuleModel();
final BRLConditionColumn brl = (BRLConditionColumn) col;
rm.lhs = brl.getDefinition().toArray(new IPattern[brl.getDefinition().size()]);
final SingleFieldConstraint sfc = rm.getLHSBoundField(var);
if (sfc != null) {
return sfc;
}
}
}
return super.getLHSBoundField(var);
}
use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.ConditionCol52FieldConstraintAdaptor in project drools by kiegroup.
the class BRLRuleModelTest method testDecisionTableColumnsWithLHSBoundFieldsInConditionCol52.
@Test
public void testDecisionTableColumnsWithLHSBoundFieldsInConditionCol52() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
Pattern52 p1 = new Pattern52();
p1.setFactType("Driver");
p1.setBoundName("$p1");
ConditionCol52 c1 = new ConditionCol52();
c1.setFactField("name");
c1.setFieldType(DataType.TYPE_STRING);
c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
c1.setBinding("$c1");
p1.getChildColumns().add(c1);
dt.getConditions().add(p1);
BRLRuleModel model = new BRLRuleModel(dt);
FieldConstraint fcr1 = model.getLHSBoundField("$c1");
assertNotNull(fcr1);
assertTrue(fcr1 instanceof ConditionCol52FieldConstraintAdaptor);
ConditionCol52FieldConstraintAdaptor fcr1sfc = (ConditionCol52FieldConstraintAdaptor) fcr1;
assertEquals("Driver", fcr1sfc.getFactType());
assertEquals("name", fcr1sfc.getFieldName());
assertEquals(DataType.TYPE_STRING, fcr1sfc.getFieldType());
}
Aggregations