use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class EnrollmentAnalyticsManagerTest method verifyGetColumnOfTypeCoordinateAndNoProgramStages.
@Test
void verifyGetColumnOfTypeCoordinateAndNoProgramStages() {
// Given
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.COORDINATE);
// When
String columnSql = subject.getColumn(item);
// Then
assertThat(columnSql, is("ax.\"" + dataElementA.getUid() + "\""));
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class EnrollmentAnalyticsManagerTest method verifyGetColumnOfTypeCoordinateAndWithProgramStages.
@Test
void verifyGetColumnOfTypeCoordinateAndWithProgramStages() {
// Given
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.COORDINATE);
item.setProgramStage(programStage);
item.setProgram(programA);
// When
String columnSql = subject.getColumn(item);
// Then
assertThat(columnSql, is("(select \"" + dataElementA.getUid() + "\" from analytics_event_" + programA.getUid() + " where analytics_event_" + programA.getUid() + ".pi = ax.pi and \"" + dataElementA.getUid() + "\" is not null and ps = '" + programStage.getUid() + "' order by executiondate desc limit 1 )"));
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class AbstractJdbcEventAnalyticsManagerTest method verifyGetSelectSqlWithTextDataElementIgnoringCase.
@Test
void verifyGetSelectSqlWithTextDataElementIgnoringCase() {
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.TEXT);
QueryFilter queryFilter = new QueryFilter(QueryOperator.IEQ, "IEQ");
String column = subject.getSelectSql(queryFilter, item, from, to);
assertThat(column, is("lower(ax.\"" + dataElementA.getUid() + "\")"));
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class AbstractJdbcEventAnalyticsManagerTest method verifyGetCoordinateColumn.
@Test
void verifyGetCoordinateColumn() {
// Given
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
// When
String column = subject.getCoordinateColumn(item);
// Then
String colName = quote(item.getItemName());
assertThat(column, is("'[' || round(ST_X(" + colName + ")::numeric, 6) || ',' || round(ST_Y(" + colName + ")::numeric, 6) || ']' as " + colName));
return;
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class AbstractJdbcEventAnalyticsManagerTest method verifyGetAggregateClauseWithValue.
@Test
void verifyGetAggregateClauseWithValue() {
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
EventQueryParams params = new EventQueryParams.Builder(createRequestParams()).withValue(dio).withAggregationType(AnalyticsAggregationType.SUM).build();
String clause = subject.getAggregateClause(params);
assertThat(clause, is("sum(ax.\"fWIAEtYVEGk\")"));
}
Aggregations