Search in sources :

Example 26 with ConditionalElementDescr

use of org.drools.drl.ast.descr.ConditionalElementDescr in project drools by kiegroup.

the class OrHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    final OrDescr orDescr = (OrDescr) parser.getCurrent();
    final Object parent = parser.getParent();
    if (!orDescr.getDescrs().isEmpty()) {
        if (parent instanceof RuleDescr || parent instanceof QueryDescr) {
            final RuleDescr ruleDescr = (RuleDescr) parent;
            ruleDescr.getLhs().addDescr(orDescr);
        } else if (parent instanceof MultiPatternDestinationDescr) {
            final MultiPatternDestinationDescr mpDescr = (MultiPatternDestinationDescr) parent;
            mpDescr.setInput(orDescr);
        } else if (parent instanceof ConditionalElementDescr) {
            final ConditionalElementDescr ceDescr = (ConditionalElementDescr) parent;
            ceDescr.addDescr(orDescr);
        }
    }
    return orDescr;
}
Also used : QueryDescr(org.drools.drl.ast.descr.QueryDescr) MultiPatternDestinationDescr(org.drools.drl.ast.descr.MultiPatternDestinationDescr) Element(org.w3c.dom.Element) RuleDescr(org.drools.drl.ast.descr.RuleDescr) OrDescr(org.drools.drl.ast.descr.OrDescr) ConditionalElementDescr(org.drools.drl.ast.descr.ConditionalElementDescr)

Example 27 with ConditionalElementDescr

use of org.drools.drl.ast.descr.ConditionalElementDescr in project drools by kiegroup.

the class NotHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    final NotDescr notDescr = (NotDescr) parser.getCurrent();
    if ((notDescr.getDescrs().size() != 1) && (notDescr.getDescrs().get(0).getClass() != PatternDescr.class)) {
        throw new SAXParseException("<not> can only have a single <pattern...> as a child element", parser.getLocator());
    }
    final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parser.getParent();
    parentDescr.addDescr(notDescr);
    return null;
}
Also used : NotDescr(org.drools.drl.ast.descr.NotDescr) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) ConditionalElementDescr(org.drools.drl.ast.descr.ConditionalElementDescr)

Example 28 with ConditionalElementDescr

use of org.drools.drl.ast.descr.ConditionalElementDescr in project drools by kiegroup.

the class ExistsHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    final ExistsDescr existsDescr = (ExistsDescr) parser.getCurrent();
    if ((existsDescr.getDescrs().size() != 1) && (existsDescr.getDescrs().get(0).getClass() != PatternDescr.class)) {
        throw new SAXParseException("<exists> can only have a single <pattern...> as a child element", parser.getLocator());
    }
    final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parser.getParent();
    parentDescr.addDescr(existsDescr);
    return existsDescr;
}
Also used : ExistsDescr(org.drools.drl.ast.descr.ExistsDescr) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) ConditionalElementDescr(org.drools.drl.ast.descr.ConditionalElementDescr)

Example 29 with ConditionalElementDescr

use of org.drools.drl.ast.descr.ConditionalElementDescr 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;
}
Also used : PatternDescr(org.drools.drl.ast.descr.PatternDescr) Element(org.w3c.dom.Element) FromDescr(org.drools.drl.ast.descr.FromDescr) AccumulateDescr(org.drools.drl.ast.descr.AccumulateDescr) ConditionalElementDescr(org.drools.drl.ast.descr.ConditionalElementDescr)

Example 30 with ConditionalElementDescr

use of org.drools.drl.ast.descr.ConditionalElementDescr in project drools by kiegroup.

the class AndHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    final AndDescr andDescr = (AndDescr) parser.getCurrent();
    final Object parent = parser.getParent();
    if (!andDescr.getDescrs().isEmpty()) {
        if (parent instanceof RuleDescr || parent instanceof QueryDescr) {
            final RuleDescr ruleDescr = (RuleDescr) parent;
            ruleDescr.setLhs(andDescr);
        } else if (parent instanceof MultiPatternDestinationDescr) {
            final MultiPatternDestinationDescr mpDescr = (MultiPatternDestinationDescr) parent;
            mpDescr.setInput(andDescr);
        } else if (parent instanceof ConditionalElementDescr) {
            final ConditionalElementDescr ceDescr = (ConditionalElementDescr) parent;
            ceDescr.addDescr(andDescr);
        }
    }
    return andDescr;
}
Also used : QueryDescr(org.drools.drl.ast.descr.QueryDescr) MultiPatternDestinationDescr(org.drools.drl.ast.descr.MultiPatternDestinationDescr) AndDescr(org.drools.drl.ast.descr.AndDescr) Element(org.w3c.dom.Element) RuleDescr(org.drools.drl.ast.descr.RuleDescr) ConditionalElementDescr(org.drools.drl.ast.descr.ConditionalElementDescr)

Aggregations

ConditionalElementDescr (org.drools.drl.ast.descr.ConditionalElementDescr)30 BaseDescr (org.drools.drl.ast.descr.BaseDescr)16 AndDescr (org.drools.drl.ast.descr.AndDescr)11 Element (org.w3c.dom.Element)10 AnnotatedBaseDescr (org.drools.drl.ast.descr.AnnotatedBaseDescr)5 CEDescrBuilder (org.drools.drl.ast.dsl.CEDescrBuilder)5 OrDescr (org.drools.drl.ast.descr.OrDescr)4 FromDescr (org.drools.drl.ast.descr.FromDescr)3 PatternDescr (org.drools.drl.ast.descr.PatternDescr)3 AccumulateDescrBuilder (org.drools.drl.ast.dsl.AccumulateDescrBuilder)3 AnnotatedDescrBuilder (org.drools.drl.ast.dsl.AnnotatedDescrBuilder)3 AnnotationDescrBuilder (org.drools.drl.ast.dsl.AnnotationDescrBuilder)3 AttributeDescrBuilder (org.drools.drl.ast.dsl.AttributeDescrBuilder)3 BehaviorDescrBuilder (org.drools.drl.ast.dsl.BehaviorDescrBuilder)3 CollectDescrBuilder (org.drools.drl.ast.dsl.CollectDescrBuilder)3 ConditionalBranchDescrBuilder (org.drools.drl.ast.dsl.ConditionalBranchDescrBuilder)3 DeclareDescrBuilder (org.drools.drl.ast.dsl.DeclareDescrBuilder)3 DescrBuilder (org.drools.drl.ast.dsl.DescrBuilder)3 EntryPointDeclarationDescrBuilder (org.drools.drl.ast.dsl.EntryPointDeclarationDescrBuilder)3 EnumDeclarationDescrBuilder (org.drools.drl.ast.dsl.EnumDeclarationDescrBuilder)3