Search in sources :

Example 6 with ConditionalElementDescr

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

the class DRL5Parser method lhsExpression.

/**
 * lhsExpression := lhsOr*
 *
 * @param lhs
 * @throws RecognitionException
 */
private void lhsExpression(CEDescrBuilder<?, AndDescr> lhs) throws RecognitionException {
    helper.start(lhs, CEDescrBuilder.class, null);
    if (state.backtracking == 0) {
        helper.emit(Location.LOCATION_LHS_BEGIN_OF_CONDITION);
    }
    try {
        while (input.LA(1) != DRL5Lexer.EOF && !helper.validateIdentifierKey(DroolsSoftKeywords.THEN) && !helper.validateIdentifierKey(DroolsSoftKeywords.END)) {
            if (state.backtracking == 0) {
                helper.emit(Location.LOCATION_LHS_BEGIN_OF_CONDITION);
            }
            lhsOr(lhs, true);
            if (lhs.getDescr() != null && lhs.getDescr() instanceof ConditionalElementDescr) {
                ConditionalElementDescr root = (ConditionalElementDescr) lhs.getDescr();
                BaseDescr[] descrs = root.getDescrs().toArray(new BaseDescr[root.getDescrs().size()]);
                root.getDescrs().clear();
                for (int i = 0; i < descrs.length; i++) {
                    root.addOrMerge(descrs[i]);
                }
            }
            if (state.failed)
                return;
        }
    } finally {
        helper.end(CEDescrBuilder.class, lhs);
    }
}
Also used : BaseDescr(org.drools.compiler.lang.descr.BaseDescr) ConditionalElementDescr(org.drools.compiler.lang.descr.ConditionalElementDescr)

Example 7 with ConditionalElementDescr

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

the class CEDescrBuilderImpl method not.

/**
 * {@inheritDoc}
 */
public CEDescrBuilder<CEDescrBuilder<P, T>, NotDescr> not() {
    CEDescrBuilder<CEDescrBuilder<P, T>, NotDescr> not = new CEDescrBuilderImpl<CEDescrBuilder<P, T>, NotDescr>(this, new NotDescr());
    ((ConditionalElementDescr) descr).addDescr(not.getDescr());
    return not;
}
Also used : NotDescr(org.drools.compiler.lang.descr.NotDescr) CEDescrBuilder(org.drools.compiler.lang.api.CEDescrBuilder) ConditionalElementDescr(org.drools.compiler.lang.descr.ConditionalElementDescr)

Example 8 with ConditionalElementDescr

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

the class CEDescrBuilderImpl method and.

/**
 * {@inheritDoc}
 */
public CEDescrBuilder<CEDescrBuilder<P, T>, AndDescr> and() {
    AndDescr andDescr = new AndDescr();
    ((ConditionalElementDescr) descr).addDescr(andDescr);
    return new CEDescrBuilderImpl<CEDescrBuilder<P, T>, AndDescr>(this, andDescr);
}
Also used : AndDescr(org.drools.compiler.lang.descr.AndDescr) ConditionalElementDescr(org.drools.compiler.lang.descr.ConditionalElementDescr)

Example 9 with ConditionalElementDescr

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

the class CEDescrBuilderImpl method exists.

/**
 * {@inheritDoc}
 */
public CEDescrBuilder<CEDescrBuilder<P, T>, ExistsDescr> exists() {
    CEDescrBuilder<CEDescrBuilder<P, T>, ExistsDescr> exists = new CEDescrBuilderImpl<CEDescrBuilder<P, T>, ExistsDescr>(this, new ExistsDescr());
    ((ConditionalElementDescr) descr).addDescr(exists.getDescr());
    return exists;
}
Also used : CEDescrBuilder(org.drools.compiler.lang.api.CEDescrBuilder) ExistsDescr(org.drools.compiler.lang.descr.ExistsDescr) ConditionalElementDescr(org.drools.compiler.lang.descr.ConditionalElementDescr)

Example 10 with ConditionalElementDescr

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

the class RuleModelDRLPersistenceImpl method parseBaseDescr.

private IPattern parseBaseDescr(final RuleModel m, final BaseDescr descr, final boolean isJavaDialect, final Map<String, String> boundParams, final PackageDataModelOracle dmo) {
    if (descr instanceof PatternDescr) {
        return parsePatternDescr(m, (PatternDescr) descr, isJavaDialect, boundParams, dmo);
    } else if (descr instanceof AndDescr) {
        AndDescr andDescr = (AndDescr) descr;
        return parseBaseDescr(m, andDescr.getDescrs().get(0), isJavaDialect, boundParams, dmo);
    } else if (descr instanceof EvalDescr) {
        FreeFormLine freeFormLine = new FreeFormLine();
        freeFormLine.setText("eval( " + ((EvalDescr) descr).getContent() + " )");
        return freeFormLine;
    } else if (descr instanceof ConditionalElementDescr) {
        return parseExistentialElementDescr(m, (ConditionalElementDescr) descr, isJavaDialect, boundParams, dmo);
    }
    return null;
}
Also used : FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) PatternDescr(org.drools.compiler.lang.descr.PatternDescr) AndDescr(org.drools.compiler.lang.descr.AndDescr) EvalDescr(org.drools.compiler.lang.descr.EvalDescr) ConditionalElementDescr(org.drools.compiler.lang.descr.ConditionalElementDescr)

Aggregations

ConditionalElementDescr (org.drools.compiler.lang.descr.ConditionalElementDescr)20 BaseDescr (org.drools.compiler.lang.descr.BaseDescr)15 AndDescr (org.drools.compiler.lang.descr.AndDescr)11 CEDescrBuilder (org.drools.compiler.lang.api.CEDescrBuilder)5 AnnotatedBaseDescr (org.drools.compiler.lang.descr.AnnotatedBaseDescr)5 OrDescr (org.drools.compiler.lang.descr.OrDescr)4 AccumulateDescrBuilder (org.drools.compiler.lang.api.AccumulateDescrBuilder)3 AnnotatedDescrBuilder (org.drools.compiler.lang.api.AnnotatedDescrBuilder)3 AnnotationDescrBuilder (org.drools.compiler.lang.api.AnnotationDescrBuilder)3 AttributeDescrBuilder (org.drools.compiler.lang.api.AttributeDescrBuilder)3 BehaviorDescrBuilder (org.drools.compiler.lang.api.BehaviorDescrBuilder)3 CollectDescrBuilder (org.drools.compiler.lang.api.CollectDescrBuilder)3 ConditionalBranchDescrBuilder (org.drools.compiler.lang.api.ConditionalBranchDescrBuilder)3 DeclareDescrBuilder (org.drools.compiler.lang.api.DeclareDescrBuilder)3 DescrBuilder (org.drools.compiler.lang.api.DescrBuilder)3 EntryPointDeclarationDescrBuilder (org.drools.compiler.lang.api.EntryPointDeclarationDescrBuilder)3 EnumDeclarationDescrBuilder (org.drools.compiler.lang.api.EnumDeclarationDescrBuilder)3 EnumLiteralDescrBuilder (org.drools.compiler.lang.api.EnumLiteralDescrBuilder)3 EvalDescrBuilder (org.drools.compiler.lang.api.EvalDescrBuilder)3 FieldDescrBuilder (org.drools.compiler.lang.api.FieldDescrBuilder)3