Search in sources :

Example 6 with IndicatorGroup

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()));
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataQueryParams(org.hisp.dhis.analytics.DataQueryParams) IndicatorGroup(org.hisp.dhis.indicator.IndicatorGroup) DimensionItemKeywords(org.hisp.dhis.common.DimensionItemKeywords) DataQueryRequest(org.hisp.dhis.common.DataQueryRequest) Indicator(org.hisp.dhis.indicator.Indicator) DimensionalObject(org.hisp.dhis.common.DimensionalObject) Test(org.junit.jupiter.api.Test)

Example 7 with IndicatorGroup

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;
}
Also used : IndicatorGroup(org.hisp.dhis.indicator.IndicatorGroup)

Example 8 with IndicatorGroup

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);
}
Also used : IndicatorGroup(org.hisp.dhis.indicator.IndicatorGroup) Configuration(org.hisp.dhis.configuration.Configuration) NotFoundException(org.hisp.dhis.webapi.controller.exception.NotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

IndicatorGroup (org.hisp.dhis.indicator.IndicatorGroup)8 ArrayList (java.util.ArrayList)4 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)4 DimensionItemKeywords (org.hisp.dhis.common.DimensionItemKeywords)4 Indicator (org.hisp.dhis.indicator.Indicator)4 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 DataQueryRequest (org.hisp.dhis.common.DataQueryRequest)3 DimensionalObject (org.hisp.dhis.common.DimensionalObject)3 Test (org.junit.jupiter.api.Test)3 HashMap (java.util.HashMap)2 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)2 BaseNameableObject (org.hisp.dhis.common.BaseNameableObject)2 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)2 User (org.hisp.dhis.user.User)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 LocalDate (java.time.LocalDate)1 ZoneId (java.time.ZoneId)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1