use of org.drools.drl.ast.descr.FromDescr in project drools by kiegroup.
the class RuleParserTest method testSimpleFunctionCallWithFrom.
@Test
public void testSimpleFunctionCallWithFrom() throws Exception {
final RuleDescr rule = (RuleDescr) parseResource("rule", "test_SimpleFunctionCallWithFrom.drl");
assertFalse(parser.getErrors().toString(), parser.hasErrors());
final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
final FromDescr from = (FromDescr) pattern.getSource();
final MVELExprDescr func = (MVELExprDescr) from.getDataSource();
assertEquals("doIt( foo,bar,42,\"hello\",[ a : \"b\", \"something\" : 42, \"a\" : foo, x : [x:y]],\"end\", [a, \"b\", 42] )", func.getExpression());
}
use of org.drools.drl.ast.descr.FromDescr in project drools by kiegroup.
the class RuleParserTest method testSimpleAccessorAndArgWithFrom.
@Test
public void testSimpleAccessorAndArgWithFrom() throws Exception {
final RuleDescr rule = (RuleDescr) parseResource("rule", "test_SimpleAccessorArgWithFrom.drl");
assertFalse(parser.getErrors().toString(), parser.hasErrors());
final PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
final FromDescr from = (FromDescr) pattern.getSource();
final MVELExprDescr accessor = (MVELExprDescr) from.getDataSource();
assertEquals("something.doIt[\"key\"]", accessor.getExpression());
}
use of org.drools.drl.ast.descr.FromDescr in project drools by kiegroup.
the class ExpressionHandler 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();
emptyContentCheck(localName, expression, parser);
FromDescr parent = (FromDescr) parser.getParent();
parent.setDataSource(new MVELExprDescr(expression.trim()));
return null;
}
use of org.drools.drl.ast.descr.FromDescr in project drools by kiegroup.
the class FromHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
final FromDescr fromDescr = (FromDescr) parser.getCurrent();
Object parent = parser.getParent();
final PatternDescr patternDescr = (PatternDescr) parent;
final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parser.getParent(1);
if (element.getElementsByTagName("expression").getLength() > 0) {
patternDescr.setSource(fromDescr);
}
return fromDescr;
}
use of org.drools.drl.ast.descr.FromDescr in project drools by kiegroup.
the class FromHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final FromDescr fromDesctiptor = new FromDescr();
return fromDesctiptor;
}
Aggregations