use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlB.
@Test
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());
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(4, params.getDataElements().size());
assertEquals(1, params.getFilterOrganisationUnits().size());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlD.
@Test
void testGetFromUrlD() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem() + ";" + patA.getDimensionItem() + ";" + patB.getDimensionItem());
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getDimensionItem());
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(2, params.getDataElements().size());
assertEquals(2, params.getProgramAttributes().size());
assertEquals(1, params.getFilterOrganisationUnits().size());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DimensionController method getRecommendedDimensions.
@GetMapping("/recommendations")
@ResponseBody
public RootNode getRecommendedDimensions(@RequestParam Set<String> dimension) {
List<String> fields = newArrayList(contextService.getParameterValues("fields"));
DataQueryRequest request = DataQueryRequest.newBuilder().dimension(dimension).build();
if (fields.isEmpty()) {
fields.addAll(Preset.defaultPreset().getFields());
}
List<DimensionalObject> dimensions = analyticsDimensionService.getRecommendedDimensions(request);
RootNode rootNode = NodeUtils.createMetadata();
rootNode.addChild(fieldFilterService.toCollectionNode(getEntityClass(), new FieldFilterParams(dimensions, fields)));
return rootNode;
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class AnalyticsController method getRawDataCsv.
@GetMapping(value = RESOURCE_PATH + RAW_DATA_PATH + ".csv")
public void getRawDataCsv(AggregateAnalyticsQueryCriteria criteria, DhisApiVersion apiVersion, HttpServletResponse response) throws Exception {
final DataQueryRequest request = DataQueryRequest.newBuilder().fromCriteria(criteria).apiVersion(apiVersion).allowAllPeriods(true).build();
DataQueryParams params = dataQueryService.getFromRequest(request);
contextUtils.configureAnalyticsResponse(response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, null, false, params.getLatestEndDate());
Grid grid = analyticsService.getRawDataValues(params);
GridUtils.toCsv(grid, response.getWriter());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlOrgUnitGroupSetAllItems.
@Test
void testGetFromUrlOrgUnitGroupSetAllItems() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem() + ";" + deC.getDimensionItem());
dimensionParams.add("pe:2012;2012S1");
dimensionParams.add(ouGroupSetA.getUid());
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getDimensionItem() + ";" + ouB.getDimensionItem() + ";" + ouC.getDimensionItem());
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(3, params.getDataElements().size());
assertEquals(2, params.getPeriods().size());
assertEquals(3, params.getFilterOrganisationUnits().size());
assertEquals(3, params.getDimensionOptions(ouGroupSetA.getUid()).size());
}
Aggregations