Search in sources :

Example 1 with ExpressionInfo

use of org.hisp.dhis.expression.ExpressionInfo in project dhis2-core by dhis2.

the class VectorFunction method getExpressionInfo.

@Override
public Object getExpressionInfo(ExprContext ctx, CommonExpressionVisitor visitor) {
    for (int i = 0; i < ctx.expr().size() - 1; i++) {
        visitor.visitExpr(ctx.expr().get(i));
    }
    // ItemIds in the last (or only) expr are from sampled periods.
    ExpressionInfo info = visitor.getInfo();
    Set<DimensionalItemId> savedItemIds = info.getItemIds();
    info.setItemIds(info.getSampleItemIds());
    Object result = visitor.visitExpr(ctx.expr().get(ctx.expr().size() - 1));
    info.setItemIds(savedItemIds);
    return castDouble(result);
}
Also used : DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) ExpressionInfo(org.hisp.dhis.expression.ExpressionInfo)

Aggregations

DimensionalItemId (org.hisp.dhis.common.DimensionalItemId)1 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)1 ExpressionInfo (org.hisp.dhis.expression.ExpressionInfo)1