use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class AbstractJdbcEventAnalyticsManagerTest method verifyGetColumn.
@Test
void verifyGetColumn() {
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
String column = subject.getColumn(item);
assertThat(column, is("ax.\"" + dataElementA.getUid() + "\""));
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class EnrollmentAnalyticsManagerTest method verifyGetCoordinateColumnAndNoProgramStage.
@Test
void verifyGetCoordinateColumnAndNoProgramStage() {
// Given
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.COORDINATE);
item.setProgram(programA);
// When
String columnSql = subject.getCoordinateColumn(item);
// Then
String colName = quote(item.getItemName());
String eventTableName = "analytics_event_" + item.getProgram().getUid();
assertThat(columnSql, is("(select " + "'[' || round(ST_X((" + colName + "))::numeric, 6) || ',' || round(ST_Y((" + colName + "))::numeric, 6) || ']' as " + colName + " from " + eventTableName + " where " + eventTableName + ".pi = " + ANALYTICS_TBL_ALIAS + ".pi " + "and " + colName + " is not null " + "order by executiondate " + "desc limit 1 )"));
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class EnrollmentAnalyticsManagerTest method verifyGetColumnOfTypeCoordinateAndWithProgramStagesAndParamsWithNumberTypeValue.
@Test
void verifyGetColumnOfTypeCoordinateAndWithProgramStagesAndParamsWithNumberTypeValue() {
// Given
DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
QueryItem item = new QueryItem(dio);
item.setValueType(ValueType.COORDINATE);
item.setProgramStage(programStageWithRepeatableParams);
item.setProgram(programB);
RepeatableStageParams repeatableStageParams = new RepeatableStageParams();
repeatableStageParams.setStartIndex(0);
repeatableStageParams.setCount(1);
item.setRepeatableStageParams(repeatableStageParams);
// When
String columnSql = subject.getColumn(item);
// Then
assertThat(columnSql, is("(select \"" + dataElementA.getUid() + "\" from analytics_event_" + programB.getUid() + " where analytics_event_" + programB.getUid() + ".pi = ax.pi and \"" + dataElementA.getUid() + "\" is not null and ps = '" + programStageWithRepeatableParams.getUid() + "' order by executiondate desc limit 1 )"));
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class DataDimensionExtractor method getItemObjectMap.
/**
* Gets a map from dimension item ids to their dimension item objects.
*
* @param itemIds a set of ids of the dimension item objects to get.
* @param atomicObjects a map from each class of atomic objects to a map
* that associates each id of that class with an atomic object.
* @return a map from the item ids to the dimension item objects.
*/
Map<DimensionalItemId, DimensionalItemObject> getItemObjectMap(final Set<DimensionalItemId> itemIds, final MapMap<Class<? extends IdentifiableObject>, String, IdentifiableObject> atomicObjects) {
final Map<DimensionalItemId, DimensionalItemObject> itemObjectMap = new HashMap<>();
for (final DimensionalItemId id : itemIds) {
if (id.hasValidIds()) {
final BaseDimensionalItemObject dimensionalItemObject = getBaseDimensionalItemObject(atomicObjects, id);
if (dimensionalItemObject != null) {
dimensionalItemObject.setQueryMods(id.getQueryMods());
itemObjectMap.put(id, dimensionalItemObject);
}
}
}
return itemObjectMap;
}
use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.
the class VisualizationGridServiceTest method baseDimensionalItemObjectStub.
private BaseDimensionalItemObject baseDimensionalItemObjectStub(final String dimensionItem) {
final BaseDimensionalItemObject baseDimensionalItemObject = new BaseDimensionalItemObject(dimensionItem);
baseDimensionalItemObject.setDescription("display " + dimensionItem);
return baseDimensionalItemObject;
}
Aggregations