Search in sources :

Example 1 with IndicatorType

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

the class AbstractWebApiTest method createTestObject.

@SuppressWarnings("unchecked")
protected T createTestObject(Class<?> clazz, char uniqueName, Object... params) {
    if (DataElementGroup.class.isAssignableFrom(clazz)) {
        return (T) createDataElementGroup(uniqueName);
    } else if (DataElementCategoryCombo.class.isAssignableFrom(clazz)) {
        return (T) createCategoryCombo(uniqueName, Arrays.copyOf(params, params.length, DataElementCategory[].class));
    } else if (DataElementCategoryOption.class.isAssignableFrom(clazz)) {
        return (T) createCategoryOption(uniqueName);
    } else if (DataElement.class.isAssignableFrom(clazz)) {
        return (T) createDataElement(uniqueName);
    } else if (DataElementCategory.class.isAssignableFrom(clazz)) {
        return (T) createDataElementCategory(uniqueName, Arrays.copyOf(params, params.length, DataElementCategoryOption[].class));
    } else if (Program.class.isAssignableFrom(clazz)) {
        OrganisationUnit organisationUnitA = createOrganisationUnit(uniqueName);
        manager.save(organisationUnitA);
        return (T) createProgram(uniqueName, new HashSet<>(), organisationUnitA);
    } else if (DataElementOperand.class.isAssignableFrom(clazz)) {
        DataElement deA = createDataElement(uniqueName);
        manager.save(deA);
        DataElementCategoryCombo cc = createCategoryCombo(uniqueName);
        DataElementCategoryOption co = createCategoryOption(uniqueName);
        manager.save(cc);
        manager.save(co);
        DataElementCategoryOptionCombo coc = createCategoryOptionCombo(cc, co);
        manager.save(coc);
        return (T) new DataElementOperand(deA, coc);
    } else if (DataElementGroupSet.class.isAssignableFrom(clazz)) {
        return (T) createDataElementGroupSet(uniqueName);
    } else if (DataElementCategoryOptionCombo.class.isAssignableFrom(clazz)) {
        DataElementCategoryCombo cc = createCategoryCombo(uniqueName);
        DataElementCategoryOption co = createCategoryOption(uniqueName);
        manager.save(cc);
        manager.save(co);
        return (T) createCategoryOptionCombo(cc, co);
    } else if (CategoryOptionGroup.class.isAssignableFrom(clazz)) {
        DataElementCategoryOption co = createCategoryOption(uniqueName);
        manager.save(co);
        return (T) createCategoryOptionGroup(uniqueName, co);
    } else if (CategoryOptionGroupSet.class.isAssignableFrom(clazz)) {
        return (T) createCategoryOptionGroupSet(uniqueName);
    } else if (EventChart.class.isAssignableFrom(clazz)) {
        Program prA = createProgram(uniqueName);
        manager.save(prA);
        EventChart ecA = new EventChart("evc" + uniqueName);
        ecA.setProgram(prA);
        ecA.setType(ChartType.COLUMN);
        return (T) ecA;
    } else if (EventReport.class.isAssignableFrom(clazz)) {
        Program prA = createProgram(uniqueName);
        manager.save(prA);
        EventReport erA = new EventReport("er" + uniqueName);
        erA.setProgram(prA);
        return (T) erA;
    } else if (ProgramDataElementDimensionItem.class.isAssignableFrom(clazz)) {
        Program prA = createProgram(uniqueName);
        manager.save(prA);
        DataElement deA = createDataElement(uniqueName);
        manager.save(deA);
        return (T) new ProgramDataElementDimensionItem(prA, deA);
    } else if (ProgramIndicator.class.isAssignableFrom(clazz)) {
        Program program = (Program) createTestObject(Program.class, uniqueName);
        manager.save(program);
        Constant constantA = createConstant(uniqueName, 7.0);
        manager.save(constantA);
        String expressionA = "( " + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.VAR_ENROLLMENT_DATE + "} - " + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.VAR_INCIDENT_DATE + "} )  / " + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}";
        return (T) createProgramIndicator(uniqueName, program, expressionA, null);
    } else if (Indicator.class.isAssignableFrom(clazz)) {
        IndicatorType indicatorType = createIndicatorType(uniqueName);
        manager.save(indicatorType);
        return (T) createIndicator(uniqueName, indicatorType);
    } else if (IndicatorGroup.class.isAssignableFrom(clazz)) {
        return (T) createIndicatorGroup(uniqueName);
    } else if (IndicatorGroupSet.class.isAssignableFrom(clazz)) {
        return (T) createIndicatorGroupSet(uniqueName);
    } else if (IndicatorType.class.isAssignableFrom(clazz)) {
        return (T) createIndicatorType(uniqueName);
    } else if (Legend.class.isAssignableFrom(clazz)) {
        return (T) createLegend(uniqueName, 0d, 10d);
    } else if (LegendSet.class.isAssignableFrom(clazz)) {
        return (T) createLegendSet(uniqueName);
    } else if (OrganisationUnit.class.isAssignableFrom(clazz)) {
        return (T) createOrganisationUnit(uniqueName);
    } else if (OrganisationUnitGroup.class.isAssignableFrom(clazz)) {
        return (T) createOrganisationUnitGroup(uniqueName);
    } else if (OrganisationUnitGroupSet.class.isAssignableFrom(clazz)) {
        return (T) createOrganisationUnitGroupSet(uniqueName);
    } else if (OrganisationUnitLevel.class.isAssignableFrom(clazz)) {
        return (T) new OrganisationUnitLevel(uniqueName, "OrgLevel" + uniqueName);
    } else if (Color.class.isAssignableFrom(clazz)) {
        Color color = new Color("#ff3200");
        color.setName("Color" + uniqueName);
        return (T) color;
    } else if (ColorSet.class.isAssignableFrom(clazz)) {
        ColorSet colorSet = new ColorSet();
        colorSet.setName("ColorSet" + uniqueName);
        return (T) colorSet;
    } else if (org.hisp.dhis.mapping.Map.class.isAssignableFrom(clazz)) {
        org.hisp.dhis.mapping.Map map = new org.hisp.dhis.mapping.Map();
        map.setName("Map" + uniqueName);
        map.setDisplayName("DisplayName" + uniqueName);
        map.setLatitude(952175.62553525);
        map.setLongitude(-1378543.6774686);
        return (T) map;
    } else if (ExternalMapLayer.class.isAssignableFrom(clazz)) {
        ExternalMapLayer externalMapLayer = new ExternalMapLayer("ExternalMapLayer" + uniqueName);
        externalMapLayer.setMapService(MapService.WMS);
        externalMapLayer.setUrl("testUrl");
        externalMapLayer.setImageFormat(ImageFormat.JPG);
        externalMapLayer.setMapLayerPosition(MapLayerPosition.BASEMAP);
        return (T) externalMapLayer;
    } else if (OptionGroup.class.isAssignableFrom(clazz)) {
        OptionGroup optionGroup = new OptionGroup("OptionGroup" + uniqueName);
        optionGroup.setShortName("Group" + uniqueName);
        return (T) optionGroup;
    } else if (OptionGroupSet.class.isAssignableFrom(clazz)) {
        return (T) new OptionGroupSet("OptionGroupSet" + uniqueName);
    } else if (Option.class.isAssignableFrom(clazz)) {
        return (T) new Option("Option" + uniqueName, "code" + uniqueName);
    } else if (OptionSet.class.isAssignableFrom(clazz)) {
        return (T) new OptionSet("OptionSet" + uniqueName, ValueType.TEXT);
    } else if (ProgramTrackedEntityAttributeGroup.class.isAssignableFrom(clazz)) {
        ProgramTrackedEntityAttributeGroup group = createProgramTrackedEntityAttributeGroup(uniqueName);
        ProgramTrackedEntityAttribute attr = createProgramTrackedEntityAttribute(uniqueName);
        group.addAttribute(attr);
        return (T) group;
    } else if (ProgramTrackedEntityAttribute.class.isAssignableFrom(clazz)) {
        return (T) createProgramTrackedEntityAttribute(uniqueName);
    } else if (ProgramDataElementDimensionItem.class.isAssignableFrom(clazz)) {
        return (T) createProgramDataElement(uniqueName);
    }
    return null;
}
Also used : ColorSet(org.hisp.dhis.color.ColorSet) OptionGroupSet(org.hisp.dhis.option.OptionGroupSet) CategoryOptionGroupSet(org.hisp.dhis.dataelement.CategoryOptionGroupSet) ExternalMapLayer(org.hisp.dhis.mapping.ExternalMapLayer) Legend(org.hisp.dhis.legend.Legend) DataElementCategoryCombo(org.hisp.dhis.dataelement.DataElementCategoryCombo) Constant(org.hisp.dhis.constant.Constant) EventReport(org.hisp.dhis.eventreport.EventReport) DataElement(org.hisp.dhis.dataelement.DataElement) CategoryOptionGroup(org.hisp.dhis.dataelement.CategoryOptionGroup) IndicatorType(org.hisp.dhis.indicator.IndicatorType) OptionGroup(org.hisp.dhis.option.OptionGroup) CategoryOptionGroup(org.hisp.dhis.dataelement.CategoryOptionGroup) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) Program(org.hisp.dhis.program.Program) Color(org.hisp.dhis.color.Color) EventChart(org.hisp.dhis.eventchart.EventChart) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) Indicator(org.hisp.dhis.indicator.Indicator) DataElementGroupSet(org.hisp.dhis.dataelement.DataElementGroupSet) ProgramDataElementDimensionItem(org.hisp.dhis.program.ProgramDataElementDimensionItem) IndicatorGroupSet(org.hisp.dhis.indicator.IndicatorGroupSet) DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) Option(org.hisp.dhis.option.Option) ProgramTrackedEntityAttributeGroup(org.hisp.dhis.program.ProgramTrackedEntityAttributeGroup) OptionSet(org.hisp.dhis.option.OptionSet) Map(java.util.Map) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) OrganisationUnitGroupSet(org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)

