Search in sources :

Example 1 with SqlLiteral

use of org.hisp.dhis.parser.expression.literal.SqlLiteral in project dhis2-core by dhis2.

the class DefaultProgramIndicatorService method _getAnalyticsSql.

private String _getAnalyticsSql(String expression, ProgramIndicator programIndicator, Date startDate, Date endDate, String tableAlias) {
    Set<String> uids = getDataElementAndAttributeIdentifiers(expression, programIndicator.getAnalyticsType());
    ProgramExpressionParams params = ProgramExpressionParams.builder().programIndicator(programIndicator).reportingStartDate(startDate).reportingEndDate(endDate).dataElementAndAttributeIdentifiers(uids).build();
    CommonExpressionVisitor visitor = newVisitor(ITEM_GET_SQL, params);
    visitor.setExpressionLiteral(new SqlLiteral());
    String sql = castString(Parser.visit(expression, visitor));
    return (tableAlias != null ? sql.replaceAll(ANALYTICS_TBL_ALIAS + "\\.", tableAlias + "\\.") : sql);
}
Also used : ProgramExpressionParams(org.hisp.dhis.parser.expression.ProgramExpressionParams) CommonExpressionVisitor(org.hisp.dhis.parser.expression.CommonExpressionVisitor) AntlrParserUtils.castString(org.hisp.dhis.antlr.AntlrParserUtils.castString) SqlLiteral(org.hisp.dhis.parser.expression.literal.SqlLiteral)

Aggregations

AntlrParserUtils.castString (org.hisp.dhis.antlr.AntlrParserUtils.castString)1 CommonExpressionVisitor (org.hisp.dhis.parser.expression.CommonExpressionVisitor)1 ProgramExpressionParams (org.hisp.dhis.parser.expression.ProgramExpressionParams)1 SqlLiteral (org.hisp.dhis.parser.expression.literal.SqlLiteral)1