use of org.drools.drl.ast.descr.PatternDescr in project drools by kiegroup.
the class FieldBindingHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
final BindingDescr fieldBindingDescr = (BindingDescr) parser.getCurrent();
final PatternDescr patternDescr = (PatternDescr) parser.getParent();
patternDescr.addConstraint(fieldBindingDescr);
return fieldBindingDescr;
}
use of org.drools.drl.ast.descr.PatternDescr in project drools by kiegroup.
the class RestrictionConnectiveHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Object op = parser.getParent();
ConnectiveDescr c = (ConnectiveDescr) parser.getCurrent();
if (op instanceof PatternDescr) {
StringBuilder sb = new StringBuilder();
c.buildExpression(sb);
ExprConstraintDescr expr = new ExprConstraintDescr();
expr.setExpression(sb.toString());
final PatternDescr patternDescr = (PatternDescr) op;
patternDescr.addConstraint(expr);
} else {
ConnectiveDescr p = (ConnectiveDescr) op;
p.add(c);
}
return c;
}
use of org.drools.drl.ast.descr.PatternDescr in project drools by kiegroup.
the class PredicateHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
final String expression = ((org.w3c.dom.Text) element.getChildNodes().item(0)).getWholeText();
if (expression == null || expression.trim().equals("")) {
throw new SAXParseException("<predicate> must have some content", parser.getLocator());
}
final PatternDescr patternDescr = (PatternDescr) parser.getParent();
ExprConstraintDescr expr = new ExprConstraintDescr("eval(" + expression + ")");
patternDescr.addConstraint(expr);
return expr;
}
use of org.drools.drl.ast.descr.PatternDescr in project drools by kiegroup.
the class AccumulateHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
final AccumulateDescr accumulateDescr = (AccumulateDescr) parser.getCurrent();
final Object parent = parser.getParent();
if (parent.getClass().getName().equals(FromDescr.class.getName())) {
final PatternDescr result = (PatternDescr) parser.getParent(1);
result.setSource(accumulateDescr);
} else if (parent instanceof ConditionalElementDescr) {
final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parent;
parentDescr.addDescr(accumulateDescr);
}
return accumulateDescr;
}
use of org.drools.drl.ast.descr.PatternDescr in project drools by kiegroup.
the class NamedConsequenceVisitor method visit.
public void visit(ConditionalBranchDescr desc) {
PatternDescr patternRelated = desc.getReferringPatternDescr(context.getParentDescr());
if (patternRelated == null) {
context.addCompilationError(new InvalidExpressionErrorResult("Related pattern cannot be found for " + desc));
return;
}
Class<?> patternRelatedClass = getClassFromContext(context.getTypeResolver(), patternRelated.getObjectType());
MethodCallExpr whenBlock = whenThenDSL(desc, patternRelated, patternRelatedClass, WHEN_CALL, null);
recurseAmongElseBranch(patternRelatedClass, patternRelated, whenBlock, desc.getElseBranch());
}
Aggregations