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;
}
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);
}
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;
}
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));
}
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);
}
Aggregations