Example 2 with IndicatorType

use of org.hisp.dhis.indicator.IndicatorType 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)

Example 3 with IndicatorType

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

the class AnalyticsServiceTest method setUpTest.

// Database (value, data element, period)
// --------------------------------------------------------------------
//
// A: 2, deA, peJan - 4, deB, peFeb - 6, deC, peMar - 8, deD, peApril
// 100, deB, peJan - 2, deD, peFeb
//
// B: 1, deA, peJan - 3, deB, peFeb - 5, deC, peMar - 7, deD, peApril
//
// C: 5, deA, peJan - 10, deB, peFeb - 15, deC, peMar - 20, deD, peApril
// 4, deD, peJan - 23, deC, peFeb
//
// D: 66, deA, peJan - 233, deA, peFeb - 399, deB, peFeb
//
// E: 1, deA, peJan - 1, deB, peFeb - 1, deC, peMar - 1, deD, peApril
// 32, deD, peJan
//
// --------------------------------------------------------------------
@Override
public void setUpTest() throws IOException {
    // Set up meta data for data values
    // --------------------------------------------------------------------
    ReportingRate reportingRateA;
    ReportingRate reportingRateB;
    ocDef = categoryService.getDefaultDataElementCategoryOptionCombo();
    ocDef.setUid("o1234578def");
    categoryService.updateDataElementCategoryOptionCombo(ocDef);
    Period peJan = createPeriod("2017-01");
    Period peFeb = createPeriod("2017-02");
    Period peMar = createPeriod("2017-03");
    Period peApril = createPeriod("2017-04");
    Period quarter = createPeriod("2017Q1");
    periodService.addPeriod(peJan);
    periodService.addPeriod(peFeb);
    periodService.addPeriod(peMar);
    periodService.addPeriod(peApril);
    DataElement deA = createDataElement('A');
    DataElement deB = createDataElement('B');
    DataElement deC = createDataElement('C');
    DataElement deD = createDataElement('D');
    dataElementService.addDataElement(deA);
    dataElementService.addDataElement(deB);
    dataElementService.addDataElement(deC);
    dataElementService.addDataElement(deD);
    OrganisationUnit ouA = createOrganisationUnit('A');
    OrganisationUnit ouB = createOrganisationUnit('B');
    OrganisationUnit ouC = createOrganisationUnit('C');
    ouC.setOpeningDate(getDate(2016, 4, 10));
    ouC.setClosedDate(null);
    OrganisationUnit ouD = createOrganisationUnit('D');
    ouD.setOpeningDate(getDate(2016, 12, 10));
    ouD.setClosedDate(null);
    OrganisationUnit ouE = createOrganisationUnit('E');
    AnalyticsTestUtils.configureHierarchy(ouA, ouB, ouC, ouD, ouE);
    organisationUnitService.addOrganisationUnit(ouA);
    organisationUnitService.addOrganisationUnit(ouB);
    organisationUnitService.addOrganisationUnit(ouC);
    organisationUnitService.addOrganisationUnit(ouD);
    organisationUnitService.addOrganisationUnit(ouE);
    idObjectManager.save(ouA);
    idObjectManager.save(ouB);
    idObjectManager.save(ouC);
    idObjectManager.save(ouD);
    idObjectManager.save(ouE);
    OrganisationUnitGroup organisationUnitGroupA = createOrganisationUnitGroup('A');
    organisationUnitGroupA.setUid("a2345groupA");
    organisationUnitGroupA.addOrganisationUnit(ouA);
    organisationUnitGroupA.addOrganisationUnit(ouB);
    OrganisationUnitGroup organisationUnitGroupB = createOrganisationUnitGroup('B');
    organisationUnitGroupB.setUid("a2345groupB");
    organisationUnitGroupB.addOrganisationUnit(ouC);
    organisationUnitGroupB.addOrganisationUnit(ouD);
    organisationUnitGroupB.addOrganisationUnit(ouE);
    OrganisationUnitGroup organisationUnitGroupC = createOrganisationUnitGroup('C');
    organisationUnitGroupC.setUid("a2345groupC");
    organisationUnitGroupC.addOrganisationUnit(ouA);
    organisationUnitGroupC.addOrganisationUnit(ouB);
    organisationUnitGroupC.addOrganisationUnit(ouC);
    OrganisationUnitGroup organisationUnitGroupD = createOrganisationUnitGroup('D');
    organisationUnitGroupD.setUid("a2345groupD");
    organisationUnitGroupD.addOrganisationUnit(ouD);
    organisationUnitGroupD.addOrganisationUnit(ouE);
    organisationUnitGroupService.addOrganisationUnitGroup(organisationUnitGroupA);
    organisationUnitGroupService.addOrganisationUnitGroup(organisationUnitGroupB);
    organisationUnitGroupService.addOrganisationUnitGroup(organisationUnitGroupC);
    organisationUnitGroupService.addOrganisationUnitGroup(organisationUnitGroupD);
    OrganisationUnitGroupSet organisationUnitGroupSetA = createOrganisationUnitGroupSet('A');
    organisationUnitGroupSetA.setUid("a234567setA");
    OrganisationUnitGroupSet organisationUnitGroupSetB = createOrganisationUnitGroupSet('B');
    organisationUnitGroupSetB.setUid("a234567setB");
    organisationUnitGroupSetA.getOrganisationUnitGroups().add(organisationUnitGroupA);
    organisationUnitGroupSetA.getOrganisationUnitGroups().add(organisationUnitGroupB);
    organisationUnitGroupSetB.getOrganisationUnitGroups().add(organisationUnitGroupC);
    organisationUnitGroupSetB.getOrganisationUnitGroups().add(organisationUnitGroupD);
    organisationUnitGroupService.addOrganisationUnitGroupSet(organisationUnitGroupSetA);
    organisationUnitGroupService.addOrganisationUnitGroupSet(organisationUnitGroupSetB);
    DataSet dataSetA = createDataSet('A');
    dataSetA.setUid("a23dataSetA");
    dataSetA.addOrganisationUnit(ouD);
    dataSetA.addOrganisationUnit(ouC);
    DataSet dataSetB = createDataSet('B');
    dataSetB.setUid("a23dataSetB");
    dataSetB.addOrganisationUnit(ouD);
    dataSetService.addDataSet(dataSetA);
    dataSetService.addDataSet(dataSetB);
    // Read data values from CSV files
    // --------------------------------------------------------------------
    ArrayList<String[]> dataValueLines = AnalyticsTestUtils.readInputFile("csv/dataValues.csv");
    parseDataValues(dataValueLines);
    ArrayList<String[]> dataSetRegistrationLines = AnalyticsTestUtils.readInputFile("csv/dataSetRegistrations.csv");
    parseDataSetRegistrations(dataSetRegistrationLines);
    // Make indicators
    // --------------------------------------------------------------------
    IndicatorType indicatorType_1 = createIndicatorType('A');
    indicatorType_1.setFactor(1);
    indicatorService.addIndicatorType(indicatorType_1);
    // deA
    Indicator indicatorA = createIndicator('A', indicatorType_1);
    String expressionA = "#{" + deA.getUid() + "." + ocDef.getUid() + "}";
    indicatorA.setNumerator(expressionA);
    indicatorA.setDenominator("1");
    // deB + deC
    Indicator indicatorB = createIndicator('B', indicatorType_1);
    String expressionB = "#{" + deB.getUid() + "." + ocDef.getUid() + "}" + "+#{" + deC.getUid() + "." + ocDef.getUid() + "}";
    indicatorB.setNumerator(expressionB);
    indicatorB.setDenominator("1");
    // (deB * deC) / 100
    Indicator indicatorC = createIndicator('C', indicatorType_1);
    String expressionC = "#{" + deB.getUid() + "." + ocDef.getUid() + "}" + "*#{" + deC.getUid() + "." + ocDef.getUid() + "}";
    indicatorC.setNumerator(expressionC);
    indicatorC.setDenominator("100");
    // (deA * deC) / deB
    Indicator indicatorD = createIndicator('D', indicatorType_1);
    String expressionD = "#{" + deA.getUid() + "." + ocDef.getUid() + "}" + "*#{" + deC.getUid() + "." + ocDef.getUid() + "}";
    indicatorD.setNumerator(expressionD);
    indicatorD.setDenominator("#{" + deB.getUid() + "." + ocDef.getUid() + "}");
    // deA * reporting rate B
    Indicator indicatorE = createIndicator('E', indicatorType_1);
    reportingRateA = new ReportingRate(dataSetA);
    reportingRateB = new ReportingRate(dataSetB);
    String expressionE = "#{" + deA.getUid() + "." + ocDef.getUid() + "}" + "*(R{" + reportingRateB.getUid() + ".REPORTING_RATE} / 100)";
    indicatorE.setNumerator(expressionE);
    indicatorE.setDenominator("1");
    // deA * reporting rate A
    Indicator indicatorF = createIndicator('F', indicatorType_1);
    String expressionF = "#{" + deA.getUid() + "." + ocDef.getUid() + "}" + "*(R{" + reportingRateA.getUid() + ".REPORTING_RATE} / 100)";
    indicatorF.setNumerator(expressionF);
    indicatorF.setDenominator("1");
    indicatorService.addIndicator(indicatorA);
    indicatorService.addIndicator(indicatorB);
    indicatorService.addIndicator(indicatorC);
    indicatorService.addIndicator(indicatorD);
    indicatorService.addIndicator(indicatorE);
    indicatorService.addIndicator(indicatorF);
    // Generate analytics tables
    // --------------------------------------------------------------------
    analyticsTableGenerator.generateTables(null, null, null, false);
    // Set parameters
    // --------------------------------------------------------------------
    List<Indicator> param_indicators = new ArrayList<>();
    List<ReportingRate> param_reportingRates = new ArrayList<>();
    // all org units - 2017
    Period y2017 = createPeriod("2017");
    DataQueryParams ou_2017_params = DataQueryParams.newBuilder().withOrganisationUnits(organisationUnitService.getAllOrganisationUnits()).withAggregationType(AggregationType.SUM).withPeriod(y2017).withOutputFormat(OutputFormat.ANALYTICS).build();
    // all org units - jan 2017
    Period y2017_jan = createPeriod("2017-01");
    DataQueryParams ou_2017_01_params = DataQueryParams.newBuilder().withOrganisationUnits(organisationUnitService.getAllOrganisationUnits()).withAggregationType(AggregationType.SUM).withPeriod(y2017_jan).withOutputFormat(OutputFormat.ANALYTICS).build();
    // org unit B - feb 2017
    Period y2017_feb = createPeriod("2017-02");
    DataQueryParams ouB_2017_02_params = DataQueryParams.newBuilder().withOrganisationUnit(ouB).withAggregationType(AggregationType.SUM).withPeriod(y2017_feb).withOutputFormat(OutputFormat.ANALYTICS).build();
    // all data elements - mar 2017
    Period y2017_mar = createPeriod("2017-03");
    DataQueryParams de_avg_2017_03_params = DataQueryParams.newBuilder().withDataElements(dataElementService.getAllDataElements()).withAggregationType(AggregationType.AVERAGE).withSkipRounding(true).withPeriod(y2017_mar).withOutputFormat(OutputFormat.ANALYTICS).build();
    // org unit B - data element C - mar 2017
    List<DataElement> dataElements1 = new ArrayList<>();
    dataElements1.add(deC);
    DataQueryParams deC_ouB_2017_03_params = DataQueryParams.newBuilder().withOrganisationUnit(ouB).withDataElements(dataElements1).withAggregationType(AggregationType.SUM).withPeriod(y2017_mar).withOutputFormat(OutputFormat.ANALYTICS).build();
    AnalyticalObject deC_ouB_2017_03_analytical = new ReportTable("deC_ouB_2017_03", dataElements1, param_indicators, param_reportingRates, Lists.newArrayList(y2017_mar), Lists.newArrayList(ouB), false, true, true, null, null, null);
    // org unit A - data element A - Q1 2017
    List<DataElement> dataElements2 = new ArrayList<>();
    dataElements2.add(deA);
    DataQueryParams deA_ouA_2017_Q01_params = DataQueryParams.newBuilder().withOrganisationUnit(ouA).withDataElements(dataElements2).withAggregationType(AggregationType.SUM).withPeriod(quarter).withOutputFormat(OutputFormat.ANALYTICS).build();
    AnalyticalObject deA_ouA_2017_Q01_analytical = new ReportTable("deA_ouA_2017_Q01", dataElements2, param_indicators, param_reportingRates, Lists.newArrayList(quarter), Lists.newArrayList(ouA), false, true, true, null, null, null);
    // org units B and C - feb 2017
    DataQueryParams ouB_ouC_2017_02_params = DataQueryParams.newBuilder().withFilterOrganisationUnits(Lists.newArrayList(ouB, ouC)).withAggregationType(AggregationType.SUM).withPeriod(y2017_feb).withOutputFormat(OutputFormat.ANALYTICS).build();
    // org unit A - jan and feb 2017
    DataQueryParams ouA_2017_01_03_params = DataQueryParams.newBuilder().withOrganisationUnit(ouA).withFilterPeriods(Lists.newArrayList(peJan, peMar)).withAggregationType(AggregationType.SUM).withOutputFormat(OutputFormat.ANALYTICS).build();
    // org unit B - Q1 2017
    DataQueryParams ouB_2017_Q01_params = DataQueryParams.newBuilder().withOrganisationUnit(ouB).withPeriod(quarter).withAggregationType(AggregationType.SUM).withOutputFormat(OutputFormat.ANALYTICS).build();
    // org unit C - Q1 2017
    DataQueryParams ouC_2017_Q01_params = DataQueryParams.newBuilder().withOrganisationUnit(ouC).withPeriod(quarter).withAggregationType(AggregationType.SUM).withOutputFormat(OutputFormat.ANALYTICS).build();
    // indicator A - 2017
    DataQueryParams inA_2017_params = DataQueryParams.newBuilder().withIndicators(Lists.newArrayList(indicatorA)).withAggregationType(AggregationType.SUM).withPeriod(y2017).withOutputFormat(OutputFormat.ANALYTICS).build();
    // indicator B (deB + deC) - 2017 Q1
    DataQueryParams inB_deB_deC_2017_Q01_params = DataQueryParams.newBuilder().withIndicators(Lists.newArrayList(indicatorB)).withAggregationType(AggregationType.SUM).withPeriod(quarter).withOutputFormat(OutputFormat.ANALYTICS).build();
    // indicator C (deB * deC) in hundreds - 2017 Q1
    List<Indicator> param_indicators3 = new ArrayList<>();
    param_indicators3.add(indicatorC);
    DataQueryParams inC_deB_deC_2017_Q01_params = DataQueryParams.newBuilder().withIndicators(param_indicators3).withAggregationType(AggregationType.SUM).withPeriod(quarter).withOutputFormat(OutputFormat.ANALYTICS).build();
    AnalyticalObject inC_deB_deC_2017_Q01_analytical = new ReportTable("deA_ouA_2017_Q01", Lists.newArrayList(), param_indicators3, param_reportingRates, Lists.newArrayList(quarter), Lists.newArrayList(ouA), true, true, true, null, null, null);
    // indicator D (deA * deC)/deB - 2017 Q1
    DataQueryParams inD_deA_deB_deC_2017_Q01_params = DataQueryParams.newBuilder().withIndicators(Lists.newArrayList(indicatorD)).withAggregationType(AggregationType.SUM).withPeriod(quarter).withOutputFormat(OutputFormat.ANALYTICS).build();
    // indicator E (deA * reporting rate B) / 100 - 2017 Q1
    DataQueryParams inE_deA_reRateA_2017_Q01_params = DataQueryParams.newBuilder().withOrganisationUnit(ouD).withIndicators(Lists.newArrayList(indicatorE)).withAggregationType(AggregationType.SUM).withPeriod(quarter).withOutputFormat(OutputFormat.ANALYTICS).build();
    // indicator E (deA * reporting rate A) / 100 - 2017 Q1
    DataQueryParams inF_deA_reRateB_2017_Q01_params = DataQueryParams.newBuilder().withOrganisationUnit(ouD).withIndicators(Lists.newArrayList(indicatorF)).withAggregationType(AggregationType.SUM).withPeriod(quarter).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Max value - org unit B and C - data element A - 2017 Feb
    DataQueryParams deA_ouB_ouC_2017_02_params = DataQueryParams.newBuilder().withFilterOrganisationUnits(Lists.newArrayList(ouB, ouC)).withDataElements(Lists.newArrayList(deA)).withAggregationType(AggregationType.MAX).withPeriod(peFeb).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Average value - org unit C and E - data element A, B and D - 2017 April
    DataQueryParams deA_deB_deD_ouC_ouE_2017_04_params = DataQueryParams.newBuilder().withFilterOrganisationUnits(Lists.newArrayList(ouC, ouE)).withDataElements(Lists.newArrayList(deA, deB, deD)).withAggregationType(AggregationType.AVERAGE).withOutputFormat(OutputFormat.ANALYTICS).withPeriod(peApril).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Sum org unit B - 2017-01-01 -> 2017-02-20
    DataQueryParams ouB_2017_01_01_2017_02_20_params = DataQueryParams.newBuilder().withDataElements(Lists.newArrayList(deA, deB)).withOrganisationUnit(ouB).withStartDate(getDate(2017, 1, 1)).withEndDate(getDate(2017, 2, 20)).withAggregationType(AggregationType.SUM).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Sum org unit B - 2017-01-01 -> 2017-02-20
    DataQueryParams ouB_2017_02_10_2017_06_20_params = DataQueryParams.newBuilder().withOrganisationUnit(ouB).withStartDate(getDate(2017, 2, 10)).withEndDate(getDate(2017, 6, 20)).withAggregationType(AggregationType.SUM).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Sum org group set A - 2017
    DataQueryParams ouGroupSetA_2017_params = DataQueryParams.newBuilder().withDimensions(Lists.newArrayList(organisationUnitGroupSetA)).withAggregationType(AggregationType.SUM).withPeriod(y2017).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Sum org group set B - 2017
    DataQueryParams ouGroupSetB_2017_03_params = DataQueryParams.newBuilder().withDimensions(Lists.newArrayList(organisationUnitGroupSetB)).withAggregationType(AggregationType.SUM).withPeriod(y2017_mar).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Reportingrate for dataSet A - Q1 2017
    DataQueryParams reRate_2017_Q01_ouC_params = DataQueryParams.newBuilder().withOrganisationUnit(ouC).withReportingRates(Lists.newArrayList(reportingRateA)).withPeriod(quarter).withAggregationType(AggregationType.SUM).withOutputFormat(OutputFormat.ANALYTICS).build();
    // Reportingrate for dataSet B - Q1 2017
    DataQueryParams reRate_2017_Q01_ouD_params = DataQueryParams.newBuilder().withOrganisationUnit(ouD).withReportingRates(Lists.newArrayList(reportingRateB)).withPeriod(quarter).withAggregationType(AggregationType.SUM).withOutputFormat(OutputFormat.ANALYTICS).build();
    dataQueryParams.put("ou_2017", ou_2017_params);
    dataQueryParams.put("ou_2017_01", ou_2017_01_params);
    dataQueryParams.put("ouB_2017_02", ouB_2017_02_params);
    dataQueryParams.put("de_avg_2017_03", de_avg_2017_03_params);
    dataQueryParams.put("deC_ouB_2017_03", deC_ouB_2017_03_params);
    dataQueryParams.put("deA_ouA_2017_Q01", deA_ouA_2017_Q01_params);
    dataQueryParams.put("ouB__ouC_2017_02", ouB_ouC_2017_02_params);
    dataQueryParams.put("ouA_2017_01_03", ouA_2017_01_03_params);
    dataQueryParams.put("ouB_2017_Q01", ouB_2017_Q01_params);
    dataQueryParams.put("ouC_2017_Q01", ouC_2017_Q01_params);
    dataQueryParams.put("inA_2017", inA_2017_params);
    dataQueryParams.put("inB_deB_deC_2017_Q01", inB_deB_deC_2017_Q01_params);
    dataQueryParams.put("inC_deB_deC_2017_Q01", inC_deB_deC_2017_Q01_params);
    dataQueryParams.put("inD_deA_deB_deC_2017_Q01", inD_deA_deB_deC_2017_Q01_params);
    dataQueryParams.put("inE_deA_reRateA_2017_Q01", inE_deA_reRateA_2017_Q01_params);
    dataQueryParams.put("inF_deA_reRateB_2017_Q01", inF_deA_reRateB_2017_Q01_params);
    dataQueryParams.put("deA_ouB_ouC_2017_02", deA_ouB_ouC_2017_02_params);
    dataQueryParams.put("deA_deB_deD_ouC_ouE_2017_04", deA_deB_deD_ouC_ouE_2017_04_params);
    dataQueryParams.put("ouB_2017_01_01_2017_02_20", ouB_2017_01_01_2017_02_20_params);
    dataQueryParams.put("ouB_2017_02_10_2017_06_20", ouB_2017_02_10_2017_06_20_params);
    dataQueryParams.put("ouGroupSetA_2017", ouGroupSetA_2017_params);
    dataQueryParams.put("ouGroupSetB_2017_03", ouGroupSetB_2017_03_params);
    dataQueryParams.put("reRate_2017_Q01_ouC", reRate_2017_Q01_ouC_params);
    dataQueryParams.put("reRate_2017_Q01_ouD", reRate_2017_Q01_ouD_params);
    analyticalObjectHashMap.put("deC_ouB_2017_03", deC_ouB_2017_03_analytical);
    analyticalObjectHashMap.put("deA_ouA_2017_Q01", deA_ouA_2017_Q01_analytical);
    analyticalObjectHashMap.put("inC_deB_deC_2017_Q01", inC_deB_deC_2017_Q01_analytical);
    // Set results
    // --------------------------------------------------------------------
    Map<String, Double> ou_2017_keyValue = new HashMap<>();
    ou_2017_keyValue.put("ouabcdefghA-2017", 949.0);
    ou_2017_keyValue.put("ouabcdefghB-2017", 750.0);
    ou_2017_keyValue.put("ouabcdefghC-2017", 77.0);
    ou_2017_keyValue.put("ouabcdefghD-2017", 698.0);
    ou_2017_keyValue.put("ouabcdefghE-2017", 36.0);
    Map<String, Double> ou_2017_01_keyValue = new HashMap<>();
    ou_2017_01_keyValue.put("ouabcdefghA-201701", 211.0);
    ou_2017_01_keyValue.put("ouabcdefghB-201701", 100.0);
    ou_2017_01_keyValue.put("ouabcdefghC-201701", 9.0);
    ou_2017_01_keyValue.put("ouabcdefghD-201701", 66.0);
    ou_2017_01_keyValue.put("ouabcdefghE-201701", 33.0);
    Map<String, Double> ouB_2017_02_keyValue = new HashMap<>();
    ouB_2017_02_keyValue.put("ouabcdefghB-201702", 636.00);
    Map<String, Double> de_avg_2017_03_keyValue = new HashMap<>();
    de_avg_2017_03_keyValue.put("deabcdefghC-201703", 6.75);
    Map<String, Double> deC_ouB_2017_03_keyValue = new HashMap<>();
    deC_ouB_2017_03_keyValue.put("deabcdefghC-ouabcdefghB-201703", 6.0);
    deC_ouB_2017_03_keyValue.put("deabcdefghC-201703-ouabcdefghB", 6.0);
    Map<String, Double> deA_ouA_2017_Q01_keyValue = new HashMap<>();
    deA_ouA_2017_Q01_keyValue.put("deabcdefghA-ouabcdefghA-2017Q1", 308.0);
    deA_ouA_2017_Q01_keyValue.put("deabcdefghA-2017Q1-ouabcdefghA", 308.0);
    Map<String, Double> ouB_ouC_2017_02_keyValue = new HashMap<>();
    ouB_ouC_2017_02_keyValue.put("201702", 669.0);
    Map<String, Double> ouA_2017_01_03_keyValue = new HashMap<>();
    ouA_2017_01_03_keyValue.put("ouabcdefghA", 238.0);
    Map<String, Double> ouB_2017_Q01_keyValue = new HashMap<>();
    ouB_2017_Q01_keyValue.put("ouabcdefghB-2017Q1", 742.0);
    Map<String, Double> ouC_2017_Q01_keyValue = new HashMap<>();
    ouC_2017_Q01_keyValue.put("ouabcdefghC-2017Q1", 57.0);
    Map<String, Double> inA_2017_keyValue = new HashMap<>();
    inA_2017_keyValue.put("inabcdefghA-2017", 308.0);
    Map<String, Double> inB_deB_deC_2017_Q01_keyValue = new HashMap<>();
    inB_deB_deC_2017_Q01_keyValue.put("inabcdefghB-2017Q1", 567.0);
    Map<String, Double> inC_deB_deC_2017_Q01_keyValue = new HashMap<>();
    inC_deB_deC_2017_Q01_keyValue.put("inabcdefghC-2017Q1", 258.50);
    inC_deB_deC_2017_Q01_keyValue.put("inabcdefghC-2017Q1-ouabcdefghA", 258.50);
    Map<String, Double> inD_deA_deB_deC_2017_Q01_keyValue = new HashMap<>();
    inD_deA_deB_deC_2017_Q01_keyValue.put("inabcdefghD-2017Q1", 29.8);
    Map<String, Double> inE_deA_reRateA_2017_Q01_keyValue = new HashMap<>();
    inE_deA_reRateA_2017_Q01_keyValue.put("inabcdefghE-ouabcdefghD-2017Q1", 99.6);
    Map<String, Double> inF_deA_reRateB_2017_Q01_keyValue = new HashMap<>();
    inF_deA_reRateB_2017_Q01_keyValue.put("inabcdefghF-ouabcdefghD-2017Q1", 199.4);
    Map<String, Double> deA_ouB_ouC_2017_02_keyValue = new HashMap<>();
    deA_ouB_ouC_2017_02_keyValue.put("deabcdefghA-201702", 233.0);
    Map<String, Double> deA_deB_deD_ouC_ouE_2017_04_keyValue = new HashMap<>();
    deA_deB_deD_ouC_ouE_2017_04_keyValue.put("deabcdefghD-201704", 10.5);
    Map<String, Double> deA_deB_2017_Q01_keyValue = new HashMap<>();
    deA_deB_2017_Q01_keyValue.put("2017Q1", 53.3);
    Map<String, Double> ouB_2017_01_01_2017_02_20_keyValue = new HashMap<>();
    ouB_2017_01_01_2017_02_20_keyValue.put("deabcdefghA-ouabcdefghB", 68.0);
    Map<String, Double> ouB_2017_02_10_2017_06_20_keyValue = new HashMap<>();
    ouB_2017_02_10_2017_06_20_keyValue.put("ouabcdefghB", 14.0);
    Map<String, Double> ouGroupSetA_2017_keyValue = new HashMap<>();
    ouGroupSetA_2017_keyValue.put("a2345groupA-2017", 138.0);
    ouGroupSetA_2017_keyValue.put("a2345groupB-2017", 811.0);
    Map<String, Double> ouGroupSetB_2017_03_keyValue = new HashMap<>();
    ouGroupSetB_2017_03_keyValue.put("a2345groupC-201703", 26.0);
    ouGroupSetB_2017_03_keyValue.put("a2345groupD-201703", 1.0);
    Map<String, Double> reRate_2017_Q01_ouC_keyValue = new HashMap<>();
    reRate_2017_Q01_ouC_keyValue.put("a23dataSetA.REPORTING_RATE-ouabcdefghC-2017Q1", 100.0);
    Map<String, Double> reRate_2017_Q01_ouD_keyValue = new HashMap<>();
    reRate_2017_Q01_ouD_keyValue.put("a23dataSetB.REPORTING_RATE-ouabcdefghD-2017Q1", 33.3);
    results.put("ou_2017", ou_2017_keyValue);
    results.put("ou_2017_01", ou_2017_01_keyValue);
    results.put("ouB_2017_02", ouB_2017_02_keyValue);
    results.put("de_avg_2017_03", de_avg_2017_03_keyValue);
    results.put("deC_ouB_2017_03", deC_ouB_2017_03_keyValue);
    results.put("deA_ouA_2017_Q01", deA_ouA_2017_Q01_keyValue);
    results.put("ouB__ouC_2017_02", ouB_ouC_2017_02_keyValue);
    results.put("ouA_2017_01_03", ouA_2017_01_03_keyValue);
    results.put("ouB_2017_Q01", ouB_2017_Q01_keyValue);
    results.put("ouC_2017_Q01", ouC_2017_Q01_keyValue);
    results.put("inA_2017", inA_2017_keyValue);
    results.put("inB_deB_deC_2017_Q01", inB_deB_deC_2017_Q01_keyValue);
    results.put("inC_deB_deC_2017_Q01", inC_deB_deC_2017_Q01_keyValue);
    results.put("inD_deA_deB_deC_2017_Q01", inD_deA_deB_deC_2017_Q01_keyValue);
    results.put("inE_deA_reRateA_2017_Q01", inE_deA_reRateA_2017_Q01_keyValue);
    results.put("inF_deA_reRateB_2017_Q01", inF_deA_reRateB_2017_Q01_keyValue);
    results.put("deA_ouB_ouC_2017_02", deA_ouB_ouC_2017_02_keyValue);
    results.put("deA_deB_deD_ouC_ouE_2017_04", deA_deB_deD_ouC_ouE_2017_04_keyValue);
    results.put("deA_deB_2017_Q01", deA_deB_2017_Q01_keyValue);
    results.put("ouB_2017_01_01_2017_02_20", ouB_2017_01_01_2017_02_20_keyValue);
    results.put("ouB_2017_02_10_2017_06_20", ouB_2017_02_10_2017_06_20_keyValue);
    results.put("ouGroupSetA_2017", ouGroupSetA_2017_keyValue);
    results.put("ouGroupSetB_2017_03", ouGroupSetB_2017_03_keyValue);
    results.put("reRate_2017_Q01_ouC", reRate_2017_Q01_ouC_keyValue);
    results.put("reRate_2017_Q01_ouD", reRate_2017_Q01_ouD_keyValue);
}
Also used : ReportingRate(org.hisp.dhis.common.ReportingRate) DataSet(org.hisp.dhis.dataset.DataSet) Period(org.hisp.dhis.period.Period) ReportTable(org.hisp.dhis.reporttable.ReportTable) Indicator(org.hisp.dhis.indicator.Indicator) DataElement(org.hisp.dhis.dataelement.DataElement) IndicatorType(org.hisp.dhis.indicator.IndicatorType) AnalyticalObject(org.hisp.dhis.common.AnalyticalObject)

