Search in sources :

Example 6 with EventDataQueryRequest

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

the class EventDataQueryServiceTest method testGetFromUrlA.

@Test
void testGetFromUrlA() {
    final String coordinateField = "EVENT";
    final String fallbackCoordinateField = "ougeometry";
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("ou:" + ouA.getUid() + ";" + ouB.getId());
    dimensionParams.add(atA.getUid() + ":LE:5");
    Set<String> filterParams = new HashSet<>();
    filterParams.add("pe:201401;201402");
    EventDataQueryRequest request = EventDataQueryRequest.builder().program(prA.getUid()).dimension(dimensionParams).filter(filterParams).coordinateField(coordinateField).fallbackCoordinateField(fallbackCoordinateField).coordinateOuFallback(true).build();
    EventQueryParams params = dataQueryService.getFromRequest(request);
    assertEquals(prA, params.getProgram());
    assertEquals(1, params.getOrganisationUnits().size());
    assertEquals(1, params.getItems().size());
    assertEquals(2, params.getFilterPeriods().size());
    assertEquals("psigeometry", params.getCoordinateField());
    assertEquals(fallbackCoordinateField, params.getFallbackCoordinateField());
    assertTrue(params.isCoordinateOuFallback());
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) EventDataQueryRequest(org.hisp.dhis.common.EventDataQueryRequest) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 7 with EventDataQueryRequest

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

the class EventDataQueryServiceTest method testGetFromUrlB.

@Test
void testGetFromUrlB() {
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("ou:" + ouA.getUid() + ";" + ouB.getId());
    dimensionParams.add(atA.getUid() + ":LE:5");
    Set<String> filterParams = new HashSet<>();
    filterParams.add("pe:201401");
    EventDataQueryRequest request = EventDataQueryRequest.builder().program(prA.getUid()).dimension(dimensionParams).filter(filterParams).value(deA.getUid()).aggregationType(AggregationType.AVERAGE).build();
    EventQueryParams params = dataQueryService.getFromRequest(request);
    assertEquals(prA, params.getProgram());
    assertEquals(1, params.getOrganisationUnits().size());
    assertEquals(1, params.getItems().size());
    assertEquals(1, params.getFilterPeriods().size());
    assertEquals(deA, params.getValue());
    assertEquals(AnalyticsAggregationType.AVERAGE, params.getAggregationType());
    assertFalse(params.isCoordinateOuFallback());
    assertEquals("psigeometry", params.getCoordinateField());
    assertEquals("ougeometry", params.getFallbackCoordinateField());
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) EventDataQueryRequest(org.hisp.dhis.common.EventDataQueryRequest) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 8 with EventDataQueryRequest

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

the class EventDataQueryServiceTest method testGetFromUrlWithOrgUnitNameSorting.

@Test
void testGetFromUrlWithOrgUnitNameSorting() {
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("ou:" + ouA.getUid() + ";" + ouB.getId());
    dimensionParams.add(atA.getUid() + ":LE:5");
    Set<String> filterParams = new HashSet<>();
    filterParams.add("pe:201401");
    Set<String> desc = new HashSet<>();
    desc.add("ouname");
    EventDataQueryRequest request = EventDataQueryRequest.builder().program(prA.getUid()).dimension(dimensionParams).filter(filterParams).value(deA.getUid()).aggregationType(AggregationType.AVERAGE).desc(desc).build();
    EventQueryParams params = dataQueryService.getFromRequest(request);
    assertEquals(prA, params.getProgram());
    assertEquals(1, params.getOrganisationUnits().size());
    assertEquals(1, params.getItems().size());
    assertEquals(1, params.getFilterPeriods().size());
    assertEquals(deA, params.getValue());
    assertEquals(1, params.getDesc().size());
    assertEquals("ouname", params.getDesc().get(0).getItem().getName());
    assertEquals(AnalyticsAggregationType.AVERAGE, params.getAggregationType());
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) EventDataQueryRequest(org.hisp.dhis.common.EventDataQueryRequest) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

HashSet (java.util.HashSet)8 DhisSpringTest (org.hisp.dhis.DhisSpringTest)8 EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)8 EventDataQueryRequest (org.hisp.dhis.common.EventDataQueryRequest)8 Test (org.junit.jupiter.api.Test)8 Sets (com.google.common.collect.Sets)1 LocalDate (java.time.LocalDate)1 ZoneId (java.time.ZoneId)1 Date (java.util.Date)1 List (java.util.List)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1 AggregationType (org.hisp.dhis.analytics.AggregationType)1 AnalyticsAggregationType (org.hisp.dhis.analytics.AnalyticsAggregationType)1 EventDataQueryService (org.hisp.dhis.analytics.event.EventDataQueryService)1 AnalyticsType (org.hisp.dhis.common.AnalyticsType)1 DimensionType (org.hisp.dhis.common.DimensionType)1 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)1 DimensionalObject (org.hisp.dhis.common.DimensionalObject)1 DimensionalObjectUtils (org.hisp.dhis.common.DimensionalObjectUtils)1