Search in sources :

Example 1 with EventQueryParams

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);
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 2 with EventQueryParams

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());
    }
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) QueryItem(org.hisp.dhis.common.QueryItem) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 3 with EventQueryParams

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());
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) Partitions(org.hisp.dhis.analytics.Partitions) DateTime(org.joda.time.DateTime) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 4 with EventQueryParams

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));
}
Also used : EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) Partitions(org.hisp.dhis.analytics.Partitions) DateTime(org.joda.time.DateTime) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 5 with EventQueryParams

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());
}
Also used : TrackedEntityAttributeDimension(org.hisp.dhis.trackedentity.TrackedEntityAttributeDimension) EventQueryParams(org.hisp.dhis.analytics.event.EventQueryParams) EventChart(org.hisp.dhis.eventchart.EventChart) TrackedEntityDataElementDimension(org.hisp.dhis.trackedentity.TrackedEntityDataElementDimension) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

EventQueryParams (org.hisp.dhis.analytics.event.EventQueryParams)42 Test (org.junit.Test)20 DhisSpringTest (org.hisp.dhis.DhisSpringTest)18 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)14 Grid (org.hisp.dhis.common.Grid)13 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)12 DateTime (org.joda.time.DateTime)6 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)4 Partitions (org.hisp.dhis.analytics.Partitions)4 QueryItem (org.hisp.dhis.common.QueryItem)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 EventChart (org.hisp.dhis.eventchart.EventChart)3 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 TrackedEntityAttributeDimension (org.hisp.dhis.trackedentity.TrackedEntityAttributeDimension)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 DataElement (org.hisp.dhis.dataelement.DataElement)2