use of org.hisp.dhis.analytics.MeasureFilter in project dhis2-core by dhis2.
the class JdbcAnalyticsManager method getMeasureCriteriaSql.
/**
* Returns a HAVING clause restricting the result based on the measure criteria
*/
private String getMeasureCriteriaSql(DataQueryParams params) {
SqlHelper sqlHelper = new SqlHelper();
String sql = " ";
for (MeasureFilter filter : params.getMeasureCriteria().keySet()) {
Double criterion = params.getMeasureCriteria().get(filter);
sql += sqlHelper.havingAnd() + " " + getNumericValueColumn(params) + " " + OPERATOR_SQL_MAP.get(filter) + " " + criterion + " ";
}
return sql;
}
use of org.hisp.dhis.analytics.MeasureFilter in project dhis2-core by dhis2.
the class JdbcAnalyticsManager method getPartitionSql.
/**
* If preAggregationMeasureCriteria is specified, generates a query which
* provides a filtered view of the data according to the criteria .If not,
* returns the full view of the partition.
*/
private String getPartitionSql(DataQueryParams params, String partition) {
if (params.isDataType(DataType.NUMERIC) && !params.getPreAggregateMeasureCriteria().isEmpty()) {
SqlHelper sqlHelper = new SqlHelper();
String sql = "";
sql += "(select * from " + partition + " ";
for (MeasureFilter filter : params.getPreAggregateMeasureCriteria().keySet()) {
Double criterion = params.getPreAggregateMeasureCriteria().get(filter);
sql += sqlHelper.whereAnd() + " value " + OPERATOR_SQL_MAP.get(filter) + " " + criterion + " ";
}
sql += ") as " + partition;
return sql;
} else {
return partition;
}
}
Aggregations