use of org.drools.model.view.Expr1ViewItemImpl in project drools by kiegroup.
the class ViewFlowBuilder method viewItem2Condition.
private static Condition viewItem2Condition(ViewItem viewItem, Condition condition, BuildContext ctx) {
if (viewItem instanceof AbstractExprViewItem) {
((PatternImpl) condition).addWatchedProps(((AbstractExprViewItem) viewItem).getWatchedProps());
}
if (viewItem instanceof Expr1ViewItemImpl) {
Expr1ViewItemImpl expr = (Expr1ViewItemImpl) viewItem;
if (expr.getPredicate() != null) {
((PatternImpl) condition).addConstraint(new SingleConstraint1(expr));
}
return condition;
}
if (viewItem instanceof ExprNViewItem) {
((PatternImpl) condition).addConstraint(SingleConstraint.createConstraint((ExprNViewItem) viewItem));
return condition;
}
if (viewItem instanceof TemporalExprViewItem) {
TemporalExprViewItem expr = (TemporalExprViewItem) viewItem;
((PatternImpl) condition).addConstraint(new TemporalConstraint(expr));
return condition;
}
if (viewItem instanceof AccumulateExprViewItem) {
AccumulateExprViewItem acc = (AccumulateExprViewItem) viewItem;
for (AccumulateFunction accFunc : acc.getAccumulateFunctions()) {
ctx.usedVars.add(accFunc.getVariable());
}
final Condition newCondition = acc.getExpr() instanceof InputViewItem ? condition : viewItem2Condition(acc.getExpr(), condition, ctx);
return new AccumulatePatternImpl(newCondition, acc.getAccumulateFunctions());
}
if (viewItem instanceof CombinedExprViewItem) {
CombinedExprViewItem combined = (CombinedExprViewItem) viewItem;
CompositePatterns patterns = viewItems2Condition(new BuildContext(ctx, combined.getExpressions()), combined.getType(), false);
return patterns.getSubConditions().size() == 1 ? patterns.getSubConditions().get(0) : patterns;
}
throw new UnsupportedOperationException("Unknown ViewItem: " + viewItem);
}
Aggregations