use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testGetFromUrlLegendSet.
@Test
public void testGetFromUrlLegendSet() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add(deA.getUid() + "-" + legendSetA.getUid() + ":IN:" + legendA.getUid() + ";" + legendB.getUid());
Set<String> filterParams = new HashSet<>();
filterParams.add("pe:201401;201402");
filterParams.add(atA.getUid() + ":LE:5");
EventQueryParams params = dataQueryService.getFromUrl(prA.getUid(), null, null, null, dimensionParams, filterParams, null, null, false, false, false, false, false, false, null, null, null, null, null, false, false, null, null, null, null);
assertEquals(prA, params.getProgram());
assertEquals(1, params.getItems().size());
assertEquals(legendSetA, params.getItems().get(0).getLegendSet());
assertEquals(1, params.getItemFilters().size());
assertEquals(2, params.getFilterPeriods().size());
}
use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testGetFromUrlA.
@Test
public void testGetFromUrlA() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("ou:" + ouA.getUid() + ";" + ouB.getId());
dimensionParams.add(atA.getUid() + ":LE:5");
Set<String> filterParams = new HashSet<>();
filterParams.add("pe:201401;201402");
EventQueryParams params = dataQueryService.getFromUrl(prA.getUid(), null, null, null, dimensionParams, filterParams, null, null, false, false, false, false, false, false, null, null, null, null, null, false, false, null, null, null, null);
assertEquals(prA, params.getProgram());
assertEquals(1, params.getOrganisationUnits().size());
assertEquals(1, params.getItems().size());
assertEquals(2, params.getFilterPeriods().size());
}
use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventQueryPlannerTest method testPlanAggregateQueryC.
@Test
public void testPlanAggregateQueryC() {
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, ouB)).build();
List<EventQueryParams> queries = queryPlanner.planAggregateQuery(params);
assertEquals(2, queries.size());
assertEquals(ouA, queries.get(0).getOrganisationUnits().get(0));
assertEquals(ouB, queries.get(1).getOrganisationUnits().get(0));
}
use of org.hisp.dhis.analytics.event.EventQueryParams in project dhis2-core by dhis2.
the class EventQueryPlannerTest method testPlanAggregateQueryA.
@Test
public void testPlanAggregateQueryA() {
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();
List<EventQueryParams> queries = queryPlanner.planAggregateQuery(params);
assertEquals(1, queries.size());
EventQueryParams query = queries.get(0);
assertEquals(new DateTime(2010, 6, 1, 0, 0).toDate(), query.getStartDate());
assertEquals(new DateTime(2012, 3, 20, 0, 0).toDate(), query.getEndDate());
Partitions partitions = query.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 EventAnalyticsController method getAggregateJson.
// -------------------------------------------------------------------------
// Aggregate
// -------------------------------------------------------------------------
@PreAuthorize("hasRole('ALL') or hasRole('F_VIEW_EVENT_ANALYTICS')")
@RequestMapping(value = RESOURCE_PATH + "/aggregate/{program}", method = RequestMethod.GET, produces = { "application/json", "application/javascript" })
// JSON, JSONP
@ResponseBody
public // JSON, JSONP
Grid getAggregateJson(@PathVariable String program, @RequestParam(required = false) String stage, @RequestParam(required = false) Date startDate, @RequestParam(required = false) Date endDate, @RequestParam Set<String> dimension, @RequestParam(required = false) Set<String> filter, @RequestParam(required = false) String value, @RequestParam(required = false) AggregationType aggregationType, @RequestParam(required = false) boolean skipMeta, @RequestParam(required = false) boolean skipData, @RequestParam(required = false) boolean skipRounding, @RequestParam(required = false) boolean completedOnly, @RequestParam(required = false) boolean hierarchyMeta, @RequestParam(required = false) boolean showHierarchy, @RequestParam(required = false) SortOrder sortOrder, @RequestParam(required = false) Integer limit, @RequestParam(required = false) EventOutputType outputType, @RequestParam(required = false) EventStatus eventStatus, @RequestParam(required = false) ProgramStatus programStatus, @RequestParam(required = false) boolean collapseDataDimensions, @RequestParam(required = false) boolean aggregateData, @RequestParam(required = false) DisplayProperty displayProperty, @RequestParam(required = false) Date relativePeriodDate, @RequestParam(required = false) String userOrgUnit, DhisApiVersion apiVersion, Model model, HttpServletResponse response) throws Exception {
EventQueryParams params = eventDataQueryService.getFromUrl(program, stage, startDate, endDate, dimension, filter, value, aggregationType, skipMeta, skipData, skipRounding, completedOnly, hierarchyMeta, showHierarchy, sortOrder, limit, outputType, eventStatus, programStatus, collapseDataDimensions, aggregateData, displayProperty, relativePeriodDate, userOrgUnit, apiVersion);
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.RESPECT_SYSTEM_SETTING);
return analyticsService.getAggregatedEventData(params);
}
Aggregations