use of org.drools.modelcompiler.builder.PackageModel in project drools by kiegroup.
the class ToTypedExpressionTest method setUp.
@Before
public void setUp() throws Exception {
imports = new HashSet<>();
packageModel = new PackageModel("", null, false, null);
typeResolver = new ClassTypeResolver(imports, getClass().getClassLoader());
ruleContext = new RuleContext(knowledgeBuilder, packageModel, ruleDescr, typeResolver, true);
imports.add("org.drools.modelcompiler.domain.Person");
}
use of org.drools.modelcompiler.builder.PackageModel in project drools by kiegroup.
the class PatternAccumulateConstraint method buildPattern.
@Override
public void buildPattern() {
Map<String, List<BaseDescr>> constraintsByVar = new HashMap<>();
for (BaseDescr constraint : constraintDescrs) {
Set<String> exprIds = DrlxParseUtil.parseExpression(constraint.getText()).getExpr().findAll(NameExpr.class).stream().map(NameExpr::toString).collect(toSet());
for (AccumulateDescr.AccumulateFunctionCallDescr accFunc : source.getFunctions()) {
if (exprIds.contains(accFunc.getBind())) {
constraintsByVar.computeIfAbsent(accFunc.getBind(), s -> new ArrayList<>()).add(constraint);
break;
}
}
}
constraintsByVar.forEach((id, constraints) -> {
pattern.setIdentifier(id);
new PatternDSLPattern(context, packageModel, pattern, constraints, null, false).buildPattern();
});
pattern.setIdentifier(null);
}
Aggregations