Search in sources :

Example 1 with Rectangle

use of org.hisp.dhis.analytics.Rectangle in project dhis2-core by dhis2.

the class JdbcEventAnalyticsManager method getRectangle.

@Override
public Rectangle getRectangle(EventQueryParams params) {
    String clusterField = params.getCoordinateField();
    String sql = "select count(psi) as " + COL_COUNT + ", ST_Extent(" + clusterField + ") as " + COL_EXTENT + " ";
    sql += getFromWhereClause(params, Lists.newArrayList("psi", clusterField));
    log.debug(String.format("Analytics event count and extent SQL: %s", sql));
    Rectangle rectangle = new Rectangle();
    SqlRowSet rowSet = jdbcTemplate.queryForRowSet(sql);
    if (rowSet.next()) {
        Object extent = rowSet.getObject(COL_EXTENT);
        rectangle.setCount(rowSet.getLong(COL_COUNT));
        rectangle.setExtent(extent != null ? String.valueOf(rowSet.getObject(COL_EXTENT)) : null);
    }
    return rectangle;
}
Also used : SqlRowSet(org.springframework.jdbc.support.rowset.SqlRowSet) Rectangle(org.hisp.dhis.analytics.Rectangle) DateUtils.getMediumDateString(org.hisp.dhis.system.util.DateUtils.getMediumDateString)

Aggregations

Rectangle (org.hisp.dhis.analytics.Rectangle)1 DateUtils.getMediumDateString (org.hisp.dhis.system.util.DateUtils.getMediumDateString)1 SqlRowSet (org.springframework.jdbc.support.rowset.SqlRowSet)1