use of org.drools.compiler.lang.descr.PredicateDescr in project drools by kiegroup.
the class MVELConstraintBuilder method buildCompilationUnit.
public MVELCompilationUnit buildCompilationUnit(RuleBuildContext context, Pattern pattern, String expression, Map<String, OperatorDescr> aliases) {
Dialect dialect = context.getDialect();
context.setDialect(context.getDialect("mvel"));
try {
PredicateDescr predicateDescr = new PredicateDescr(context.getRuleDescr().getResource(), expression);
AnalysisResult analysis = buildAnalysis(context, pattern, predicateDescr, aliases);
if (analysis == null) {
// something bad happened
return null;
}
Declaration[][] usedDeclarations = getUsedDeclarations(context, pattern, analysis);
return buildCompilationUnit(context, usedDeclarations[0], usedDeclarations[1], predicateDescr, analysis);
} finally {
context.setDialect(dialect);
}
}
use of org.drools.compiler.lang.descr.PredicateDescr in project drools by kiegroup.
the class PatternBuilder method processAtomicExpression.
protected Constraint processAtomicExpression(RuleBuildContext context, Pattern pattern, BaseDescr d, String expr, Map<String, OperatorDescr> aliases) {
if (d instanceof AtomicExprDescr) {
Matcher m = evalRegexp.matcher(((AtomicExprDescr) d).getExpression());
if (m.find()) {
// MVELDumper already stripped the eval
// this will build the eval using the specified dialect
PredicateDescr pdescr = new PredicateDescr(context.getRuleDescr().getResource(), expr);
pdescr.copyLocation(d);
return buildEval(context, pattern, pdescr, aliases, expr, true);
}
}
return null;
}
use of org.drools.compiler.lang.descr.PredicateDescr in project drools by kiegroup.
the class PatternBuilder method createAndBuildPredicate.
protected Constraint createAndBuildPredicate(RuleBuildContext context, Pattern pattern, BaseDescr base, String expr, Map<String, OperatorDescr> aliases) {
Dialect dialect = context.getDialect();
MVELDialect mvelDialect = (MVELDialect) context.getDialect("mvel");
context.setDialect(mvelDialect);
PredicateDescr pdescr = new PredicateDescr(context.getRuleDescr().getResource(), expr);
pdescr.copyParameters(base);
pdescr.copyLocation(base);
Constraint evalConstraint = buildEval(context, pattern, pdescr, aliases, expr, false);
// fall back to original dialect
context.setDialect(dialect);
return evalConstraint;
}
use of org.drools.compiler.lang.descr.PredicateDescr in project drools by kiegroup.
the class AbstractASMEvalBuilder method build.
public RuleConditionElement build(RuleBuildContext context, BaseDescr descr, Pattern prefixPattern) {
if (prefixPattern == null) {
return build(context, descr);
}
EvalDescr evalDescr = (EvalDescr) descr;
PredicateDescr predicateDescr = new PredicateDescr(context.getRuleDescr().getResource(), evalDescr.getContent());
AnalysisResult analysis = buildAnalysis(context, prefixPattern, predicateDescr, null);
Declaration[] declarations = getUsedDeclarations(context, prefixPattern, analysis);
return buildEval(context, evalDescr, analysis, declarations);
}
Aggregations