Search in sources :

Example 51 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class FlowAccumulateConstraint method buildPattern.

@Override
public void buildPattern() {
    for (BaseDescr constraint : constraintDescrs) {
        String expression = constraint.toString();
        final DrlxParseResult drlxParseResult = new ConstraintParser(context, packageModel).drlxParse(null, null, expression, false);
        drlxParseResult.accept(success -> {
            success.setSkipThisAsParam(true);
            new FlowExpressionBuilder(context).processExpression(success);
        });
    }
}
Also used : ConstraintParser(org.drools.modelcompiler.builder.generator.drlxparse.ConstraintParser) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) DrlxParseResult(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseResult) FlowExpressionBuilder(org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder)

Example 52 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class FlowDSLPattern method findAllConstraint.

public List<PatternConstraintParseResult> findAllConstraint(PatternDescr pattern, List<? extends BaseDescr> constraintDescrs, Class<?> patternType) {
    final List<PatternConstraintParseResult> patternConstraintParseResults = new ArrayList<>();
    for (BaseDescr constraint : constraintDescrs) {
        final PatternConstraintParseResult patternConstraintParseResult = parseConstraint(pattern, patternType, constraint);
        patternConstraintParseResults.add(patternConstraintParseResult);
    }
    return patternConstraintParseResults;
}
Also used : ArrayList(java.util.ArrayList) BaseDescr(org.drools.compiler.lang.descr.BaseDescr)

Example 53 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class PatternDSL method findAllConstraint.

public List<PatternConstraintParseResult> findAllConstraint(PatternDescr pattern, List<? extends BaseDescr> constraintDescrs, Class<?> patternType) {
    final List<PatternConstraintParseResult> patternConstraintParseResults = new ArrayList<>();
    for (BaseDescr constraint : constraintDescrs) {
        final PatternConstraintParseResult patternConstraintParseResult = parseConstraint(pattern, patternType, constraint);
        patternConstraintParseResults.add(patternConstraintParseResult);
    }
    return patternConstraintParseResults;
}
Also used : ArrayList(java.util.ArrayList) BaseDescr(org.drools.compiler.lang.descr.BaseDescr)

Example 54 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class RuleModelDRLPersistenceImpl method parseConstraint.

private void parseConstraint(final RuleModel m, final FactPattern factPattern, final ConditionalElementDescr constraint, final boolean isJavaDialect, final Map<String, String> boundParams, final PackageDataModelOracle dmo) {
    for (BaseDescr descr : constraint.getDescrs()) {
        if (descr instanceof ExprConstraintDescr) {
            ExprConstraintDescr exprConstraint = (ExprConstraintDescr) descr;
            Expr expr = parseExpr(exprConstraint.getExpression(), isJavaDialect, boundParams, dmo);
            factPattern.addConstraint(expr.asFieldConstraint(m, factPattern));
        }
    }
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) ExprConstraintDescr(org.drools.compiler.lang.descr.ExprConstraintDescr)

Example 55 with BaseDescr

use of org.drools.compiler.lang.descr.BaseDescr in project drools by kiegroup.

the class ExprConstraintDescrVisitor method visit.

private void visit(ConstraintConnectiveDescr descr) {
    switch(descr.getConnective()) {
        case AND:
            solvers.startOperator(OperatorDescrType.AND);
            for (BaseDescr baseDescr : descr.getDescrs()) {
                visit(baseDescr);
            }
            solvers.endOperator();
            break;
        case OR:
            solvers.startOperator(OperatorDescrType.OR);
            for (BaseDescr baseDescr : descr.getDescrs()) {
                visit(baseDescr);
            }
            solvers.endOperator();
            break;
        case XOR:
            // TODO: Generated code -Rikkola-
            break;
        case INC_OR:
            // TODO: Generated code -Rikkola-
            break;
        case INC_AND:
            // TODO: Generated code -Rikkola-
            break;
    }
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr)

Aggregations

BaseDescr (org.drools.compiler.lang.descr.BaseDescr)109 AnnotatedBaseDescr (org.drools.compiler.lang.descr.AnnotatedBaseDescr)60 ConstraintConnectiveDescr (org.drools.compiler.lang.descr.ConstraintConnectiveDescr)23 AtomicExprDescr (org.drools.compiler.lang.descr.AtomicExprDescr)17 ConditionalElementDescr (org.drools.compiler.lang.descr.ConditionalElementDescr)16 BindingDescr (org.drools.compiler.lang.descr.BindingDescr)12 AndDescr (org.drools.compiler.lang.descr.AndDescr)11 RelationalExprDescr (org.drools.compiler.lang.descr.RelationalExprDescr)11 DeclareDescrBuilder (org.drools.compiler.lang.api.DeclareDescrBuilder)9 PatternDescr (org.drools.compiler.lang.descr.PatternDescr)8 OrDescr (org.drools.compiler.lang.descr.OrDescr)7 ArrayList (java.util.ArrayList)6 AccumulateDescrBuilder (org.drools.compiler.lang.api.AccumulateDescrBuilder)6 AnnotatedDescrBuilder (org.drools.compiler.lang.api.AnnotatedDescrBuilder)6 AnnotationDescrBuilder (org.drools.compiler.lang.api.AnnotationDescrBuilder)6 AttributeDescrBuilder (org.drools.compiler.lang.api.AttributeDescrBuilder)6 BehaviorDescrBuilder (org.drools.compiler.lang.api.BehaviorDescrBuilder)6 CEDescrBuilder (org.drools.compiler.lang.api.CEDescrBuilder)6 CollectDescrBuilder (org.drools.compiler.lang.api.CollectDescrBuilder)6 ConditionalBranchDescrBuilder (org.drools.compiler.lang.api.ConditionalBranchDescrBuilder)6