use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlRelativePeriods.
@Test
void testGetFromUrlRelativePeriods() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem() + ";" + deC.getDimensionItem() + ";" + deD.getDimensionItem());
dimensionParams.add("pe:LAST_12_MONTHS");
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getDimensionItem() + ";" + ouB.getDimensionItem());
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(4, params.getDataElements().size());
assertEquals(12, params.getPeriods().size());
assertEquals(2, params.getFilterOrganisationUnits().size());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlUserOrgUnit.
@Test
void testGetFromUrlUserOrgUnit() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("ou:" + OrganisationUnit.KEY_USER_ORGUNIT);
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem());
dimensionParams.add("pe:2011;2012");
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(1, params.getOrganisationUnits().size());
assertEquals(2, params.getDataElements().size());
assertEquals(2, params.getPeriods().size());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlWithCodeB.
@Test
void testGetFromUrlWithCodeB() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getCode() + ";" + deB.getCode() + ";" + inA.getCode());
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getCode());
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).inputIdScheme(IdScheme.CODE).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(2, params.getDataElements().size());
assertEquals(1, params.getIndicators().size());
assertEquals(1, params.getFilterOrganisationUnits().size());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlPeriodOrder.
@Test
void testGetFromUrlPeriodOrder() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getUid() + ";" + deB.getUid() + ";" + deC.getUid() + ";" + deD.getUid());
dimensionParams.add("pe:2013;2012Q4;2012S2");
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getUid());
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
List<DimensionalItemObject> periods = params.getPeriods();
assertEquals(3, periods.size());
assertEquals("2013", periods.get(0).getUid());
assertEquals("2012Q4", periods.get(1).getUid());
assertEquals("2012S2", periods.get(2).getUid());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceDimensionItemKeywordTest method convertAnalyticsRequestWithOuLevelToDataQueryParam.
@Test
void convertAnalyticsRequestWithOuLevelToDataQueryParam() {
mockDimensionService();
when(organisationUnitService.getOrganisationUnitLevelByLevel(2)).thenReturn(buildOrgUnitLevel(2, "level2UID", "District", null));
when(organisationUnitService.getOrganisationUnitLevelByLevelOrUid("2")).thenReturn(2);
when(organisationUnitService.getOrganisationUnitsAtLevels(Mockito.anyList(), Mockito.anyList())).thenReturn(Lists.newArrayList(new OrganisationUnit(), new OrganisationUnit()));
rb.addOuFilter("LEVEL-2;ImspTQPwCqd");
rb.addDimension(concatenateUuid(DATA_ELEMENT_1, DATA_ELEMENT_2, DATA_ELEMENT_3));
rb.addPeDimension(PERIOD_DIMENSION);
DataQueryRequest request = DataQueryRequest.newBuilder().filter(rb.getFilterParams()).dimension(rb.getDimensionParams()).build();
DataQueryParams params = target.getFromRequest(request);
DimensionalObject filter = params.getFilters().get(0);
DimensionItemKeywords keywords = filter.getDimensionItemKeywords();
assertEquals(1, keywords.getKeywords().size());
assertNotNull(keywords.getKeyword("level2UID"));
assertEquals("District", keywords.getKeyword("level2UID").getMetadataItem().getName());
assertNull(keywords.getKeyword("level2UID").getMetadataItem().getCode());
}
Aggregations