Search in sources :

Example 16 with DataElementCategoryOption

use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.

the class DefaultCsvImportService method categoryOptionsFromCsv.

// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private List<DataElementCategoryOption> categoryOptionsFromCsv(CsvReader reader) throws IOException {
    List<DataElementCategoryOption> list = new ArrayList<>();
    while (reader.readRecord()) {
        String[] values = reader.getValues();
        if (values != null && values.length > 0) {
            DataElementCategoryOption object = new DataElementCategoryOption();
            setIdentifiableObject(object, values);
            object.setShortName(getSafe(values, 3, object.getName(), 50));
            list.add(object);
        }
    }
    return list;
}
Also used : DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) ArrayList(java.util.ArrayList)

Example 17 with DataElementCategoryOption

use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.

the class DhisConvenienceTest method createDataElementCategory.

/**
     * @param categoryUniqueIdentifier A unique character to identify the
     *                                 category.
     * @param categoryOptions          the category options.
     * @return DataElementCategory
     */
public static DataElementCategory createDataElementCategory(char categoryUniqueIdentifier, DataElementCategoryOption... categoryOptions) {
    DataElementCategory dataElementCategory = new DataElementCategory("DataElementCategory" + categoryUniqueIdentifier, DataDimensionType.DISAGGREGATION);
    dataElementCategory.setAutoFields();
    for (DataElementCategoryOption categoryOption : categoryOptions) {
        dataElementCategory.addCategoryOption(categoryOption);
    }
    return dataElementCategory;
}
Also used : DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) DataElementCategory(org.hisp.dhis.dataelement.DataElementCategory)

Example 18 with DataElementCategoryOption

use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.

the class DhisConvenienceTest method createCategoryOptionCombo.

/**
     * @param categoryComboUniqueIdentifier A unique character to identify the
     *                                      category option combo.
     * @param dataElementCategoryCombo      The associated category combination.
     * @param categoryOptions               the category options.
     * @return DataElementCategoryOptionCombo
     */
public static DataElementCategoryOptionCombo createCategoryOptionCombo(char categoryComboUniqueIdentifier, DataElementCategoryCombo dataElementCategoryCombo, DataElementCategoryOption... categoryOptions) {
    DataElementCategoryOptionCombo categoryOptionCombo = new DataElementCategoryOptionCombo();
    categoryOptionCombo.setAutoFields();
    categoryOptionCombo.setCategoryCombo(dataElementCategoryCombo);
    for (DataElementCategoryOption categoryOption : categoryOptions) {
        categoryOptionCombo.getCategoryOptions().add(categoryOption);
        categoryOption.getCategoryOptionCombos().add(categoryOptionCombo);
    }
    return categoryOptionCombo;
}
Also used : DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Example 19 with DataElementCategoryOption

use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.

the class DataValueDimensionTest method testGetDimensions.

@Test
public void testGetDimensions() {
    List<DataElementCategoryOption> categoryOptions = new ArrayList<>();
    categoryOptions.add(male);
    categoryOptions.add(under15);
    DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
    DataValue dataValue = dataValueService.getDataValue(dataElementA, periodA, sourceA, categoryOptionCombo);
    assertNotNull(dataValue);
}
Also used : DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) ArrayList(java.util.ArrayList) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 20 with DataElementCategoryOption

use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.

the class DataValueDimensionTest method testGetByCategoryOptionCombos.

@Test
public void testGetByCategoryOptionCombos() {
    List<DataElementCategoryOption> categoryOptions = new ArrayList<>();
    categoryOptions.add(male);
    categoryOptions.add(under15);
    DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
    assertNotNull(categoryOptionCombo);
    assertEquals(genderAndAgeGroup, categoryOptionCombo.getCategoryCombo());
    assertTrue(CollectionUtils.isEqualCollection(categoryOptions, categoryOptionCombo.getCategoryOptions()));
    categoryOptions.clear();
    categoryOptions.add(female);
    categoryOptions.add(over15);
    categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
    assertNotNull(categoryOptionCombo);
    assertEquals(genderAndAgeGroup, categoryOptionCombo.getCategoryCombo());
    assertTrue(CollectionUtils.isEqualCollection(categoryOptions, categoryOptionCombo.getCategoryOptions()));
    categoryOptions.clear();
    categoryOptions.add(male);
    categoryOptions.add(female);
    categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
    assertNull(categoryOptionCombo);
}
Also used : DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) ArrayList(java.util.ArrayList) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

DataElementCategoryOption (org.hisp.dhis.dataelement.DataElementCategoryOption)27 DataElementCategoryOptionCombo (org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)13 ArrayList (java.util.ArrayList)9 DataElementCategoryCombo (org.hisp.dhis.dataelement.DataElementCategoryCombo)8 DataElementCategory (org.hisp.dhis.dataelement.DataElementCategory)7 DataElement (org.hisp.dhis.dataelement.DataElement)6 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)6 DhisSpringTest (org.hisp.dhis.DhisSpringTest)5 DataSet (org.hisp.dhis.dataset.DataSet)5 Test (org.junit.Test)5 HashSet (java.util.HashSet)4 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)4 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)4 Section (org.hisp.dhis.dataset.Section)4 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 SectionOrderComparator (org.hisp.dhis.dataset.comparator.SectionOrderComparator)3 Collection (java.util.Collection)2 Collections (java.util.Collections)2