void connectiveOperatorDropDown(final ConnectiveConstraint cc, final Callback<Widget> callback) { if (!isReadOnly) { final String factType = cc.getFactType(); final String fieldName = cc.getFieldName(); this.getDataModelOracle().getConnectiveOperatorCompletions(factType, fieldName, new Callback<String[]>() { @Override public void callback(final String[] operators) { final CEPOperatorsDropdown dropdown = getDropdown(operators, cc); dropdown.addPlaceholder(GuidedRuleEditorResources.CONSTANTS.pleaseChoose(), ""); dropdown.addValueChangeHandler(new ValueChangeHandler<OperatorSelection>() { public void onValueChange(ValueChangeEvent<OperatorSelection> event) { OperatorSelection selection = event.getValue(); String selected = selection.getValue(); cc.setOperator(selected); } }); callback.callback(dropdown); } }); } else { final SmallLabel w = new SmallLabel("<b>" + (cc.getOperator() == null ? GuidedRuleEditorResources.CONSTANTS.pleaseChoose() : HumanReadable.getOperatorDisplayName(cc.getOperator())) + "</b>"); callback.callback(w); } }
void connectiveOperatorDropDown(final ConnectiveConstraint cc, final Callback<Widget> callback) { if (!isReadOnly) { final String factType = cc.getFactType(); final String fieldName = cc.getFieldName(); this.getDataModelOracle().getConnectiveOperatorCompletions(factType, fieldName, new Callback<String[]>() { @Override public void callback(final String[] operators) { final CEPOperatorsDropdown dropdown = getDropdown(operators, cc); dropdown.addPlaceholder(GuidedRuleEditorResources.CONSTANTS.pleaseChoose(), ""); dropdown.addValueChangeHandler(new ValueChangeHandler<OperatorSelection>() { public void onValueChange(ValueChangeEvent<OperatorSelection> event) { OperatorSelection selection = event.getValue(); String selected = selection.getValue(); cc.setOperator(selected); } }); callback.callback(dropdown); } }); } else { final SmallLabel w = new SmallLabel("<b>" + (cc.getOperator() == null ? GuidedRuleEditorResources.CONSTANTS.pleaseChoose() : HumanReadable.getOperatorDisplayName(cc.getOperator())) + "</b>"); callback.callback(w); } }
@Test public void testAbbreviatedCondition() throws Exception { final String resourcePath = RULES_ROOT + "matchPeopleAbbreviatedCondition.rdrl"; final GuidedEditorContent content = guidedRuleService.loadContent(getPath(resourcePath)); final RuleModel model = content.getModel(); Assertions.assertThat(model.lhs.length).isEqualTo(1); final FactPattern pattern = (FactPattern) model.lhs[0]; final SingleFieldConstraint fieldConstraintOne = (SingleFieldConstraint) pattern.getConstraint(0); Assertions.assertThat(fieldConstraintOne.getConnectives()).hasSize(2); final ConnectiveConstraint fieldConstraintTwo = fieldConstraintOne.getConnectives()[0]; final ConnectiveConstraint fieldConstraintThree = fieldConstraintOne.getConnectives()[1]; Assertions.assertThat(fieldConstraintOne.getFieldName()).isEqualTo("age"); Assertions.assertThat(fieldConstraintOne.getOperator()).isEqualTo(Operator.NOT_EQUAL.getOperatorString()); Assertions.assertThat(fieldConstraintOne.getValue()).isEqualTo("18"); Assertions.assertThat(fieldConstraintTwo.getFieldName()).isEqualTo("age"); Assertions.assertThat(fieldConstraintTwo.getOperator()).isEqualTo("&& " + Operator.LESS.getOperatorString()); Assertions.assertThat(fieldConstraintTwo.getValue()).isEqualTo("25"); Assertions.assertThat(fieldConstraintThree.getFieldName()).isEqualTo("age"); Assertions.assertThat(fieldConstraintThree.getOperator()).isEqualTo("&& " + Operator.GREATER.getOperatorString()); Assertions.assertThat(fieldConstraintThree.getValue()).isEqualTo("15"); final List<ValidationMessage> messages = validateResource(resourcePath); Assertions.assertThat(messages).isEmpty(); }
@Test public void testAbbreviatedCondition() throws Exception { final String resourcePath = RULES_ROOT + "matchPeopleAbbreviatedCondition.rdrl"; final GuidedEditorContent content = guidedRuleService.loadContent(getPath(resourcePath)); final RuleModel model = content.getModel(); Assertions.assertThat(model.lhs.length).isEqualTo(1); final FactPattern pattern = (FactPattern) model.lhs[0]; final SingleFieldConstraint fieldConstraintOne = (SingleFieldConstraint) pattern.getConstraint(0); Assertions.assertThat(fieldConstraintOne.getConnectives()).hasSize(2); final ConnectiveConstraint fieldConstraintTwo = fieldConstraintOne.getConnectives()[0]; final ConnectiveConstraint fieldConstraintThree = fieldConstraintOne.getConnectives()[1]; Assertions.assertThat(fieldConstraintOne.getFieldName()).isEqualTo("age"); Assertions.assertThat(fieldConstraintOne.getOperator()).isEqualTo(Operator.NOT_EQUAL.getOperatorString()); Assertions.assertThat(fieldConstraintOne.getValue()).isEqualTo("18"); Assertions.assertThat(fieldConstraintTwo.getFieldName()).isEqualTo("age"); Assertions.assertThat(fieldConstraintTwo.getOperator()).isEqualTo("&& " + Operator.LESS.getOperatorString()); Assertions.assertThat(fieldConstraintTwo.getValue()).isEqualTo("25"); Assertions.assertThat(fieldConstraintThree.getFieldName()).isEqualTo("age"); Assertions.assertThat(fieldConstraintThree.getOperator()).isEqualTo("&& " + Operator.GREATER.getOperatorString()); Assertions.assertThat(fieldConstraintThree.getValue()).isEqualTo("15"); final List<ValidationMessage> messages = validateResource(resourcePath); Assertions.assertThat(messages).isEmpty(); }
private ConnectiveConstraint visitConnectiveConstraint(ConnectiveConstraint cc) { ConnectiveConstraint clone = new ConnectiveConstraint(); clone.setConstraintValueType(cc.getConstraintValueType()); clone.setExpressionValue((ExpressionFormLine) visit(cc.getExpressionValue())); clone.setFactType(cc.getFactType()); clone.setFieldName(cc.getFieldName()); clone.setFieldType(cc.getFieldType()); clone.setOperator(cc.getOperator()); for (Map.Entry<String, String> entry : cc.getParameters().entrySet()) { clone.setParameter(entry.getKey(), entry.getValue()); } clone.setValue(cc.getValue()); return clone; }
private ConnectiveConstraint visitConnectiveConstraint(ConnectiveConstraint cc) { ConnectiveConstraint clone = new ConnectiveConstraint(); clone.setConstraintValueType(cc.getConstraintValueType()); clone.setExpressionValue((ExpressionFormLine) visit(cc.getExpressionValue())); clone.setFactType(cc.getFactType()); clone.setFieldName(cc.getFieldName()); clone.setFieldType(cc.getFieldType()); clone.setOperator(cc.getOperator()); for (Map.Entry<String, String> entry : cc.getParameters().entrySet()) { clone.setParameter(entry.getKey(), entry.getValue()); } clone.setValue(cc.getValue()); return clone; }
conn.getConstraintValueType(), conn.getFieldType(), conn.getOperator(), connectiveParameters, conn.getValue(),
String fieldName = cc.getFieldName(); if (fieldName.equals(DataType.TYPE_THIS)) { showLiteralSelector = CEPOracle.isCEPOperator(cc.getOperator()); showFormulaSelector = showFormulaSelector && showLiteralSelector;
String fieldName = cc.getFieldName(); if (fieldName.equals(DataType.TYPE_THIS)) { showLiteralSelector = CEPOracle.isCEPOperator(cc.getOperator()); showFormulaSelector = showFormulaSelector && showLiteralSelector;