Search in sources :

Example 6 with SingleAccumulate

use of org.drools.core.rule.SingleAccumulate in project drools by kiegroup.

the class JavaAccumulateBuilder method buildInlineAccumulate.

private Accumulate buildInlineAccumulate(final RuleBuildContext context, final AccumulateDescr accumDescr, final RuleConditionElement source, Map<String, Declaration> decls, Map<String, Class<?>> declCls, final boolean readLocalsFromTuple) {
    // ELSE, if it is not an external function, build it using the regular java builder
    final String className = "Accumulate" + context.getNextId();
    accumDescr.setClassName(className);
    BoundIdentifiers available = new BoundIdentifiers(declCls, context);
    final JavaAnalysisResult initCodeAnalysis = (JavaAnalysisResult) context.getDialect().analyzeBlock(context, accumDescr, accumDescr.getInitCode(), available);
    final AnalysisResult actionCodeAnalysis = context.getDialect().analyzeBlock(context, accumDescr, accumDescr.getActionCode(), available);
    final AnalysisResult resultCodeAnalysis = context.getDialect().analyzeExpression(context, accumDescr, accumDescr.getResultCode(), available);
    if (initCodeAnalysis == null || actionCodeAnalysis == null || resultCodeAnalysis == null) {
        // not possible to get the analysis results - compilation error has been already logged
        return null;
    }
    final Set<String> requiredDeclarations = new HashSet<String>(initCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
    requiredDeclarations.addAll(actionCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
    requiredDeclarations.addAll(resultCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
    final Map<String, Class<?>> requiredGlobals = new HashMap<String, Class<?>>(initCodeAnalysis.getBoundIdentifiers().getGlobals());
    requiredGlobals.putAll(actionCodeAnalysis.getBoundIdentifiers().getGlobals());
    requiredGlobals.putAll(resultCodeAnalysis.getBoundIdentifiers().getGlobals());
    if (accumDescr.getReverseCode() != null) {
        final AnalysisResult reverseCodeAnalysis = context.getDialect().analyzeBlock(context, accumDescr, accumDescr.getActionCode(), available);
        requiredDeclarations.addAll(reverseCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
        requiredGlobals.putAll(reverseCodeAnalysis.getBoundIdentifiers().getGlobals());
    }
    final Declaration[] declarations = new Declaration[requiredDeclarations.size()];
    int i = 0;
    for (Iterator<String> it = requiredDeclarations.iterator(); it.hasNext(); i++) {
        declarations[i] = decls.get(it.next());
    }
    final Declaration[] sourceDeclArr = source.getOuterDeclarations().values().toArray(new Declaration[source.getOuterDeclarations().size()]);
    Arrays.sort(sourceDeclArr, RuleTerminalNode.SortDeclarations.instance);
    final Map<String, Object> map = createVariableContext(className, null, context, declarations, null, requiredGlobals);
    map.put("className", accumDescr.getClassName());
    map.put("innerDeclarations", sourceDeclArr);
    map.put("isMultiPattern", readLocalsFromTuple ? Boolean.TRUE : Boolean.FALSE);
    final String initCode = this.fixInitCode(initCodeAnalysis, accumDescr.getInitCode());
    final String actionCode = accumDescr.getActionCode();
    final String resultCode = accumDescr.getResultCode();
    String[] attributesTypes = new String[initCodeAnalysis.getLocalVariablesMap().size()];
    String[] attributes = new String[initCodeAnalysis.getLocalVariablesMap().size()];
    int index = 0;
    for (Map.Entry<String, JavaLocalDeclarationDescr> entry : initCodeAnalysis.getLocalVariablesMap().entrySet()) {
        attributes[index] = entry.getKey();
        attributesTypes[index] = entry.getValue().getType();
        index++;
    }
    map.put("attributes", attributes);
    map.put("attributesTypes", attributesTypes);
    map.put("initCode", initCode);
    map.put("actionCode", actionCode);
    map.put("resultCode", resultCode);
    if (accumDescr.getReverseCode() == null) {
        map.put("reverseCode", "");
        map.put("supportsReverse", "false");
    } else {
        map.put("reverseCode", accumDescr.getReverseCode());
        map.put("supportsReverse", "true");
    }
    map.put("hashCode", actionCode.hashCode());
    SingleAccumulate accumulate = new SingleAccumulate(source, declarations);
    generateTemplates("accumulateInnerClass", "accumulateInvoker", context, className, map, accumulate.new Wirer(), accumDescr);
    return accumulate;
}
Also used : HashMap(java.util.HashMap) SingleAccumulate(org.drools.core.rule.SingleAccumulate) AnalysisResult(org.drools.compiler.compiler.AnalysisResult) MutableTypeConstraint(org.drools.core.rule.MutableTypeConstraint) MvelConstraint(org.drools.core.rule.constraint.MvelConstraint) Constraint(org.drools.core.spi.Constraint) BoundIdentifiers(org.drools.compiler.compiler.BoundIdentifiers) JavaLocalDeclarationDescr(org.drools.compiler.rule.builder.dialect.java.parser.JavaLocalDeclarationDescr) Declaration(org.drools.core.rule.Declaration) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 7 with SingleAccumulate

use of org.drools.core.rule.SingleAccumulate in project drools by kiegroup.

the class JavaAccumulateBuilder method buildExternalFunctionCall.

private Accumulate buildExternalFunctionCall(RuleBuildContext context, AccumulateDescr accumDescr, RuleConditionElement source, Map<String, Declaration> declsInScope, Map<String, Class<?>> declCls, boolean readLocalsFromTuple) {
    // list of functions to build
    final List<AccumulateFunctionCallDescr> funcCalls = accumDescr.getFunctions();
    // list of available source declarations
    final Declaration[] sourceDeclArr = source.getOuterDeclarations().values().toArray(new Declaration[source.getOuterDeclarations().size()]);
    Arrays.sort(sourceDeclArr, RuleTerminalNode.SortDeclarations.instance);
    // set of required previous declarations
    Set<Declaration> requiredDecl = new HashSet<Declaration>();
    Pattern pattern = (Pattern) context.getDeclarationResolver().peekBuildStack();
    if (accumDescr.isMultiFunction()) {
        // the accumulator array
        Accumulator[] accumulators = new Accumulator[funcCalls.size()];
        // creating the custom array reader
        InternalReadAccessor reader = new SelfReferenceClassFieldReader(Object[].class);
        int index = 0;
        for (AccumulateFunctionCallDescr fc : funcCalls) {
            AccumulateFunction function = getAccumulateFunction(context, accumDescr, fc, source, declCls);
            if (function == null) {
                return null;
            }
            bindReaderToDeclaration(context, accumDescr, pattern, fc, new ArrayElementReader(reader, index, function.getResultType()), function.getResultType(), index);
            accumulators[index++] = buildAccumulator(context, accumDescr, declsInScope, declCls, readLocalsFromTuple, sourceDeclArr, requiredDecl, fc, function);
        }
        return new MultiAccumulate(source, requiredDecl.toArray(new Declaration[requiredDecl.size()]), accumulators);
    } else {
        AccumulateFunctionCallDescr fc = accumDescr.getFunctions().get(0);
        AccumulateFunction function = getAccumulateFunction(context, accumDescr, fc, source, declCls);
        if (function == null) {
            return null;
        }
        Class<?> returnType = function.getResultType();
        if (!pattern.isCompatibleWithAccumulateReturnType(returnType)) {
            context.addError(new DescrBuildError(accumDescr, context.getRuleDescr(), null, "Pattern of type: '" + pattern.getObjectType() + "' on rule '" + context.getRuleDescr().getName() + "' is not compatible with type " + returnType.getCanonicalName() + " returned by accumulate function."));
            return null;
        }
        bindReaderToDeclaration(context, accumDescr, pattern, fc, new SelfReferenceClassFieldReader(function.getResultType()), function.getResultType(), -1);
        Accumulator accumulator = buildAccumulator(context, accumDescr, declsInScope, declCls, readLocalsFromTuple, sourceDeclArr, requiredDecl, fc, function);
        return new SingleAccumulate(source, requiredDecl.toArray(new Declaration[requiredDecl.size()]), accumulator);
    }
}
Also used : Accumulator(org.drools.core.spi.Accumulator) Pattern(org.drools.core.rule.Pattern) MultiAccumulate(org.drools.core.rule.MultiAccumulate) SingleAccumulate(org.drools.core.rule.SingleAccumulate) MutableTypeConstraint(org.drools.core.rule.MutableTypeConstraint) MvelConstraint(org.drools.core.rule.constraint.MvelConstraint) Constraint(org.drools.core.spi.Constraint) DescrBuildError(org.drools.compiler.compiler.DescrBuildError) SelfReferenceClassFieldReader(org.drools.core.base.extractors.SelfReferenceClassFieldReader) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor) AccumulateFunctionCallDescr(org.drools.compiler.lang.descr.AccumulateDescr.AccumulateFunctionCallDescr) ArrayElementReader(org.drools.core.base.extractors.ArrayElementReader) Declaration(org.drools.core.rule.Declaration) AccumulateFunction(org.kie.api.runtime.rule.AccumulateFunction) HashSet(java.util.HashSet)

Example 8 with SingleAccumulate

use of org.drools.core.rule.SingleAccumulate in project drools by kiegroup.

the class JavaAccumulateBuilder method buildInlineAccumulate.

private Accumulate buildInlineAccumulate(final RuleBuildContext context, final AccumulateDescr accumDescr, final RuleConditionElement source, Map<String, Declaration> decls, Map<String, Class<?>> declCls, final boolean readLocalsFromTuple) {
    // ELSE, if it is not an external function, build it using the regular java builder
    final String className = "Accumulate" + context.getNextId();
    accumDescr.setClassName(className);
    BoundIdentifiers available = new BoundIdentifiers(declCls, context);
    final JavaAnalysisResult initCodeAnalysis = (JavaAnalysisResult) context.getDialect().analyzeBlock(context, accumDescr, accumDescr.getInitCode(), available);
    final AnalysisResult actionCodeAnalysis = context.getDialect().analyzeBlock(context, accumDescr, accumDescr.getActionCode(), available);
    final AnalysisResult resultCodeAnalysis = context.getDialect().analyzeExpression(context, accumDescr, accumDescr.getResultCode(), available);
    if (initCodeAnalysis == null || actionCodeAnalysis == null || resultCodeAnalysis == null) {
        // not possible to get the analysis results - compilation error has been already logged
        return null;
    }
    final Set<String> requiredDeclarations = new HashSet<String>(initCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
    requiredDeclarations.addAll(actionCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
    requiredDeclarations.addAll(resultCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
    final Map<String, Class<?>> requiredGlobals = new HashMap<String, Class<?>>(initCodeAnalysis.getBoundIdentifiers().getGlobals());
    requiredGlobals.putAll(actionCodeAnalysis.getBoundIdentifiers().getGlobals());
    requiredGlobals.putAll(resultCodeAnalysis.getBoundIdentifiers().getGlobals());
    if (accumDescr.getReverseCode() != null) {
        final AnalysisResult reverseCodeAnalysis = context.getDialect().analyzeBlock(context, accumDescr, accumDescr.getActionCode(), available);
        requiredDeclarations.addAll(reverseCodeAnalysis.getBoundIdentifiers().getDeclrClasses().keySet());
        requiredGlobals.putAll(reverseCodeAnalysis.getBoundIdentifiers().getGlobals());
    }
    final Declaration[] declarations = new Declaration[requiredDeclarations.size()];
    int i = 0;
    for (Iterator<String> it = requiredDeclarations.iterator(); it.hasNext(); i++) {
        declarations[i] = decls.get(it.next());
    }
    final Declaration[] sourceDeclArr = source.getOuterDeclarations().values().toArray(new Declaration[source.getOuterDeclarations().size()]);
    Arrays.sort(sourceDeclArr, RuleTerminalNode.SortDeclarations.instance);
    final Map<String, Object> map = createVariableContext(className, null, context, declarations, null, requiredGlobals);
    map.put("className", accumDescr.getClassName());
    map.put("innerDeclarations", sourceDeclArr);
    map.put("isMultiPattern", readLocalsFromTuple ? Boolean.TRUE : Boolean.FALSE);
    final String initCode = this.fixInitCode(initCodeAnalysis, accumDescr.getInitCode());
    final String actionCode = accumDescr.getActionCode();
    final String resultCode = accumDescr.getResultCode();
    String[] attributesTypes = new String[initCodeAnalysis.getLocalVariablesMap().size()];
    String[] attributes = new String[initCodeAnalysis.getLocalVariablesMap().size()];
    int index = 0;
    for (Map.Entry<String, JavaLocalDeclarationDescr> entry : initCodeAnalysis.getLocalVariablesMap().entrySet()) {
        attributes[index] = entry.getKey();
        attributesTypes[index] = entry.getValue().getType();
        index++;
    }
    map.put("attributes", attributes);
    map.put("attributesTypes", attributesTypes);
    map.put("initCode", initCode);
    map.put("actionCode", actionCode);
    map.put("resultCode", resultCode);
    if (accumDescr.getReverseCode() == null) {
        map.put("reverseCode", "");
        map.put("supportsReverse", "false");
    } else {
        map.put("reverseCode", accumDescr.getReverseCode());
        map.put("supportsReverse", "true");
    }
    map.put("hashCode", actionCode.hashCode());
    SingleAccumulate accumulate = new SingleAccumulate(source, declarations);
    generateTemplates("accumulateInnerClass", "accumulateInvoker", context, className, map, accumulate.new Wirer(), accumDescr);
    return accumulate;
}
Also used : HashMap(java.util.HashMap) SingleAccumulate(org.drools.core.rule.SingleAccumulate) AnalysisResult(org.drools.compiler.compiler.AnalysisResult) MutableTypeConstraint(org.drools.core.rule.MutableTypeConstraint) MVELConstraint(org.drools.mvel.MVELConstraint) Constraint(org.drools.core.spi.Constraint) BoundIdentifiers(org.drools.compiler.compiler.BoundIdentifiers) JavaLocalDeclarationDescr(org.drools.compiler.rule.builder.dialect.java.parser.JavaLocalDeclarationDescr) Declaration(org.drools.core.rule.Declaration) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Example 9 with SingleAccumulate

use of org.drools.core.rule.SingleAccumulate in project drools by kiegroup.

the class MVELAccumulateBuilder method build.

@SuppressWarnings("unchecked")
public RuleConditionElement build(final RuleBuildContext context, final BaseDescr descr, final Pattern prefixPattern) {
    boolean typesafe = context.isTypesafe();
    try {
        final AccumulateDescr accumDescr = (AccumulateDescr) descr;
        if (!accumDescr.hasValidInput()) {
            return null;
        }
        final RuleConditionBuilder builder = (RuleConditionBuilder) context.getDialect().getBuilder(accumDescr.getInput().getClass());
        // create source CE
        final RuleConditionElement source = builder.build(context, accumDescr.getInput());
        if (source == null) {
            return null;
        }
        MVELDialect dialect = (MVELDialect) context.getDialect();
        Map<String, Declaration> decls = context.getDeclarationResolver().getDeclarations(context.getRule());
        Map<String, Declaration> sourceOuterDeclr = source.getOuterDeclarations();
        Map<String, Class<?>> declarationClasses = DeclarationScopeResolver.getDeclarationClasses(decls);
        declarationClasses.putAll(DeclarationScopeResolver.getDeclarationClasses(sourceOuterDeclr));
        BoundIdentifiers boundIds = new BoundIdentifiers(declarationClasses, context);
        final boolean readLocalsFromTuple = PackageBuilderUtil.isReadLocalsFromTuple(context, accumDescr, source);
        Accumulator[] accumulators;
        if (accumDescr.isExternalFunction()) {
            // uses accumulate functions
            accumulators = buildExternalFunctions(context, accumDescr, dialect, decls, sourceOuterDeclr, boundIds, readLocalsFromTuple, source, declarationClasses);
        } else {
            // it is a custom accumulate
            accumulators = buildCustomAccumulate(context, accumDescr, dialect, decls, sourceOuterDeclr, boundIds, readLocalsFromTuple);
        }
        List<Declaration> requiredDeclarations = new ArrayList<Declaration>();
        for (Accumulator acc : accumulators) {
            MvelAccumulator mvelAcc = (MvelAccumulator) acc;
            Collections.addAll(requiredDeclarations, mvelAcc.getRequiredDeclarations());
        }
        MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData("mvel");
        Accumulate accumulate;
        if (accumDescr.isMultiFunction()) {
            accumulate = new MultiAccumulate(source, requiredDeclarations.toArray(new Declaration[requiredDeclarations.size()]), accumulators, accumulators.length);
            int index = 0;
            for (Accumulator accumulator : accumulators) {
                data.addCompileable(((MultiAccumulate) accumulate).new Wirer(index++), (MVELCompileable) accumulator);
                ((MVELCompileable) accumulator).compile(data, context.getRule());
            }
        } else {
            accumulate = new SingleAccumulate(source, requiredDeclarations.toArray(new Declaration[requiredDeclarations.size()]), accumulators[0]);
            data.addCompileable(((SingleAccumulate) accumulate).new Wirer(), (MVELCompileable) accumulators[0]);
            ((MVELCompileable) accumulators[0]).compile(data, context.getRule());
        }
        return accumulate;
    } catch (Exception e) {
        AsmUtil.copyErrorLocation(e, descr);
        context.addError(new DescrBuildError(context.getParentDescr(), descr, e, "Unable to build expression for 'accumulate' : " + e.getMessage()));
        return null;
    } finally {
        context.setTypesafe(typesafe);
    }
}
Also used : Accumulator(org.drools.core.spi.Accumulator) MVELAccumulator(org.drools.mvel.expr.MVELAccumulator) MvelAccumulator(org.drools.core.spi.MvelAccumulator) MVELCompileable(org.drools.mvel.expr.MVELCompileable) ArrayList(java.util.ArrayList) AccumulateDescr(org.drools.drl.ast.descr.AccumulateDescr) MultiAccumulate(org.drools.core.rule.MultiAccumulate) SingleAccumulate(org.drools.core.rule.SingleAccumulate) Accumulate(org.drools.core.rule.Accumulate) MVELDialectRuntimeData(org.drools.mvel.MVELDialectRuntimeData) Declaration(org.drools.core.rule.Declaration) MultiAccumulate(org.drools.core.rule.MultiAccumulate) RuleConditionBuilder(org.drools.compiler.rule.builder.RuleConditionBuilder) RuleConditionElement(org.drools.core.rule.RuleConditionElement) SingleAccumulate(org.drools.core.rule.SingleAccumulate) MutableTypeConstraint(org.drools.core.rule.MutableTypeConstraint) MVELConstraint(org.drools.mvel.MVELConstraint) Constraint(org.drools.core.spi.Constraint) BoundIdentifiers(org.drools.compiler.compiler.BoundIdentifiers) DescrBuildError(org.drools.compiler.compiler.DescrBuildError) MvelAccumulator(org.drools.core.spi.MvelAccumulator)

Example 10 with SingleAccumulate

use of org.drools.core.rule.SingleAccumulate in project drools by kiegroup.

the class KiePackagesBuilder method addPatternForVariable.

private Pattern addPatternForVariable(RuleContext ctx, GroupElement group, Variable patternVariable, Condition.Type type) {
    Pattern pattern = null;
    // If the variable is already bound to the result of previous accumulate result pattern, then find it.
    if (patternVariable instanceof org.drools.model.Declaration) {
        org.drools.model.Declaration decl = (org.drools.model.Declaration) patternVariable;
        if (decl.getSource() == null) {
            Accumulate accSource = ctx.getAccumulateSource(patternVariable);
            if (accSource != null) {
                for (RuleConditionElement element : group.getChildren()) {
                    if (element instanceof Pattern && ((Pattern) element).getSource() == accSource) {
                        pattern = (Pattern) element;
                        break;
                    }
                }
            }
        }
    }
    PatternSource priorSource = null;
    if (pattern != null && type == Condition.Type.ACCUMULATE) {
        // so it would be potentially tricky if this was a multi var, with multiple bindings.
        if (pattern.getSource() instanceof SingleAccumulate) {
            group.getChildren().remove(pattern);
            priorSource = pattern.getSource();
            pattern = null;
        }
    }
    if (pattern == null) {
        pattern = new Pattern(ctx.getNextPatternIndex(), // tupleIndex will be set by ReteooBuilder
        0, // tupleIndex will be set by ReteooBuilder
        0, getObjectType(patternVariable), patternVariable.getName(), true);
        pattern.setSource(priorSource);
    }
    if (patternVariable instanceof org.drools.model.Declaration) {
        org.drools.model.Declaration decl = (org.drools.model.Declaration) patternVariable;
        if (decl.getSource() != null) {
            if (decl.getSource() instanceof EntryPoint) {
                pattern.setSource(new EntryPointId(((EntryPoint) decl.getSource()).getName()));
            } else if (decl.getSource() instanceof WindowReference) {
                WindowReference<?> window = (WindowReference) decl.getSource();
                if (!ctx.getPkg().getWindowDeclarations().containsKey(window.getName())) {
                    createWindowReference(ctx, window);
                }
                pattern.setSource(new org.drools.core.rule.WindowReference(window.getName()));
            } else if (decl.getSource() instanceof From) {
                pattern.setSource(buildFrom(ctx, pattern, (From) decl.getSource()));
            } else if (decl.getSource() instanceof UnitData) {
                UnitData unitData = (UnitData) decl.getSource();
                pattern.setSource(new EntryPointId(ctx.getRule().getRuleUnitClassName() + "." + unitData.getName()));
            } else {
                throw new UnsupportedOperationException("Unknown source: " + decl.getSource());
            }
        }
        if (decl.getWindow() != null) {
            pattern.addBehavior(createWindow(decl.getWindow()));
            ctx.setNeedStreamMode();
        }
    } else if (patternVariable instanceof Exchange) {
        if (type == Condition.Type.SENDER) {
            Function0 supplier = ((Exchange) patternVariable).getMessageSupplier();
            DataProvider provider = new LambdaDataProvider(x -> supplier.apply(), false);
            pattern.setSource(new AsyncSend(pattern, patternVariable.getName(), provider));
        } else if (type == Condition.Type.RECEIVER) {
            pattern.setSource(new AsyncReceive(pattern, patternVariable.getName()));
        } else {
            throw new UnsupportedOperationException();
        }
    }
    ctx.registerPattern(patternVariable, pattern);
    return pattern;
}
Also used : GroupByPatternImpl(org.drools.model.patterns.GroupByPatternImpl) Arrays(java.util.Arrays) AsyncReceive(org.drools.core.rule.AsyncReceive) FunctionUtils.toFunctionN(org.drools.model.functions.FunctionUtils.toFunctionN) Binding(org.drools.model.Binding) CoreComponentFactory(org.drools.core.reteoo.CoreComponentFactory) SingleConstraint(org.drools.model.SingleConstraint) QueryCallPattern(org.drools.model.patterns.QueryCallPattern) PatternImpl(org.drools.model.patterns.PatternImpl) PatternSource(org.drools.core.rule.PatternSource) Map(java.util.Map) Declaration(org.drools.core.rule.Declaration) NamesGenerator.generateName(org.drools.model.impl.NamesGenerator.generateName) LambdaGroupByAccumulate(org.drools.modelcompiler.constraints.LambdaGroupByAccumulate) QueryNameConstraint(org.drools.core.rule.constraint.QueryNameConstraint) ConditionalElement(org.drools.core.rule.ConditionalElement) QueryImpl(org.drools.core.rule.QueryImpl) LambdaConstraint(org.drools.modelcompiler.constraints.LambdaConstraint) Direct(org.kie.api.definition.rule.Direct) EvaluationUtil.adaptBitMask(org.drools.modelcompiler.util.EvaluationUtil.adaptBitMask) TimerUtil.buildTimerExpression(org.drools.modelcompiler.util.TimerUtil.buildTimerExpression) CompositePatterns(org.drools.model.patterns.CompositePatterns) Set(java.util.Set) Predicate1(org.drools.model.functions.Predicate1) Exchange(org.drools.model.impl.Exchange) Query(org.drools.model.Query) Stream(java.util.stream.Stream) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl) FactTemplateObjectType(org.drools.core.facttemplates.FactTemplateObjectType) LambdaAccumulator(org.drools.modelcompiler.constraints.LambdaAccumulator) CountAccumulateFunction(org.drools.core.base.accumulators.CountAccumulateFunction) AccumulatePattern(org.drools.model.AccumulatePattern) DomainClassMetadata(org.drools.model.DomainClassMetadata) LambdaDataProvider(org.drools.modelcompiler.constraints.LambdaDataProvider) SelfPatternBiding(org.drools.model.view.SelfPatternBiding) Enabled(org.drools.core.spi.Enabled) ObjectType(org.drools.core.spi.ObjectType) EntryPointId(org.drools.core.rule.EntryPointId) All(org.kie.api.definition.rule.All) TypeMetaData(org.drools.model.TypeMetaData) ArrayList(java.util.ArrayList) UnificationConstraint(org.drools.modelcompiler.constraints.UnificationConstraint) BitMaskUtil.calculatePatternMask(org.drools.model.bitmask.BitMaskUtil.calculatePatternMask) RuleUnitUtil(org.kie.internal.ruleunit.RuleUnitUtil) LinkedHashSet(java.util.LinkedHashSet) EntryPoint(org.drools.model.EntryPoint) QueryElement(org.drools.core.rule.QueryElement) RuleConditionElement(org.drools.core.rule.RuleConditionElement) WindowDeclaration(org.drools.core.rule.WindowDeclaration) SelfReferenceClassFieldReader(org.drools.core.base.extractors.SelfReferenceClassFieldReader) LambdaConsequence(org.drools.modelcompiler.consequence.LambdaConsequence) PatternExtractor(org.drools.core.spi.PatternExtractor) NamedConsequenceImpl(org.drools.model.consequences.NamedConsequenceImpl) TemporalConstraintEvaluator(org.drools.modelcompiler.constraints.TemporalConstraintEvaluator) Rule(org.drools.model.Rule) DataProvider(org.drools.core.spi.DataProvider) PropertySpecificOption(org.kie.internal.builder.conf.PropertySpecificOption) BindingEvaluator(org.drools.modelcompiler.constraints.BindingEvaluator) EvalCondition(org.drools.core.rule.EvalCondition) TypeDeclarationUtil.createTypeDeclaration(org.drools.modelcompiler.util.TypeDeclarationUtil.createTypeDeclaration) EnabledBoolean(org.drools.core.base.EnabledBoolean) TypeDeclaration(org.drools.core.rule.TypeDeclaration) Accumulator(org.drools.core.spi.Accumulator) PrototypeVariable(org.drools.model.PrototypeVariable) Consequence(org.drools.model.Consequence) Global(org.drools.model.Global) WindowReference(org.drools.model.WindowReference) DroolsQuery(org.drools.core.base.DroolsQuery) UnitData(org.drools.model.UnitData) DynamicValueSupplier(org.drools.model.DynamicValueSupplier) ExistentialPatternImpl(org.drools.model.patterns.ExistentialPatternImpl) NamedConsequence(org.drools.core.rule.NamedConsequence) AbstractConstraint(org.drools.modelcompiler.constraints.AbstractConstraint) InternalKnowledgePackage(org.drools.core.definitions.InternalKnowledgePackage) Value(org.drools.model.Value) FactFactory.prototypeToFactTemplate(org.drools.modelcompiler.facttemplate.FactFactory.prototypeToFactTemplate) Condition(org.drools.model.Condition) Constraint(org.drools.model.Constraint) Collection(java.util.Collection) Forall(org.drools.core.rule.Forall) SlidingTimeWindow(org.drools.core.rule.SlidingTimeWindow) Index(org.drools.model.Index) LambdaEvalExpression(org.drools.modelcompiler.constraints.LambdaEvalExpression) Collectors(java.util.stream.Collectors) RuleBuilder.buildTimer(org.drools.compiler.rule.builder.RuleBuilder.buildTimer) List(java.util.List) SingleConstraint1(org.drools.model.constraints.SingleConstraint1) Entry(java.util.Map.Entry) Optional(java.util.Optional) BindingInnerObjectEvaluator(org.drools.modelcompiler.constraints.BindingInnerObjectEvaluator) SlidingLengthWindow(org.drools.core.rule.SlidingLengthWindow) Role(org.kie.api.definition.type.Role) ConstraintEvaluator(org.drools.modelcompiler.constraints.ConstraintEvaluator) OR(org.drools.core.rule.GroupElement.OR) LambdaSalience(org.drools.modelcompiler.attributes.LambdaSalience) CombinedConstraint(org.drools.modelcompiler.constraints.CombinedConstraint) KieBaseConfiguration(org.kie.api.KieBaseConfiguration) ClassObjectType(org.drools.core.base.ClassObjectType) Prototype(org.drools.model.Prototype) ClassFieldAccessorCache(org.drools.core.base.ClassFieldAccessorCache) Pattern(org.drools.core.rule.Pattern) InternalReadAccessor(org.drools.core.spi.InternalReadAccessor) HashMap(java.util.HashMap) AsyncSend(org.drools.core.rule.AsyncSend) Behavior(org.drools.core.rule.Behavior) AbstractSingleConstraint(org.drools.model.constraints.AbstractSingleConstraint) AND(org.drools.core.rule.GroupElement.AND) GroupByPattern(org.drools.model.GroupByPattern) View(org.drools.model.View) Function0(org.drools.model.functions.Function0) EvalImpl(org.drools.model.patterns.EvalImpl) LambdaReadAccessor(org.drools.modelcompiler.constraints.LambdaReadAccessor) Function1(org.drools.model.functions.Function1) KnowledgeBuilderConfigurationImpl(org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl) WindowDefinition(org.drools.model.WindowDefinition) RuleBaseConfiguration(org.drools.core.RuleBaseConfiguration) From0(org.drools.model.From0) From1(org.drools.model.From1) EvalExpression(org.drools.core.spi.EvalExpression) KnowledgePackageImpl(org.drools.core.definitions.impl.KnowledgePackageImpl) From(org.drools.model.From) From4(org.drools.model.From4) From2(org.drools.model.From2) Model(org.drools.model.Model) From3(org.drools.model.From3) MultiAccumulate(org.drools.core.rule.MultiAccumulate) Salience(org.drools.core.spi.Salience) Variable(org.drools.model.Variable) ArrayElementReader(org.drools.core.base.extractors.ArrayElementReader) KnowledgeBuilderConfiguration(org.kie.internal.builder.KnowledgeBuilderConfiguration) Propagation(org.kie.api.definition.rule.Propagation) Consumer(java.util.function.Consumer) DSL.entryPoint(org.drools.model.DSL.entryPoint) QueryArgument(org.drools.core.rule.QueryArgument) Collectors.toList(java.util.stream.Collectors.toList) SingleAccumulate(org.drools.core.rule.SingleAccumulate) SalienceInteger(org.drools.core.base.SalienceInteger) Accumulate(org.drools.core.rule.Accumulate) ConditionalNamedConsequenceImpl(org.drools.model.consequences.ConditionalNamedConsequenceImpl) Collections(java.util.Collections) DSL.declarationOf(org.drools.model.DSL.declarationOf) ConditionalBranch(org.drools.core.rule.ConditionalBranch) AccumulateFunction(org.drools.model.functions.accumulate.AccumulateFunction) LambdaEnabled(org.drools.modelcompiler.attributes.LambdaEnabled) GroupElement(org.drools.core.rule.GroupElement) Argument(org.drools.model.Argument) DeclarationImpl(org.drools.model.impl.DeclarationImpl) QueryCallPattern(org.drools.model.patterns.QueryCallPattern) AccumulatePattern(org.drools.model.AccumulatePattern) Pattern(org.drools.core.rule.Pattern) GroupByPattern(org.drools.model.GroupByPattern) AsyncReceive(org.drools.core.rule.AsyncReceive) EntryPoint(org.drools.model.EntryPoint) Function0(org.drools.model.functions.Function0) RuleConditionElement(org.drools.core.rule.RuleConditionElement) From(org.drools.model.From) AsyncSend(org.drools.core.rule.AsyncSend) SingleAccumulate(org.drools.core.rule.SingleAccumulate) LambdaGroupByAccumulate(org.drools.modelcompiler.constraints.LambdaGroupByAccumulate) MultiAccumulate(org.drools.core.rule.MultiAccumulate) SingleAccumulate(org.drools.core.rule.SingleAccumulate) Accumulate(org.drools.core.rule.Accumulate) WindowReference(org.drools.model.WindowReference) UnitData(org.drools.model.UnitData) Exchange(org.drools.model.impl.Exchange) LambdaDataProvider(org.drools.modelcompiler.constraints.LambdaDataProvider) DataProvider(org.drools.core.spi.DataProvider) EntryPointId(org.drools.core.rule.EntryPointId) LambdaDataProvider(org.drools.modelcompiler.constraints.LambdaDataProvider) PatternSource(org.drools.core.rule.PatternSource) Declaration(org.drools.core.rule.Declaration) WindowDeclaration(org.drools.core.rule.WindowDeclaration) TypeDeclarationUtil.createTypeDeclaration(org.drools.modelcompiler.util.TypeDeclarationUtil.createTypeDeclaration) TypeDeclaration(org.drools.core.rule.TypeDeclaration)

Aggregations

SingleAccumulate (org.drools.core.rule.SingleAccumulate)10 Declaration (org.drools.core.rule.Declaration)9 MultiAccumulate (org.drools.core.rule.MultiAccumulate)7 Accumulator (org.drools.core.spi.Accumulator)7 Accumulate (org.drools.core.rule.Accumulate)6 MutableTypeConstraint (org.drools.core.rule.MutableTypeConstraint)6 Constraint (org.drools.core.spi.Constraint)6 ArrayList (java.util.ArrayList)5 ArrayElementReader (org.drools.core.base.extractors.ArrayElementReader)5 SelfReferenceClassFieldReader (org.drools.core.base.extractors.SelfReferenceClassFieldReader)5 Pattern (org.drools.core.rule.Pattern)5 InternalReadAccessor (org.drools.core.spi.InternalReadAccessor)5 HashSet (java.util.HashSet)4 BoundIdentifiers (org.drools.compiler.compiler.BoundIdentifiers)4 DescrBuildError (org.drools.compiler.compiler.DescrBuildError)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 RuleConditionElement (org.drools.core.rule.RuleConditionElement)3 MvelConstraint (org.drools.core.rule.constraint.MvelConstraint)3 AnalysisResult (org.drools.compiler.compiler.AnalysisResult)2