Search in sources :

Example 1 with GENERATED_VARIABLE_PREFIX

use of org.drools.model.impl.VariableImpl.GENERATED_VARIABLE_PREFIX in project drools by kiegroup.

the class PatternDSL method generatePatternIdentifierIfMissing.

private void generatePatternIdentifierIfMissing() {
    if (pattern.getIdentifier() == null) {
        final String generatedName = generateName("pattern_" + patternType.getSimpleName());
        final String patternNameAggregated = findFirstInnerBinding(constraintDescrs, patternType).map(ib -> context.getAggregatePatternMap().putIfAbsent(new AggregateKey(ib, patternType), generatedName)).orElse(generatedName);
        pattern.setIdentifier(GENERATED_VARIABLE_PREFIX + patternNameAggregated);
    }
}
Also used : DrlxParseUtil.validateDuplicateBindings(org.drools.modelcompiler.builder.generator.DrlxParseUtil.validateDuplicateBindings) DrlxParseResult(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseResult) AggregateKey(org.drools.modelcompiler.builder.generator.AggregateKey) DrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseSuccess) PrintUtil.printNode(org.drools.mvel.parser.printer.PrintUtil.printNode) PatternSourceDescr(org.drools.drl.ast.descr.PatternSourceDescr) DeclarationSpec(org.drools.modelcompiler.builder.generator.DeclarationSpec) DescrBuildError(org.drools.compiler.compiler.DescrBuildError) DrlxParseUtil(org.drools.modelcompiler.builder.generator.DrlxParseUtil) ConstraintExpression(org.drools.modelcompiler.builder.generator.drlxparse.ConstraintExpression) DrlxParseUtil.getPatternListenedProperties(org.drools.modelcompiler.builder.generator.DrlxParseUtil.getPatternListenedProperties) PatternDescr(org.drools.drl.ast.descr.PatternDescr) InvalidExpressionErrorResult(org.drools.modelcompiler.builder.errors.InvalidExpressionErrorResult) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) GENERATED_VARIABLE_PREFIX(org.drools.model.impl.VariableImpl.GENERATED_VARIABLE_PREFIX) ConstraintUtil(org.drools.modelcompiler.builder.generator.ConstraintUtil) AccumulateDescr(org.drools.drl.ast.descr.AccumulateDescr) NamesGenerator.generateName(org.drools.model.impl.NamesGenerator.generateName) Expression(com.github.javaparser.ast.expr.Expression) ConstraintParser(org.drools.modelcompiler.builder.generator.drlxparse.ConstraintParser) BinaryExpr(com.github.javaparser.ast.expr.BinaryExpr) ExprConstraintDescr(org.drools.drl.ast.descr.ExprConstraintDescr) PackageModel(org.drools.modelcompiler.builder.PackageModel) WindowReferenceGenerator(org.drools.modelcompiler.builder.generator.WindowReferenceGenerator) ClassUtils(org.drools.core.util.ClassUtils) Collection(java.util.Collection) MethodCallExpr(com.github.javaparser.ast.expr.MethodCallExpr) Set(java.util.Set) PatternBuilder.lookAheadFieldsOfIdentifier(org.drools.compiler.rule.builder.PatternBuilder.lookAheadFieldsOfIdentifier) StreamUtils.optionalToStream(org.drools.modelcompiler.util.StreamUtils.optionalToStream) FromVisitor(org.drools.modelcompiler.builder.generator.visitor.FromVisitor) Collectors(java.util.stream.Collectors) BaseDescr(org.drools.drl.ast.descr.BaseDescr) Objects(java.util.Objects) RuleContext(org.drools.modelcompiler.builder.generator.RuleContext) List(java.util.List) SingleDrlxParseSuccess(org.drools.modelcompiler.builder.generator.drlxparse.SingleDrlxParseSuccess) DSLNode(org.drools.modelcompiler.builder.generator.visitor.DSLNode) ParseResultVoidVisitor(org.drools.modelcompiler.builder.generator.drlxparse.ParseResultVoidVisitor) Watch(org.kie.api.definition.rule.Watch) Optional(java.util.Optional) ParseResultVisitor(org.drools.modelcompiler.builder.generator.drlxparse.ParseResultVisitor) Collections(java.util.Collections) DrlxParseFail(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseFail) AggregateKey(org.drools.modelcompiler.builder.generator.AggregateKey)

Aggregations

BinaryExpr (com.github.javaparser.ast.expr.BinaryExpr)1 Expression (com.github.javaparser.ast.expr.Expression)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 DescrBuildError (org.drools.compiler.compiler.DescrBuildError)1 PatternBuilder.lookAheadFieldsOfIdentifier (org.drools.compiler.rule.builder.PatternBuilder.lookAheadFieldsOfIdentifier)1 ClassUtils (org.drools.core.util.ClassUtils)1 AccumulateDescr (org.drools.drl.ast.descr.AccumulateDescr)1 BaseDescr (org.drools.drl.ast.descr.BaseDescr)1 ExprConstraintDescr (org.drools.drl.ast.descr.ExprConstraintDescr)1 PatternDescr (org.drools.drl.ast.descr.PatternDescr)1 PatternSourceDescr (org.drools.drl.ast.descr.PatternSourceDescr)1