Search in sources :

Example 6 with DataQueryRequest

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

the class DataQueryServiceTest method testGetFromUrlA.

@Test
void testGetFromUrlA() {
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("dx:" + deA.getUid() + ";" + deB.getUid() + ";" + deC.getUid() + ";" + deD.getUid());
    dimensionParams.add("pe:2012;2012S1;2012S2");
    dimensionParams.add(ouGroupSetA.getUid() + ":" + ouGroupA.getUid() + ";" + ouGroupB.getUid() + ";" + ouGroupC.getUid());
    Set<String> filterParams = new HashSet<>();
    filterParams.add("ou:" + ouA.getUid() + ";" + ouB.getUid() + ";" + ouC.getUid() + ";" + ouD.getUid() + ";" + ouE.getUid());
    DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).build();
    DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
    assertEquals(4, params.getDataElements().size());
    assertEquals(3, params.getPeriods().size());
    assertEquals(5, params.getFilterOrganisationUnits().size());
    assertEquals(3, params.getDimensionOptions(ouGroupSetA.getUid()).size());
}
Also used : DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) DataQueryRequest(org.hisp.dhis.common.DataQueryRequest) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 7 with DataQueryRequest

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

the class DataQueryServiceTest method testGetFromUrlNoOrganisationUnits.

@Test
void testGetFromUrlNoOrganisationUnits() {
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D");
    dimensionParams.add("ou");
    DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
    assertThrows(IllegalQueryException.class, () -> dataQueryService.getFromRequest(dataQueryRequest));
}
Also used : DataQueryRequest(org.hisp.dhis.common.DataQueryRequest) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 8 with DataQueryRequest

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

the class DataQueryServiceTest method testGetFromUrlInvalidOrganisationUnits.

@Test
void testGetFromUrlInvalidOrganisationUnits() {
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D");
    dimensionParams.add("ou:aTr6yTgX7t5;gBgf2G2j4GR");
    DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
    assertIllegalQueryEx(assertThrows(IllegalQueryException.class, () -> dataQueryService.getFromRequest(dataQueryRequest)), ErrorCode.E7124);
}
Also used : IllegalQueryException(org.hisp.dhis.common.IllegalQueryException) DataQueryRequest(org.hisp.dhis.common.DataQueryRequest) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 9 with DataQueryRequest

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

the class DataQueryServiceTest method testGetFromUrlOrgUnitLevel.

@Test
void testGetFromUrlOrgUnitLevel() {
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("ou:LEVEL-2");
    dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem());
    dimensionParams.add("pe:2011;2012");
    DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
    DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
    assertEquals(2, params.getOrganisationUnits().size());
    assertEquals(2, params.getDataElements().size());
    assertEquals(2, params.getPeriods().size());
}
Also used : DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) DataQueryRequest(org.hisp.dhis.common.DataQueryRequest) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 10 with DataQueryRequest

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

the class DataQueryServiceTest method testGetFromUrlNoPeriods.

@Test
void testGetFromUrlNoPeriods() {
    Set<String> dimensionParams = new HashSet<>();
    dimensionParams.add("dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D");
    dimensionParams.add("pe");
    DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
    assertThrows(IllegalQueryException.class, () -> dataQueryService.getFromRequest(dataQueryRequest));
}
Also used : DataQueryRequest(org.hisp.dhis.common.DataQueryRequest) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

DataQueryRequest (org.hisp.dhis.common.DataQueryRequest)35 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)29 Test (org.junit.jupiter.api.Test)29 HashSet (java.util.HashSet)19 LinkedHashSet (java.util.LinkedHashSet)18 DhisSpringTest (org.hisp.dhis.DhisSpringTest)18 DimensionalObject (org.hisp.dhis.common.DimensionalObject)11 DimensionItemKeywords (org.hisp.dhis.common.DimensionItemKeywords)9 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)8 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 DataElement (org.hisp.dhis.dataelement.DataElement)3 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 Grid (org.hisp.dhis.common.Grid)2 DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)2 Indicator (org.hisp.dhis.indicator.Indicator)2 IndicatorGroup (org.hisp.dhis.indicator.IndicatorGroup)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 LineString (org.geojson.LineString)1 MultiLineString (org.geojson.MultiLineString)1 Attribute (org.hisp.dhis.attribute.Attribute)1