Search in sources :

Example 6 with BaseDimensionalItemObject

use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.

the class AbstractJdbcEventAnalyticsManagerTest method verifyGetAggregateClauseWithValueFails.

@Test
void verifyGetAggregateClauseWithValueFails() {
    DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
    EventQueryParams params = new EventQueryParams.Builder(createRequestParams()).withValue(dio).withAggregationType(fromAggregationType(AggregationType.CUSTOM)).build();
    assertThrows(IllegalArgumentException.class, () -> subject.getAggregateClause(params));
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) Test(org.junit.jupiter.api.Test)

Example 7 with BaseDimensionalItemObject

use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.

the class AbstractJdbcEventAnalyticsManagerTest method verifyGetSelectSqlWithTextDataElement.

@Test
void verifyGetSelectSqlWithTextDataElement() {
    DimensionalItemObject dio = new BaseDimensionalItemObject(dataElementA.getUid());
    QueryItem item = new QueryItem(dio);
    item.setValueType(ValueType.TEXT);
    QueryFilter queryFilter = new QueryFilter(QueryOperator.EQ, "EQ");
    String column = subject.getSelectSql(queryFilter, item, from, to);
    assertThat(column, is("ax.\"" + dataElementA.getUid() + "\""));
}
Also used : QueryItem(org.hisp.dhis.common.QueryItem) QueryFilter(org.hisp.dhis.common.QueryFilter) 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 8 with BaseDimensionalItemObject

use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.

the class EnrollmentAnalyticsManagerTest method verifyGetCoordinateColumnWithProgramStage.

@Test
void verifyGetCoordinateColumnWithProgramStage() {
    // 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.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 " + "and ps = '" + item.getProgramStage().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) 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 9 with BaseDimensionalItemObject

use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.

the class CascadeSharingTest method baseDimensionalItemObject.

protected DimensionalItemObject baseDimensionalItemObject(final String dimensionItem, DimensionItemType type) {
    final BaseDimensionalItemObject baseDimensionalItemObject = new BaseDimensionalItemObject(dimensionItem);
    baseDimensionalItemObject.setDimensionItemType(type);
    return baseDimensionalItemObject;
}
Also used : BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject)

Example 10 with BaseDimensionalItemObject

use of org.hisp.dhis.common.BaseDimensionalItemObject in project dhis2-core by dhis2.

the class DimensionServiceTest method setUpTest.

