Search in sources :

Example 1 with ConditionCol52FieldConstraintAdaptor

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);
}
Also used : BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ConditionCol52FieldConstraintAdaptor(org.drools.workbench.models.guided.dtable.shared.model.adaptors.ConditionCol52FieldConstraintAdaptor) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel)

Example 2 with ConditionCol52FieldConstraintAdaptor

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());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) ConditionCol52FieldConstraintAdaptor(org.drools.workbench.models.guided.dtable.shared.model.adaptors.ConditionCol52FieldConstraintAdaptor) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Aggregations

BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)2 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)2 ConditionCol52FieldConstraintAdaptor (org.drools.workbench.models.guided.dtable.shared.model.adaptors.ConditionCol52FieldConstraintAdaptor)2 FieldConstraint (org.drools.workbench.models.datamodel.rule.FieldConstraint)1 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)1 BRLRuleModel (org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)1 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)1 Test (org.junit.Test)1