use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventQueryPlannerTest method validateFailureNoStartEndDatePeriods.
@Test(expected = IllegalQueryException.class)
public void validateFailureNoStartEndDatePeriods() {
EventQueryParams params = new EventQueryParams.Builder().withProgram(prA).withOrganisationUnits(Lists.newArrayList(ouB)).build();
queryPlanner.validate(params);
}
use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventQueryPlannerTest method testFromDataQueryParams.
@Test
public void testFromDataQueryParams() {
DataQueryParams dataQueryParams = DataQueryParams.newBuilder().withProgramDataElements(getList(pdeA, pdeB, pdeC, pdeD)).withProgramAttributes(getList(patA, patB)).withOrganisationUnits(getList(ouA, ouB, ouC)).withPeriods(getList(createPeriod("200101"), createPeriod("200103"), createPeriod("200105"), createPeriod("200107"))).build();
EventQueryParams params = EventQueryParams.fromDataQueryParams(dataQueryParams);
assertEquals(6, params.getItems().size());
assertNull(params.getDimension(DimensionalObject.DATA_X_DIM_ID));
assertTrue(params.isAggregateData());
for (QueryItem item : params.getItems()) {
assertEquals(prA, item.getProgram());
}
}
use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventQueryPlannerTest method testPlanEventQueryB.
@Test
public void testPlanEventQueryB() {
EventQueryParams params = new EventQueryParams.Builder().withProgram(prA).withStartDate(new DateTime(2010, 3, 1, 0, 0).toDate()).withEndDate(new DateTime(2010, 9, 20, 0, 0).toDate()).withOrganisationUnits(Lists.newArrayList(ouA)).build();
params = queryPlanner.planEventQuery(params);
assertEquals(new DateTime(2010, 3, 1, 0, 0).toDate(), params.getStartDate());
assertEquals(new DateTime(2010, 9, 20, 0, 0).toDate(), params.getEndDate());
Partitions partitions = params.getPartitions();
assertEquals(1, partitions.getPartitions().size());
assertEquals("analytics_event_2010_programuida", partitions.getSinglePartition());
}
use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventQueryPlannerTest method testPlanEventQueryA.
@Test
public void testPlanEventQueryA() {
EventQueryParams params = new EventQueryParams.Builder().withProgram(prA).withStartDate(new DateTime(2010, 6, 1, 0, 0).toDate()).withEndDate(new DateTime(2012, 3, 20, 0, 0).toDate()).withOrganisationUnits(Lists.newArrayList(ouA)).build();
params = queryPlanner.planEventQuery(params);
assertEquals(new DateTime(2010, 6, 1, 0, 0).toDate(), params.getStartDate());
assertEquals(new DateTime(2012, 3, 20, 0, 0).toDate(), params.getEndDate());
Partitions partitions = params.getPartitions();
assertEquals(3, partitions.getPartitions().size());
assertEquals("analytics_event_2010_programuida", partitions.getPartitions().get(0));
assertEquals("analytics_event_2011_programuida", partitions.getPartitions().get(1));
assertEquals("analytics_event_2012_programuida", partitions.getPartitions().get(2));
}
use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testGetFromAnalyticalObjectB.
@Test
public void testGetFromAnalyticalObjectB() {
EventChart eventChart = new EventChart();
eventChart.setAutoFields();
eventChart.setProgram(prA);
eventChart.getColumnDimensions().add(atA.getUid());
eventChart.getColumnDimensions().add(deA.getUid());
eventChart.getRowDimensions().add(DimensionalObject.PERIOD_DIM_ID);
eventChart.getFilterDimensions().add(DimensionalObject.ORGUNIT_DIM_ID);
eventChart.getAttributeDimensions().add(new TrackedEntityAttributeDimension(atA, null, "LE:5"));
eventChart.getDataElementDimensions().add(new TrackedEntityDataElementDimension(deA, null, "GE:100"));
eventChart.getPeriods().add(peA);
eventChart.getPeriods().add(peB);
eventChart.getOrganisationUnits().add(ouA);
eventChart.getOrganisationUnits().add(ouB);
EventQueryParams params = dataQueryService.getFromAnalyticalObject(eventChart);
assertNotNull(params);
assertEquals(2, params.getItems().size());
assertEquals(2, params.getPeriods().size());
assertEquals(2, params.getFilterOrganisationUnits().size());
}
Aggregations