AbstractJdbcEventAnalyticsManager { protected String getSelectSql( QueryItem item, Date startDate, Date endDate ) { if ( item.isProgramIndicator() ) { ProgramIndicator programIndicator = (ProgramIndicator)item.getItem(); return programIndicatorService.getAnalyticsSql( programIndicator.getExpression(), programIndicator, startDate, endDate ); } else { return item.isText() ? wrapLower( getColumn( item ) ) : getColumn( item ); } } AbstractJdbcEventAnalyticsManager( @Qualifier( "readOnlyJdbcTemplate" ) JdbcTemplate jdbcTemplate,
        StatementBuilder statementBuilder, ProgramIndicatorService programIndicatorService,
        ProgramIndicatorSubqueryBuilder programIndicatorSubqueryBuilder ); Grid getAggregatedEventData( EventQueryParams params, Grid grid, int maxLimit );  }
@Test public void verifyGetSelectSqlWithProgramIndicator() { ProgramIndicator programIndicator = createProgramIndicator( 'A', programA, "9.0", null ); QueryItem item = new QueryItem( programIndicator ); subject.getSelectSql( item, from, to ); verify( programIndicatorService ).getAnalyticsSql( programIndicator.getExpression(), programIndicator, from, to ); }
@Test public void verifyGetSelectSqlWithTextDataElement() { DimensionalItemObject dio = new BaseDimensionalItemObject( dataElementA.getUid() ); QueryItem item = new QueryItem( dio ); item.setValueType( ValueType.TEXT ); String column = subject.getSelectSql( item, from, to ); assertThat( column, is( "lower(ax.\"" + dataElementA.getUid() + "\")" ) ); }
@Test public void verifyGetSelectSqlWithNonTextDataElement() { DimensionalItemObject dio = new BaseDimensionalItemObject( dataElementA.getUid() ); QueryItem item = new QueryItem( dio ); item.setValueType( ValueType.NUMBER ); String column = subject.getSelectSql( item, from, to ); assertThat( column, is( "ax.\"" + dataElementA.getUid() + "\"" ) ); }