use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.
the class MergeServiceTest method testIndicatorClone.
@Test
public void testIndicatorClone() {
IndicatorType indicatorType = createIndicatorType('A');
Indicator indicator = createIndicator('A', indicatorType);
Indicator clone = mergeService.clone(indicator);
assertEquals(indicator.getName(), clone.getName());
assertEquals(indicator.getUid(), clone.getUid());
assertEquals(indicator.getCode(), clone.getCode());
assertEquals(indicator.getIndicatorType(), clone.getIndicatorType());
}
use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.
the class ObjectBundleServiceTest method testCreateMetadataWithIndicator.
@Test
public void testCreateMetadataWithIndicator() throws IOException {
Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/metadata_with_indicators.json").getInputStream(), RenderFormat.JSON);
ObjectBundleParams params = new ObjectBundleParams();
params.setObjectBundleMode(ObjectBundleMode.COMMIT);
params.setImportStrategy(ImportStrategy.CREATE);
params.setObjects(metadata);
ObjectBundle bundle = objectBundleService.create(params);
ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
assertTrue(validate.getErrorReports().isEmpty());
objectBundleService.commit(bundle);
List<OrganisationUnit> organisationUnits = manager.getAll(OrganisationUnit.class);
List<DataElement> dataElements = manager.getAll(DataElement.class);
List<Indicator> indicators = manager.getAll(Indicator.class);
assertFalse(organisationUnits.isEmpty());
assertEquals(3, dataElements.size());
assertEquals(1, indicators.size());
}
use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.
the class ExpressionServiceTest method testGetIndicatorValue.
@Test
public void testGetIndicatorValue() {
IndicatorType indicatorType = new IndicatorType("A", 100, false);
Indicator indicatorA = createIndicator('A', indicatorType);
indicatorA.setNumerator(expressionE);
indicatorA.setDenominator(expressionF);
Indicator indicatorB = createIndicator('B', indicatorType);
indicatorB.setNumerator(expressionN);
indicatorB.setDenominator(expressionF);
Map<DataElementOperand, Double> valueMap = new HashMap<>();
valueMap.put(new DataElementOperand(deA, coc), 12d);
valueMap.put(new DataElementOperand(deB, coc), 34d);
valueMap.put(new DataElementOperand(deA, cocA, cocB), 46d);
valueMap.put(new DataElementOperand(deB, cocA), 10d);
Map<String, Double> constantMap = new HashMap<>();
constantMap.put(constantA.getUid(), 2.0);
assertEquals(200d, expressionService.getIndicatorValue(indicatorA, period, valueMap, constantMap, null), DELTA);
assertEquals(300d, expressionService.getIndicatorValue(indicatorB, period, valueMap, constantMap, null), DELTA);
}
use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.
the class ExpressionServiceTest method testGetIndicatorValueObject.
@Test
public void testGetIndicatorValueObject() {
IndicatorType indicatorType = new IndicatorType("A", 100, false);
Indicator indicatorA = createIndicator('A', indicatorType);
indicatorA.setNumerator(expressionE);
indicatorA.setDenominator(expressionF);
Indicator indicatorB = createIndicator('B', indicatorType);
indicatorB.setNumerator(expressionN);
indicatorB.setDenominator(expressionF);
Map<DataElementOperand, Double> valueMap = new HashMap<>();
valueMap.put(new DataElementOperand(deA, coc), 12d);
valueMap.put(new DataElementOperand(deB, coc), 34d);
valueMap.put(new DataElementOperand(deA, cocA, cocB), 46d);
valueMap.put(new DataElementOperand(deB, cocA), 10d);
Map<String, Double> constantMap = new HashMap<>();
constantMap.put(constantA.getUid(), 2.0);
IndicatorValue value = expressionService.getIndicatorValueObject(indicatorA, period, valueMap, constantMap, null);
assertEquals(24d, value.getNumeratorValue(), DELTA);
assertEquals(12d, value.getDenominatorValue(), DELTA);
assertEquals(100, value.getFactor());
assertEquals(200d, value.getValue(), DELTA);
value = expressionService.getIndicatorValueObject(indicatorB, period, valueMap, constantMap, null);
assertEquals(36d, value.getNumeratorValue(), DELTA);
assertEquals(12d, value.getDenominatorValue(), DELTA);
assertEquals(100, value.getFactor());
assertEquals(300d, value.getValue(), DELTA);
}
use of org.hisp.dhis.indicator.Indicator in project dhis2-core by dhis2.
the class ChartStoreTest method setUpTest.
// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@Override
public void setUpTest() {
// ---------------------------------------------------------------------
// 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);
// units.add( unitC );
chartA = createChart('A', indicators, periods, units);
chartB = createChart('B', indicators, periods, units);
chartC = createChart('C', indicators, periods, units);
}
Aggregations