use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryA.
/**
* Query spans 2 partitions. Splits in 2 queries for each partition, then
* splits in 4 queries on data elements to satisfy optimal for a total
* of 8 queries, because query has 2 different aggregation types.
*/
@Test
public void planQueryA() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB, deC, deD)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD, ouE)).withPeriods(getList(createPeriod("200101"), createPeriod("200103"), createPeriod("200105"), createPeriod("200107"), createPeriod("2002Q3"), createPeriod("2002Q4"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableName(ANALYTICS_TABLE_NAME).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(8, queryGroups.getAllQueries().size());
assertEquals(2, queryGroups.getSequentialQueries().size());
assertEquals(4, 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 QueryPlannerTest method planQueryD.
/**
* Query spans 1 partition. Splits on 2 aggregation types, then splits one
* query on 3 days in period to satisfy optimal for a total of 4 queries.
*/
@Test
public void planQueryD() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB, deC)).withOrganisationUnits(getList(ouA)).withPeriods(getList(createPeriod("200001"), createPeriod("200002"), createPeriod("200003"), createPeriod("200004"), createPeriod("200005"), createPeriod("200006"), createPeriod("200007"), createPeriod("200008"), createPeriod("200009"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableName(ANALYTICS_TABLE_NAME).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(4, queryGroups.getAllQueries().size());
assertEquals(2, queryGroups.getSequentialQueries().size());
assertEquals(3, 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 testGetFromAnalyticalObjectA.
@Test
public void testGetFromAnalyticalObjectA() {
Chart chart = new Chart();
chart.setSeries(DimensionalObject.DATA_X_DIM_ID);
chart.setCategory(DimensionalObject.ORGUNIT_DIM_ID);
chart.getFilterDimensions().add(DimensionalObject.PERIOD_DIM_ID);
chart.addDataDimensionItem(deA);
chart.addDataDimensionItem(deB);
chart.addDataDimensionItem(deC);
chart.getOrganisationUnits().add(ouA);
chart.getOrganisationUnits().add(ouB);
chart.getPeriods().add(PeriodType.getPeriodFromIsoString("2012"));
DataQueryParams params = dataQueryService.getFromAnalyticalObject(chart);
assertNotNull(params);
assertEquals(3, params.getDataElements().size());
assertEquals(2, params.getOrganisationUnits().size());
assertEquals(1, params.getFilterPeriods().size());
assertEquals(2, params.getDimensions().size());
assertEquals(1, params.getFilters().size());
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlC.
@Test
public void testGetFromUrlC() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem() + ";" + pdA.getDimensionItem() + ";" + pdB.getDimensionItem());
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.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(2, params.getDataElements().size());
assertEquals(2, params.getProgramDataElements().size());
assertEquals(1, params.getFilterOrganisationUnits().size());
}
use of org.hisp.dhis.analytics.DataQueryParams in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlB.
@Test
public void testGetFromUrlB() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem() + ";" + deC.getDimensionItem() + ";" + deD.getUid());
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);
assertEquals(4, params.getDataElements().size());
assertEquals(1, params.getFilterOrganisationUnits().size());
}
Aggregations