use of org.hisp.dhis.analytics.QueryPlannerParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryDataElementGroupSetDisaggregation.
/**
* Query is type disaggregation as aggregation period type for periods is
* monthly and data element groups period type is yearly. Split on two org
* units.
*/
@Test
void planQueryDataElementGroupSetDisaggregation() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElementGroupSet(dgsB).withOrganisationUnits(getList(ouA, ouB)).withPeriods(getList(createPeriod("201001"), createPeriod("201003"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(2, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(2, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
assertNotNull(query.getDataPeriodType());
assertEquals(yearly, query.getDataPeriodType());
assertTrue(query.isDisaggregation());
}
}
use of org.hisp.dhis.analytics.QueryPlannerParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryDataElementDisaggregation.
/**
* Query is type disaggregation as aggregation period type for periods is
* monthly and data elements period type is yearly. Split on two data
* elements.
*/
@Test
void planQueryDataElementDisaggregation() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deI, deJ)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD)).withPeriods(getList(createPeriod("201001"), createPeriod("201003"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(4, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(4, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
assertNotNull(query.getDataPeriodType());
assertEquals(yearly, query.getDataPeriodType());
assertTrue(query.isDisaggregation());
}
}
use of org.hisp.dhis.analytics.QueryPlannerParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryM.
/**
* Splits in 4 queries for data elements to satisfy optimal for a total of 4
* queries.
*/
@Test
void planQueryM() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB, deG, deH)).withOrganisationUnits(getList(ouA)).withPeriods(getList(createPeriod("200101"), createPeriod("200103"))).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(4, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(4, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
use of org.hisp.dhis.analytics.QueryPlannerParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryAggregationTypeA.
/**
* Split on two data elements. Set aggregation type average and value type
* integer on query. Convert aggregation type from data elements to average
* and then to average integer.
*/
@Test
void planQueryAggregationTypeA() {
DataElement deA = createDataElement('A', ValueType.INTEGER, AggregationType.SUM);
DataElement deB = createDataElement('B', ValueType.INTEGER, AggregationType.COUNT);
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA, deB)).withOrganisationUnits(getList(ouA)).withPeriods(getList(createPeriod("200101"))).withAggregationType(AnalyticsAggregationType.AVERAGE).build();
QueryPlannerParams plannerParams = QueryPlannerParams.newBuilder().withOptimalQueries(4).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(2, queryGroups.getAllQueries().size());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertNotNull(query.getAggregationType());
assertEquals(AggregationType.AVERAGE, query.getAggregationType().getAggregationType());
assertEquals(DataType.NUMERIC, query.getAggregationType().getDataType());
}
}
use of org.hisp.dhis.analytics.QueryPlannerParams in project dhis2-core by dhis2.
the class QueryPlannerTest method planQueryF.
/**
* Splits on 3 queries on organisation units for an optimal of 3 queries.
*/
@Test
void planQueryF() {
DataQueryParams params = DataQueryParams.newBuilder().withDataElements(getList(deA)).withOrganisationUnits(getList(ouA, ouB, ouC, ouD, ouE)).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).withTableType(ANALYTICS_TABLE_TYPE).build();
DataQueryGroups queryGroups = queryPlanner.planQuery(params, plannerParams);
assertEquals(3, queryGroups.getAllQueries().size());
assertEquals(1, queryGroups.getSequentialQueries().size());
assertEquals(3, queryGroups.getLargestGroupSize());
for (DataQueryParams query : queryGroups.getAllQueries()) {
assertTrue(samePeriodType(query.getPeriods()));
assertDimensionNameNotNull(query);
}
}
Aggregations