Search in sources :

Example 1 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class DhisConvenienceTest method createIndicator.

/**
     * @param uniqueCharacter A unique character to identify the object.
     * @param type            The type.
     */
public static Indicator createIndicator(char uniqueCharacter, IndicatorType type) {
    Indicator indicator = new Indicator();
    indicator.setAutoFields();
    indicator.setUid(BASE_IN_UID + uniqueCharacter);
    indicator.setName("Indicator" + uniqueCharacter);
    indicator.setShortName("IndicatorShort" + uniqueCharacter);
    indicator.setCode("IndicatorCode" + uniqueCharacter);
    indicator.setDescription("IndicatorDescription" + uniqueCharacter);
    indicator.setAnnualized(false);
    indicator.setIndicatorType(type);
    indicator.setNumerator("Numerator");
    indicator.setNumeratorDescription("NumeratorDescription");
    indicator.setDenominator("Denominator");
    indicator.setDenominatorDescription("DenominatorDescription");
    return indicator;
}
Also used : Indicator(org.hisp.dhis.indicator.Indicator) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator)

Example 2 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class ChartController method getChart.

@RequestMapping(value = { "/data", "/data.png" }, method = RequestMethod.GET)
public void getChart(@RequestParam(value = "in") String indicatorUid, @RequestParam(value = "ou") String organisationUnitUid, @RequestParam(value = "periods", required = false) boolean periods, @RequestParam(value = "width", defaultValue = "800", required = false) int width, @RequestParam(value = "height", defaultValue = "500", required = false) int height, @RequestParam(value = "skipTitle", required = false) boolean skipTitle, @RequestParam(value = "attachment", required = false) boolean attachment, HttpServletResponse response) throws IOException {
    Indicator indicator = indicatorService.getIndicator(indicatorUid);
    OrganisationUnit unit = organisationUnitService.getOrganisationUnit(organisationUnitUid);
    JFreeChart chart;
    if (periods) {
        chart = chartService.getJFreePeriodChart(indicator, unit, !skipTitle, i18nManager.getI18nFormat());
    } else {
        chart = chartService.getJFreeOrganisationUnitChart(indicator, unit, !skipTitle, i18nManager.getI18nFormat());
    }
    contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "chart.png", attachment);
    ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, width, height);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Indicator(org.hisp.dhis.indicator.Indicator) JFreeChart(org.jfree.chart.JFreeChart) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class DefaultExpressionService method getOrganisationUnitGroupsInIndicators.

@Override
public Set<OrganisationUnitGroup> getOrganisationUnitGroupsInIndicators(Collection<Indicator> indicators) {
    Set<OrganisationUnitGroup> groups = new HashSet<>();
    if (indicators != null) {
        for (Indicator indicator : indicators) {
            groups.addAll(getOrganisationUnitGroupsInExpression(indicator.getNumerator()));
            groups.addAll(getOrganisationUnitGroupsInExpression(indicator.getDenominator()));
        }
    }
    return groups;
}
Also used : OrganisationUnitGroup(org.hisp.dhis.organisationunit.OrganisationUnitGroup) Indicator(org.hisp.dhis.indicator.Indicator) HashSet(java.util.HashSet)

Example 4 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class ExpressionServiceTest method testGetDimensionalItemObjectsInIndicators.

@Test
public void testGetDimensionalItemObjectsInIndicators() {
    Indicator indicator = createIndicator('A', null);
    indicator.setNumerator(expressionI);
    indicator.setDenominator(expressionA);
    Set<Indicator> indicators = Sets.newHashSet(indicator);
    Set<DimensionalItemObject> items = expressionService.getDimensionalItemObjectsInIndicators(indicators);
    assertEquals(6, items.size());
    assertTrue(items.contains(opA));
    assertTrue(items.contains(opB));
    assertTrue(items.contains(deB));
    assertTrue(items.contains(piA));
}
Also used : Indicator(org.hisp.dhis.indicator.Indicator) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 5 with Indicator

use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.

the class ChartServiceTest method setUpTest.

// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() throws Exception {
    // ---------------------------------------------------------------------
    // Indicator
    // ---------------------------------------------------------------------
    IndicatorType indicatorType = createIndicatorType('A');
    indicatorA = createIndicator('A', indicatorType);
    indicatorB = createIndicator('B', indicatorType);
    indicatorC = createIndicator('C', indicatorType);
    indicatorService.addIndicatorType(indicatorType);
    indicatorService.addIndicator(indicatorA);
    indicatorService.addIndicator(indicatorB);
    indicatorService.addIndicator(indicatorC);
    List<Indicator> indicators = new ArrayList<>();
    indicators.add(indicatorA);
    indicators.add(indicatorB);
    indicators.add(indicatorC);
    // ---------------------------------------------------------------------
    // Period
    // ---------------------------------------------------------------------
    PeriodType periodType = new MonthlyPeriodType();
    periodA = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 1, 2));
    periodB = createPeriod(periodType, getDate(2000, 1, 3), getDate(2000, 1, 4));
    periodC = createPeriod(periodType, getDate(2000, 1, 5), getDate(2000, 1, 6));
    periodService.addPeriod(periodA);
    periodService.addPeriod(periodB);
    periodService.addPeriod(periodC);
    List<Period> periods = new ArrayList<>();
    periods.add(periodA);
    periods.add(periodB);
    periods.add(periodC);
    // ---------------------------------------------------------------------
    // OrganisationUnit
    // ---------------------------------------------------------------------
    unitA = createOrganisationUnit('A');
    unitB = createOrganisationUnit('B');
    organisationUnitService.addOrganisationUnit(unitA);
    organisationUnitService.addOrganisationUnit(unitB);
    List<OrganisationUnit> units = new ArrayList<>();
    units.add(unitA);
    units.add(unitB);
    chartA = createChart('A', indicators, periods, units);
    chartA.setType(ChartType.BAR);
    chartB = createChart('B', indicators, periods, units);
    chartB.setType(ChartType.BAR);
    chartC = createChart('C', indicators, periods, units);
    chartC.setType(ChartType.BAR);
}
Also used : MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) PeriodType(org.hisp.dhis.period.PeriodType) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) IndicatorType(org.hisp.dhis.indicator.IndicatorType) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) Indicator(org.hisp.dhis.indicator.Indicator)

Aggregations

Indicator (org.hisp.dhis.indicator.Indicator)23 Test (org.junit.Test)8 DataElement (org.hisp.dhis.dataelement.DataElement)7 IndicatorType (org.hisp.dhis.indicator.IndicatorType)7 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)7 ProgramIndicator (org.hisp.dhis.program.ProgramIndicator)7 DhisSpringTest (org.hisp.dhis.DhisSpringTest)5 Period (org.hisp.dhis.period.Period)5 DataSet (org.hisp.dhis.dataset.DataSet)4 ArrayList (java.util.ArrayList)3 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)3 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Matcher (java.util.regex.Matcher)2 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 DimensionalObject (org.hisp.dhis.common.DimensionalObject)2 IndicatorGroupSet (org.hisp.dhis.indicator.IndicatorGroupSet)2 IndicatorValue (org.hisp.dhis.indicator.IndicatorValue)2