use of org.drools.drl.ast.descr.ConditionalElementDescr 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.ConditionalElementDescr in project drools by kiegroup.
the class CollectHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
final CollectDescr collectDescr = (CollectDescr) parser.getCurrent();
final Object parent = parser.getParent();
if (parent.getClass().getName().equals(FromDescr.class.getName())) {
final PatternDescr resultPattern = (PatternDescr) parser.getParent(1);
resultPattern.setSource(collectDescr);
} else if (parent instanceof ConditionalElementDescr) {
final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parent;
parentDescr.addDescr(collectDescr);
}
return collectDescr;
}
use of org.drools.drl.ast.descr.ConditionalElementDescr in project drools by kiegroup.
the class GroupElementBuilder method build.
public RuleConditionElement build(final RuleBuildContext context, final BaseDescr descr, final Pattern prefixPattern) {
final ConditionalElementDescr cedescr = (ConditionalElementDescr) descr;
final GroupElement ge = this.newGroupElementFor(descr);
context.getDeclarationResolver().pushOnBuildStack(ge);
if (prefixPattern != null) {
ge.addChild(prefixPattern);
}
// iterate over child descriptors
for (final BaseDescr child : cedescr.getDescrs()) {
// gets child to build
// child.setResource(..) does not seem to be necessary (since builderImpls have already set the resource for all children)
// but leaving it in here to be save
child.setResource(context.getRuleDescr().getResource());
child.setNamespace(context.getRuleDescr().getNamespace());
// gets corresponding builder
final RuleConditionBuilder builder = (RuleConditionBuilder) context.getDialect().getBuilder(child.getClass());
if (builder != null) {
final RuleConditionElement element = builder.build(context, child);
// builder will return null. Ex: ClassNotFound for the pattern type
if (element != null) {
ge.addChild(element);
}
} else {
throw new RuntimeException("BUG: no builder found for descriptor class " + child.getClass());
}
}
context.getDeclarationResolver().popBuildStack();
return ge;
}
use of org.drools.drl.ast.descr.ConditionalElementDescr in project drools by kiegroup.
the class CEDescrBuilderImpl method and.
/**
* {@inheritDoc}
*/
public CEDescrBuilder<CEDescrBuilder<P, T>, AndDescr> and() {
AndDescr andDescr = new AndDescr();
((ConditionalElementDescr) descr).addDescr(andDescr);
return new CEDescrBuilderImpl<CEDescrBuilder<P, T>, AndDescr>(this, andDescr);
}
use of org.drools.drl.ast.descr.ConditionalElementDescr in project drools by kiegroup.
the class CEDescrBuilderImpl method not.
/**
* {@inheritDoc}
*/
public CEDescrBuilder<CEDescrBuilder<P, T>, NotDescr> not() {
CEDescrBuilder<CEDescrBuilder<P, T>, NotDescr> not = new CEDescrBuilderImpl<CEDescrBuilder<P, T>, NotDescr>(this, new NotDescr());
((ConditionalElementDescr) descr).addDescr(not.getDescr());
return not;
}
Aggregations