use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryC.
/**
* Query spans 3 organisation unit levels. Splits in 3 queries for each level,
* then splits in 2 queries on organisation units to satisfy optimal for a total
* of 5 queries, as there are only 5 organisation units in total.
*/
@Test
public void planQueryC() {
ouB.setParent(ouA);
ouC.setParent(ouA);
ouD.setParent(ouB);
ouE.setParent(ouC);
ouA.getChildren().add(ouB);
ouA.getChildren().add(ouC);
ouD.getChildren().add(ouB);
ouC.getChildren().add(ouE);
organisationUnitService.updateOrganisationUnit(ouA);
organisationUnitService.updateOrganisationUnit(ouB);
organisationUnitService.updateOrganisationUnit(ouC);
organisationUnitService.updateOrganisationUnit(ouD);
organisationUnitService.updateOrganisationUnit(ouE);
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD, ouE)).withPeriods(getList(createPeriod("2000Q1"), createPeriod("2000Q2"), createPeriod("2000Q3"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(6).withTableName(ANALYTICS_TABLE_NAME).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(5, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(5, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertTrue(samePartition(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlNoPeriodsAllowAllPeriods.
@Test
public void testGetFromUrlNoPeriodsAllowAllPeriods() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getUid() + ";" + deB.getUid() + ";" + deC.getUid() + ";" + deD.getUid());
dimensionParams.add("pe");
DataQueryParams params = dataQueryService.getFromUrl(dimensionParams, null, null, null, null, null, null, false, false, false, false, false, false, false, false, false, false, null, null, null, false, null, null, null, true, null);
assertEquals(0, params.getPeriods().size());
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlPeriodOrder.
@Test
public void testGetFromUrlPeriodOrder() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getUid() + ";" + deB.getUid() + ";" + deC.getUid() + ";" + deD.getUid());
dimensionParams.add("pe:2013;2012Q4;2012S2");
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getUid());
DataQueryParams params = dataQueryService.getFromUrl(dimensionParams, filterParams, null, null, null, null, null, false, false, false, false, false, false, false, false, false, false, null, null, null, false, null, null, null, false, null);
List<DimensionalItemObject> periods = params.getPeriods();
assertEquals(3, periods.size());
assertEquals("2013", periods.get(0).getUid());
assertEquals("2012Q4", periods.get(1).getUid());
assertEquals("2012S2", periods.get(2).getUid());
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlWithCodeB.
@Test
public void testGetFromUrlWithCodeB() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getCode() + ";" + deB.getCode() + ";" + inA.getCode());
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getCode());
DataQueryParams params = dataQueryService.getFromUrl(dimensionParams, filterParams, null, null, null, null, null, false, false, false, false, false, false, false, false, false, false, null, null, IdScheme.CODE, false, null, null, null, false, null);
assertEquals(2, params.getDataElements().size());
assertEquals(1, params.getIndicators().size());
assertEquals(1, params.getFilterOrganisationUnits().size());
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlRelativePeriods.
@Test
public void testGetFromUrlRelativePeriods() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem() + ";" + deC.getDimensionItem() + ";" + deD.getDimensionItem());
dimensionParams.add("pe:LAST_12_MONTHS");
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getDimensionItem() + ";" + ouB.getDimensionItem());
DataQueryParams params = dataQueryService.getFromUrl(dimensionParams, filterParams, null, null, null, null, null, false, false, false, false, false, false, false, false, false, false, null, null, null, false, null, null, null, false, null);
assertEquals(4, params.getDataElements().size());
assertEquals(12, params.getPeriods().size());
assertEquals(2, params.getFilterOrganisationUnits().size());
}
Aggregations