Search in sources :

Example 11 with Category

use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.

the class DefaultAdxDataService method getCodeCategoryMap.

private Map<String, Category> getCodeCategoryMap(CategoryCombo categoryCombo, IdScheme catScheme) throws AdxException {
    Map<String, Category> categoryMap = new HashMap<>();
    List<Category> categories = categoryCombo.getCategories();
    for (Category category : categories) {
        String categoryId = category.getPropertyValue(catScheme);
        if (categoryId == null || !XMLChar.isValidName(categoryId)) {
            throw new AdxException("Category " + catScheme.name() + " for " + category.getName() + " is missing or invalid: " + categoryId);
        }
        categoryMap.put(categoryId, category);
    }
    return categoryMap;
}
Also used : Category(org.hisp.dhis.category.Category) HashMap(java.util.HashMap)

Example 12 with Category

use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.

the class CategoryComboTest method before.

// -------------------------------------------------------------------------
// Fixture
// -------------------------------------------------------------------------
@BeforeEach
void before() {
    categoryOptionA = new CategoryOption("OptionA");
    categoryOptionB = new CategoryOption("OptionB");
    categoryOptionC = new CategoryOption("OptionC");
    categoryOptionD = new CategoryOption("OptionD");
    categoryOptionE = new CategoryOption("OptionE");
    categoryOptionF = new CategoryOption("OptionF");
    categoryA = new Category("CategoryA", DataDimensionType.DISAGGREGATION);
    categoryB = new Category("CategoryB", DataDimensionType.DISAGGREGATION);
    categoryC = new Category("CategoryC", DataDimensionType.DISAGGREGATION);
    categoryA.getCategoryOptions().add(categoryOptionA);
    categoryA.getCategoryOptions().add(categoryOptionB);
    categoryB.getCategoryOptions().add(categoryOptionC);
    categoryB.getCategoryOptions().add(categoryOptionD);
    categoryC.getCategoryOptions().add(categoryOptionE);
    categoryC.getCategoryOptions().add(categoryOptionF);
    categoryOptionA.getCategories().add(categoryA);
    categoryOptionB.getCategories().add(categoryA);
    categoryOptionC.getCategories().add(categoryB);
    categoryOptionD.getCategories().add(categoryB);
    categoryOptionE.getCategories().add(categoryC);
    categoryOptionF.getCategories().add(categoryC);
    categoryCombo = new CategoryCombo("CategoryCombo", DataDimensionType.DISAGGREGATION);
    categoryCombo.getCategories().add(categoryA);
    categoryCombo.getCategories().add(categoryB);
    categoryCombo.getCategories().add(categoryC);
}
Also used : Category(org.hisp.dhis.category.Category) CategoryCombo(org.hisp.dhis.category.CategoryCombo) CategoryOption(org.hisp.dhis.category.CategoryOption) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with Category

use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.

the class TypedIndexedObjectContainerTest method containsObject.

@Test
void containsObject() {
    final Category category1 = new Category();
    final Category category2 = new Category();
    container.add(category1);
    container.add(category2);
    Assertions.assertTrue(container.containsObject(category1));
}
Also used : Category(org.hisp.dhis.category.Category) Test(org.junit.jupiter.api.Test)

Example 14 with Category

use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.

the class TypedIndexedObjectContainerTest method containsObjectNot.

@Test
void containsObjectNot() {
    final Category category1 = new Category();
    final Category category2 = new Category();
    container.add(category1);
    container.add(category2);
    Assertions.assertFalse(container.containsObject(new Category()));
}
Also used : Category(org.hisp.dhis.category.Category) Test(org.junit.jupiter.api.Test)

Example 15 with Category

use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.

the class TypedIndexedObjectContainerTest method containsObjectNoType.

@Test
void containsObjectNoType() {
    final Category category1 = new Category();
    final Category category2 = new Category();
    container.add(category1);
    container.add(category2);
    Assertions.assertFalse(container.containsObject(new Attribute()));
}
Also used : Category(org.hisp.dhis.category.Category) Attribute(org.hisp.dhis.attribute.Attribute) Test(org.junit.jupiter.api.Test)

Aggregations

Category (org.hisp.dhis.category.Category)61 CategoryOption (org.hisp.dhis.category.CategoryOption)25 CategoryCombo (org.hisp.dhis.category.CategoryCombo)22 Test (org.junit.jupiter.api.Test)21 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)13 CategoryOptionGroupSet (org.hisp.dhis.category.CategoryOptionGroupSet)13 ArrayList (java.util.ArrayList)12 User (org.hisp.dhis.user.User)12 DataElement (org.hisp.dhis.dataelement.DataElement)11 HashSet (java.util.HashSet)8 DataSet (org.hisp.dhis.dataset.DataSet)8 OrganisationUnitGroupSet (org.hisp.dhis.organisationunit.OrganisationUnitGroupSet)8 HashMap (java.util.HashMap)7 Date (java.util.Date)5 AnalyticsTableColumn (org.hisp.dhis.analytics.AnalyticsTableColumn)5 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)5 OrganisationUnitLevel (org.hisp.dhis.organisationunit.OrganisationUnitLevel)5 List (java.util.List)4 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)4 Attribute (org.hisp.dhis.attribute.Attribute)4