Search in sources :

Example 16 with BaseDimensionalItemObject

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() + "\""));
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 17 with BaseDimensionalItemObject

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 )"));
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 18 with BaseDimensionalItemObject

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 )"));
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) RepeatableStageParams(org.hisp.dhis.common.RepeatableStageParams) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 19 with BaseDimensionalItemObject

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;
}
Also used : DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) HashMap(java.util.HashMap) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject)

Example 20 with BaseDimensionalItemObject

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;
}
Also used : BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject)

Aggregations

BaseDimensionalItemObject (org.hisp.dhis.common.BaseDimensionalItemObject)21 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)17 Test (org.junit.jupiter.api.Test)14 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)13 QueryItem (org.hisp.dhis.common.QueryItem)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)3 QueryFilter (org.hisp.dhis.common.QueryFilter)3 DimensionalItemId (org.hisp.dhis.common.DimensionalItemId)2 RepeatableStageParams (org.hisp.dhis.common.RepeatableStageParams)2 ReportingRate (org.hisp.dhis.common.ReportingRate)2 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)2 ProgramDataElementDimensionItem (org.hisp.dhis.program.ProgramDataElementDimensionItem)2 ProgramTrackedEntityAttributeDimensionItem (org.hisp.dhis.program.ProgramTrackedEntityAttributeDimensionItem)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 DimensionResponse (org.hisp.dhis.analytics.dimension.DimensionResponse)1 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)1 ValueTypedDimensionalItemObject (org.hisp.dhis.common.ValueTypedDimensionalItemObject)1 DataElement (org.hisp.dhis.dataelement.DataElement)1