Search in sources :

Example 36 with SingleFieldConstraintEBLeftSide

use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools-wb by kiegroup.

the class SingleFieldConstraintOperatorSelector method configure.

public void configure(final SingleFieldConstraint constraint, final Supplier<ConstraintValueEditor> constraintValueEditor, final Function<SingleFieldConstraint, ConstraintValueEditor> constraintValueEditorProducer, final FactPatternWidget parent, final HorizontalPanel placeholderForDropdown, final FlexTable constraintValueEditorWrapper, final int constraintValueEditorRowIndex, final int constraintValueEditorColumnIndex, final AsyncPackageDataModelOracle oracle) {
    this.constraint = constraint;
    this.constraintValueEditor = constraintValueEditor;
    this.constraintValueEditorProducer = constraintValueEditorProducer;
    this.parent = parent;
    this.placeholderForDropdown = placeholderForDropdown;
    this.constraintValueEditorWrapper = constraintValueEditorWrapper;
    this.constraintValueEditorRowIndex = constraintValueEditorRowIndex;
    this.constraintValueEditorColumnIndex = constraintValueEditorColumnIndex;
    this.oracle = oracle;
    String fieldName;
    String factType;
    // Connectives Operators are handled in class Connectives
    if (constraint instanceof SingleFieldConstraintEBLeftSide) {
        SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constraint;
        factType = sfexp.getExpressionLeftSide().getPreviousClassType();
        if (factType == null) {
            factType = sfexp.getExpressionLeftSide().getClassType();
        }
        fieldName = sfexp.getExpressionLeftSide().getFieldName();
    } else {
        factType = constraint.getFactType();
        fieldName = constraint.getFieldName();
    }
    oracle.getOperatorCompletions(factType, fieldName, operators -> {
        final CEPOperatorsDropdown operatorsDropdown = getNewOperatorDropdown(operators, constraint);
        operatorsDropdown.addPlaceholder(GuidedRuleEditorResources.CONSTANTS.pleaseChoose(), "");
        placeholderForDropdown.add(operatorsDropdown);
        operatorsDropdown.addValueChangeHandler(event -> onDropDownValueChanged(event));
    });
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) CEPOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown)

Example 37 with SingleFieldConstraintEBLeftSide

use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools-wb by kiegroup.

the class PopupCreatorTest method testMakeSingleFieldConstraintEBLeftSide.

@Test
public void testMakeSingleFieldConstraintEBLeftSide() {
    final String expectedFactType = "factType";
    final ExpressionFormLine expectedExpressionFormLine = mock(ExpressionFormLine.class);
    final int expectedConstraintValueType = SingleFieldConstraint.TYPE_UNDEFINED;
    doReturn(expectedExpressionFormLine).when(popupCreator).makeExpressionFormLine(expectedFactType);
    final SingleFieldConstraintEBLeftSide constraint = popupCreator.makeSingleFieldConstraintEBLeftSide(expectedFactType);
    assertEquals(expectedConstraintValueType, constraint.getConstraintValueType());
    assertEquals(expectedExpressionFormLine, constraint.getExpressionLeftSide());
    assertEquals(expectedFactType, constraint.getFactType());
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) Test(org.junit.Test)

Aggregations

SingleFieldConstraintEBLeftSide (org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide)37 Test (org.junit.Test)31 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)30 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)29 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)29 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)29 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)28 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)28 ExpressionUnboundFact (org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact)24 ExpressionField (org.drools.workbench.models.datamodel.rule.ExpressionField)21 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)13 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)10 ExpressionMethod (org.drools.workbench.models.datamodel.rule.ExpressionMethod)7 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)6 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)3 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)3 ExpressionFormLine (org.drools.workbench.models.datamodel.rule.ExpressionFormLine)3 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)3 List (java.util.List)2