use of org.hisp.dhis.indicator.IndicatorGroup in project dhis2-core by dhis2.
the class DataQueryServiceDimensionItemKeywordTest method convertAnalyticsRequestWithIndicatorGroup.
@Test
void convertAnalyticsRequestWithIndicatorGroup() {
final String INDICATOR_GROUP_UID = "oehv9EO3vP7";
when(dimensionService.getDataDimensionalItemObject(UID, "cYeuwXTCPkU")).thenReturn(new DataElement());
IndicatorGroup indicatorGroup = new IndicatorGroup("dummy");
indicatorGroup.setUid(INDICATOR_GROUP_UID);
indicatorGroup.setCode("CODE_10");
indicatorGroup.setMembers(Sets.newHashSet(new Indicator(), new Indicator()));
when(idObjectManager.getObject(IndicatorGroup.class, UID, INDICATOR_GROUP_UID)).thenReturn(indicatorGroup);
when(idObjectManager.getObject(OrganisationUnit.class, UID, "goRUwCHPg1M")).thenReturn(new OrganisationUnit("aaa"));
when(idObjectManager.getObject(OrganisationUnit.class, UID, "fdc6uOvgoji")).thenReturn(new OrganisationUnit("bbb"));
rb.addOuFilter("goRUwCHPg1M;fdc6uOvgoji");
rb.addDimension("IN_GROUP-" + INDICATOR_GROUP_UID + ";cYeuwXTCPkU;Jtf34kNZhz");
rb.addPeDimension(PERIOD_DIMENSION);
DataQueryRequest request = DataQueryRequest.newBuilder().filter(rb.getFilterParams()).dimension(rb.getDimensionParams()).build();
DataQueryParams params = target.getFromRequest(request);
DimensionalObject dimension = params.getDimension("dx");
assertThat(dimension.getDimensionItemKeywords().getKeywords(), hasSize(1));
DimensionItemKeywords.Keyword aggregation = dimension.getDimensionItemKeywords().getKeywords().get(0);
assertThat(aggregation.getMetadataItem().getUid(), is(indicatorGroup.getUid()));
assertThat(aggregation.getMetadataItem().getCode(), is(indicatorGroup.getCode()));
assertThat(aggregation.getMetadataItem().getName(), is(indicatorGroup.getName()));
}
use of org.hisp.dhis.indicator.IndicatorGroup in project dhis2-core by dhis2.
the class DhisConvenienceTest method createIndicatorGroup.
/**
* @param uniqueCharacter A unique character to identify the object.
*/
public static IndicatorGroup createIndicatorGroup(char uniqueCharacter) {
IndicatorGroup group = new IndicatorGroup();
group.setAutoFields();
group.setUid(BASE_UID + uniqueCharacter);
group.setName("IndicatorGroup" + uniqueCharacter);
return group;
}
use of org.hisp.dhis.indicator.IndicatorGroup in project dhis2-core by dhis2.
the class ConfigurationController method setInfrastructuralIndicators.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@PostMapping("/infrastructuralIndicators")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void setInfrastructuralIndicators(@RequestBody String uid) throws NotFoundException {
uid = trim(uid);
IndicatorGroup group = identifiableObjectManager.get(IndicatorGroup.class, uid);
if (group == null) {
throw new NotFoundException("Indicator group", uid);
}
Configuration configuration = configurationService.getConfiguration();
configuration.setInfrastructuralIndicators(group);
configurationService.setConfiguration(configuration);
}
Aggregations