@Override
public void setUpTest() {
    deA = createDataElement('A');
    deB = createDataElement('B');
    deC = createDataElement('C');
    deC.setDomainType(DataElementDomain.TRACKER);
    dataElementService.addDataElement(deA);
    dataElementService.addDataElement(deB);
    dataElementService.addDataElement(deC);
    cocA = categoryService.getDefaultCategoryOptionCombo();
    dsA = createDataSet('A');
    dataSetService.addDataSet(dsA);
    prA = createProgram('A');
    idObjectManager.save(prA);
    psA = createProgramStage('A', 1);
    idObjectManager.save(psA);
    atA = createTrackedEntityAttribute('A');
    idObjectManager.save(atA);
    piA = createProgramIndicator('A', prA, null, null);
    idObjectManager.save(piA);
    peA = createPeriod("201201");
    peB = createPeriod("201202");
    peLast12Months = new BaseDimensionalItemObject(LAST_12_MONTHS.toString());
    peA.setUid("201201");
    peB.setUid("201202");
    ouA = createOrganisationUnit('A');
    ouB = createOrganisationUnit('B');
    ouC = createOrganisationUnit('C');
    ouD = createOrganisationUnit('D');
    ouE = createOrganisationUnit('E');
    ouB.updateParent(ouA);
    ouC.updateParent(ouA);
    ouD.updateParent(ouB);
    ouE.updateParent(ouB);
    organisationUnitService.addOrganisationUnit(ouA);
    organisationUnitService.addOrganisationUnit(ouB);
    organisationUnitService.addOrganisationUnit(ouC);
    organisationUnitService.addOrganisationUnit(ouD);
    organisationUnitService.addOrganisationUnit(ouE);
    String level2 = KEY_LEVEL + 2;
    ouUser = new BaseDimensionalItemObject(KEY_USER_ORGUNIT);
    ouLevel2 = new BaseDimensionalItemObject(level2);
    deGroupSetA = createDataElementGroupSet('A');
    dataElementService.addDataElementGroupSet(deGroupSetA);
    deGroupA = createDataElementGroup('A');
    deGroupB = createDataElementGroup('B');
    deGroupC = createDataElementGroup('C');
    deGroupA.getGroupSets().add(deGroupSetA);
    deGroupB.getGroupSets().add(deGroupSetA);
    deGroupC.getGroupSets().add(deGroupSetA);
    dataElementService.addDataElementGroup(deGroupA);
    dataElementService.addDataElementGroup(deGroupB);
    dataElementService.addDataElementGroup(deGroupC);
    deGroupSetA.getMembers().add(deGroupA);
    deGroupSetA.getMembers().add(deGroupB);
    deGroupSetA.getMembers().add(deGroupC);
    dataElementService.updateDataElementGroupSet(deGroupSetA);
    ouGroupSetA = createOrganisationUnitGroupSet('A');
    organisationUnitGroupService.addOrganisationUnitGroupSet(ouGroupSetA);
    ouGroupA = createOrganisationUnitGroup('A');
    ouGroupB = createOrganisationUnitGroup('B');
    ouGroupC = createOrganisationUnitGroup('C');
    ouGroupA.getGroupSets().add(ouGroupSetA);
    ouGroupB.getGroupSets().add(ouGroupSetA);
    ouGroupC.getGroupSets().add(ouGroupSetA);
    organisationUnitGroupService.addOrganisationUnitGroup(ouGroupA);
    organisationUnitGroupService.addOrganisationUnitGroup(ouGroupB);
    organisationUnitGroupService.addOrganisationUnitGroup(ouGroupC);
    ouGroupSetA.getOrganisationUnitGroups().add(ouGroupA);
    ouGroupSetA.getOrganisationUnitGroups().add(ouGroupB);
    ouGroupSetA.getOrganisationUnitGroups().add(ouGroupC);
    organisationUnitGroupService.updateOrganisationUnitGroupSet(ouGroupSetA);
    queryModsA = QueryModifiers.builder().periodOffset(10).build();
    queryModsB = QueryModifiers.builder().minDate(new Date()).build();
    queryModsC = QueryModifiers.builder().maxDate(new Date()).build();
    itemObjectA = deA;
    itemObjectB = new DataElementOperand(deA, cocA);
    itemObjectC = new DataElementOperand(deA, null, cocA);
    itemObjectD = new DataElementOperand(deA, cocA, cocA);
    itemObjectE = new ReportingRate(dsA);
    itemObjectF = new ProgramDataElementDimensionItem(prA, deA);
    itemObjectG = new ProgramTrackedEntityAttributeDimensionItem(prA, atA);
    itemObjectH = piA;
    itemIdA = new DimensionalItemId(DATA_ELEMENT, deA.getUid());
    itemIdB = new DimensionalItemId(DATA_ELEMENT_OPERAND, deA.getUid(), cocA.getUid());
    itemIdC = new DimensionalItemId(DATA_ELEMENT_OPERAND, deA.getUid(), null, cocA.getUid());
    itemIdD = new DimensionalItemId(DATA_ELEMENT_OPERAND, deA.getUid(), cocA.getUid(), cocA.getUid());
    itemIdE = new DimensionalItemId(REPORTING_RATE, dsA.getUid(), ReportingRateMetric.REPORTING_RATE.name());
    itemIdF = new DimensionalItemId(PROGRAM_DATA_ELEMENT, prA.getUid(), deA.getUid());
    itemIdG = new DimensionalItemId(PROGRAM_ATTRIBUTE, prA.getUid(), atA.getUid());
    itemIdH = new DimensionalItemId(PROGRAM_INDICATOR, piA.getUid());
    itemIds = new HashSet<>();
    itemIds.add(itemIdA);
    itemIds.add(itemIdB);
    itemIds.add(itemIdC);
    itemIds.add(itemIdD);
    itemIds.add(itemIdE);
    itemIds.add(itemIdF);
    itemIds.add(itemIdG);
    itemIds.add(itemIdH);
    itemMap = ImmutableMap.<DimensionalItemId, DimensionalItemObject>builder().put(itemIdA, itemObjectA).put(itemIdB, itemObjectB).put(itemIdC, itemObjectC).put(itemIdD, itemObjectD).put(itemIdE, itemObjectE).put(itemIdF, itemObjectF).put(itemIdG, itemObjectG).put(itemIdH, itemObjectH).build();
}
Also used : DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) DimensionalItemId(org.hisp.dhis.common.DimensionalItemId) ProgramDataElementDimensionItem(org.hisp.dhis.program.ProgramDataElementDimensionItem) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) BaseDimensionalItemObject(org.hisp.dhis.common.BaseDimensionalItemObject) ReportingRate(org.hisp.dhis.common.ReportingRate) ProgramTrackedEntityAttributeDimensionItem(org.hisp.dhis.program.ProgramTrackedEntityAttributeDimensionItem) Date(java.util.Date) 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