Example 4 with IndicatorType

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

the class AnalyticsUtilsTest method testHandleGridForDataValueSet.

@Test
public void testHandleGridForDataValueSet() {
    IndicatorType itA = new IndicatorType();
    DataElementCategoryOptionCombo ocA = createCategoryOptionCombo('A');
    ocA.setUid("ceabcdefghA");
    DataElement dxA = createDataElement('A');
    dxA.setUid("deabcdefghA");
    dxA.setValueType(ValueType.INTEGER);
    DataElement dxB = createDataElement('B');
    dxB.setUid("deabcdefghB");
    dxB.setValueType(ValueType.NUMBER);
    Indicator dxC = createIndicator('C', itA);
    dxC.setUid("deabcdefghC");
    dxC.setDecimals(0);
    dxC.setAggregateExportAttributeOptionCombo("ceabcdefghA");
    Indicator dxD = createIndicator('D', itA);
    dxD.setUid("deabcdefghD");
    dxD.setDecimals(2);
    dxD.setAggregateExportCategoryOptionCombo("ceabcdefghB");
    DataElementOperand dxE = new DataElementOperand(dxA, ocA);
    DataElementOperand dxF = new DataElementOperand(dxB, ocA);
    DataQueryParams params = DataQueryParams.newBuilder().addDimension(new BaseDimensionalObject(DATA_X_DIM_ID, DimensionType.DATA_X, Lists.newArrayList(dxA, dxB, dxC, dxD, dxE, dxF))).build();
    Grid grid = new ListGrid();
    grid.addHeader(new GridHeader(DimensionalObject.DATA_X_DIM_ID));
    grid.addHeader(new GridHeader(DimensionalObject.ORGUNIT_DIM_ID));
    grid.addHeader(new GridHeader(DimensionalObject.PERIOD_DIM_ID));
    grid.addHeader(new GridHeader(VALUE_ID, VALUE_HEADER_NAME, ValueType.NUMBER, Double.class.getName(), false, false));
    grid.addRow().addValuesAsList(Lists.newArrayList("deabcdefghA", "ouA", "peA", 1d));
    grid.addRow().addValuesAsList(Lists.newArrayList("deabcdefghB", "ouA", "peA", 2d));
    grid.addRow().addValuesAsList(Lists.newArrayList("deabcdefghC", "ouA", "peA", 3d));
    grid.addRow().addValuesAsList(Lists.newArrayList("deabcdefghD", "ouA", "peA", 4d));
    grid.addRow().addValuesAsList(Lists.newArrayList("deabcdefghA.ceabcdefghA", "ouA", "peA", 5d));
    grid.addRow().addValuesAsList(Lists.newArrayList("deabcdefghB.ceabcdefghA", "ouA", "peA", 6d));
    assertEquals(4, grid.getWidth());
    assertEquals(6, grid.getHeight());
    AnalyticsUtils.handleGridForDataValueSet(params, grid);
    assertEquals(6, grid.getWidth());
    assertEquals(6, grid.getHeight());
    assertEquals("deabcdefghA", grid.getRow(0).get(0));
    assertNull(grid.getRow(0).get(3));
    assertNull(grid.getRow(0).get(4));
    assertEquals(1, grid.getRow(0).get(5));
    assertEquals("deabcdefghB", grid.getRow(1).get(0));
    assertNull(grid.getRow(1).get(3));
    assertNull(grid.getRow(1).get(4));
    assertEquals(2d, (Double) grid.getRow(1).get(5), 0.01);
    assertEquals("deabcdefghC", grid.getRow(2).get(0));
    assertNull(grid.getRow(2).get(3));
    assertEquals("ceabcdefghA", grid.getRow(2).get(4));
    assertEquals(3, grid.getRow(2).get(5));
    assertEquals("deabcdefghD", grid.getRow(3).get(0));
    assertEquals("ceabcdefghB", grid.getRow(3).get(3));
    assertNull(grid.getRow(3).get(4));
    assertEquals(4d, (Double) grid.getRow(3).get(5), 0.01);
    assertEquals("deabcdefghA", grid.getRow(4).get(0));
    assertEquals("ceabcdefghA", grid.getRow(4).get(3));
    assertNull(grid.getRow(4).get(4));
    assertEquals(5, grid.getRow(4).get(5));
    assertEquals("deabcdefghB", grid.getRow(5).get(0));
    assertEquals("ceabcdefghA", grid.getRow(5).get(3));
    assertNull(grid.getRow(5).get(4));
    assertEquals(6d, (Double) grid.getRow(5).get(5), 0.01);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataElementOperand(org.hisp.dhis.dataelement.DataElementOperand) IndicatorType(org.hisp.dhis.indicator.IndicatorType) ListGrid(org.hisp.dhis.system.grid.ListGrid) ListGrid(org.hisp.dhis.system.grid.ListGrid) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) Indicator(org.hisp.dhis.indicator.Indicator) ProgramIndicator(org.hisp.dhis.program.ProgramIndicator) Test(org.junit.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Example 5 with IndicatorType

use of org.hisp.dhis.indicator.IndicatorType 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());
}
Also used : IndicatorType(org.hisp.dhis.indicator.IndicatorType) Indicator(org.hisp.dhis.indicator.Indicator) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

IndicatorType (org.hisp.dhis.indicator.IndicatorType)9 Indicator (org.hisp.dhis.indicator.Indicator)8 ProgramIndicator (org.hisp.dhis.program.ProgramIndicator)4 Test (org.junit.Test)4 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 DataElement (org.hisp.dhis.dataelement.DataElement)3 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 Period (org.hisp.dhis.period.Period)3 ArrayList (java.util.ArrayList)2 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)2 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)2 MonthlyPeriodType (org.hisp.dhis.period.MonthlyPeriodType)2 PeriodType (org.hisp.dhis.period.PeriodType)2 Map (java.util.Map)1 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)1 Color (org.hisp.dhis.color.Color)1 ColorSet (org.hisp.dhis.color.ColorSet)1 AnalyticalObject (org.hisp.dhis.common.AnalyticalObject)1 ReportingRate (org.hisp.dhis.common.ReportingRate)1 Constant (org.hisp.dhis.constant.Constant)1