use of org.drools.compiler.lang.descr.ExistsDescr in project drools by kiegroup.
the class ExistsHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final ExistsDescr existsDescr = new ExistsDescr();
return existsDescr;
}
use of org.drools.compiler.lang.descr.ExistsDescr 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;
}
use of org.drools.compiler.lang.descr.ExistsDescr in project drools by kiegroup.
the class RuleParserTest method testPluggableOperators2.
@Test
public void testPluggableOperators2() throws Exception {
final String text = "rule \"tt\"\n" + " dialect \"mvel\"\n" + "when\n" + " exists (TelephoneCall( this finishes [1m] \"25-May-2011\" ))\n" + "then\n" + "end";
PatternDescr pattern = (PatternDescr) ((ExistsDescr) ((RuleDescr) parse("rule", text)).getLhs().getDescrs().get(0)).getDescrs().get(0);
assertEquals("TelephoneCall", pattern.getObjectType());
ExprConstraintDescr constr = (ExprConstraintDescr) pattern.getConstraint().getDescrs().get(0);
assertEquals("this finishes [1m] \"25-May-2011\"", constr.getText());
}
Aggregations