return new EvalExpr(unwrapParenthesis(singleExpr)); } else { return new SimpleExpr(singleExpr, isJavaDialect, boundParams,
createExpressionBuilderConstraint(m, factPattern, fieldName, operator, value) : createSingleFieldConstraint(m, factPattern, fieldName,
public FieldConstraint asFieldConstraint(final RuleModel m, final FactPattern factPattern) { String fieldName = expr; String value = null; String operator = findNullOrNotNullOperator(expr); if (operator != null) { int opPos = expr.indexOf(operator); fieldName = expr.substring(0, opPos).trim(); } else { operator = findOperator(expr); } if (operator != null) { int opPos = expr.indexOf(operator); fieldName = expr.substring(0, opPos).trim(); value = expr.substring(opPos + operator.length(), expr.length()).trim(); } boolean isExpression = fieldName.contains(".") || fieldName.endsWith("()"); return createFieldConstraint(m, factPattern, fieldName, value, operator == null ? null : operator.trim(), isExpression); }
DataType.TYPE_THIS)); } else if (isBoundParam) { ModelField currentFact = findFact(dmo.getModuleModelFields(), factType); processExpressionPart(m, factType, currentField, expressionPart); processExpressionPart(m, factType, currentField,
} else if (value.indexOf('.') > 0 && boundParams.containsKey(value.substring(0, value.indexOf('.')).trim())) { con.setExpressionValue(parseExpression(m, null, value,
for (int index = 0; index < currentMethodInfo.getParams().size(); index++) { final String paramDataType = currentMethodInfo.getParams().get(index); final String paramValue = getParameterValue(paramDataType, parameters, index);
final String value) { SingleFieldConstraint con = new SingleFieldConstraint(); fieldName = setFieldBindingOnContraint(factPattern.getFactType(), fieldName, m, boundParams); con.setFieldName(fieldName); setOperatorAndValueOnConstraint(m, operator, value, con.setParent(createParentFor(m, factPattern, fieldName));
private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide(final RuleModel m, final FactPattern factPattern, String fieldName, final String operator, final String value) { SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide(); fieldName = setFieldBindingOnContraint(factPattern.getFactType(), fieldName, m, con, boundParams); String classType = RuleModelPersistenceHelper.getFQFactType(m, factPattern.getFactType(), dmo); con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(factPattern.getFactType())); parseExpression(m, classType, fieldName, con.getExpressionLeftSide()); setOperatorAndValueOnConstraint(m, operator, value, factPattern, con); return con; }
private SingleFieldConstraint createExpressionBuilderConstraint(final RuleModel m, final FactPattern factPattern, final String fieldName, final String operator, final String value) { // TODO: we should find a way to know when the expression uses a getter and in this case create a plain SingleFieldConstraint //int dotPos = fieldName.lastIndexOf('.'); //SingleFieldConstraint con = createSingleFieldConstraint(dotPos > 0 ? fieldName.substring(dotPos+1) : fieldName, operator, value); SingleFieldConstraint con = createSingleFieldConstraintEBLeftSide(m, factPattern, fieldName, operator, value); return con; }
private SingleFieldConstraint createParentFor(final RuleModel m, final FactPattern factPattern, final String fieldName) { int dotPos = fieldName.lastIndexOf('.'); if (dotPos > 0) { SingleFieldConstraint constraint = createNullCheckFieldConstraint(m, factPattern, fieldName.substring(0, dotPos)); factPattern.addConstraint(constraint); return constraint; } return null; }
private SingleFieldConstraint createNullCheckFieldConstraint(final RuleModel m, final FactPattern factPattern, final String fieldName) { return createFieldConstraint(m, factPattern, fieldName, null, null, true); }