Search in sources :

Example 86 with CategoryOption

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

the class DhisConvenienceTest method createCategoryOptionCombo.

/**
 * @param categoryCombo the category combo.
 * @param categoryOptions the category options.
 * @return CategoryOptionCombo
 *
 *         Note: All the Category Options (COs) should be added to the
 *         Category Option Combo (COC) before the COC is added to the COs.
 *         That way the hashCode for the COC is stable when it is added to
 *         the CO HashSets because the COC hashCode depends on its linked
 *         COs.
 */
public static CategoryOptionCombo createCategoryOptionCombo(CategoryCombo categoryCombo, CategoryOption... categoryOptions) {
    CategoryOptionCombo categoryOptionCombo = new CategoryOptionCombo();
    categoryOptionCombo.setAutoFields();
    categoryOptionCombo.setCategoryCombo(categoryCombo);
    for (CategoryOption categoryOption : categoryOptions) {
        categoryOptionCombo.getCategoryOptions().add(categoryOption);
    }
    for (CategoryOption categoryOption : categoryOptions) {
        categoryOption.getCategoryOptionCombos().add(categoryOptionCombo);
    }
    return categoryOptionCombo;
}
Also used : CategoryOption(org.hisp.dhis.category.CategoryOption) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo)

Example 87 with CategoryOption

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

the class DimensionControllerTest method setUp.

@BeforeEach
void setUp() {
    CategoryOption categoryOptionA = new CategoryOption("Male");
    CategoryOption categoryOptionB = new CategoryOption("Female");
    categoryService.addCategoryOption(categoryOptionA);
    categoryService.addCategoryOption(categoryOptionB);
    Category categoryA = new Category("Gender", DataDimensionType.DISAGGREGATION);
    categoryA.setShortName(categoryA.getName());
    categoryA.addCategoryOption(categoryOptionA);
    categoryA.addCategoryOption(categoryOptionB);
    categoryService.addCategory(categoryA);
    CategoryCombo categoryComboA = new CategoryCombo("Gender", DataDimensionType.DISAGGREGATION);
    categoryComboA.addCategory(categoryA);
    categoryService.addCategoryCombo(categoryComboA);
    ccId = categoryComboA.getUid();
}
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)

Aggregations

CategoryOption (org.hisp.dhis.category.CategoryOption)87 CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)47 CategoryCombo (org.hisp.dhis.category.CategoryCombo)38 Category (org.hisp.dhis.category.Category)34 Test (org.junit.jupiter.api.Test)33 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)26 Program (org.hisp.dhis.program.Program)19 ArrayList (java.util.ArrayList)18 Event (org.hisp.dhis.tracker.domain.Event)15 BeforeEach (org.junit.jupiter.api.BeforeEach)15 HashSet (java.util.HashSet)14 Collectors (java.util.stream.Collectors)13 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)13 DataElement (org.hisp.dhis.dataelement.DataElement)13 Collections (java.util.Collections)12 DataSet (org.hisp.dhis.dataset.DataSet)12 CodeGenerator (org.hisp.dhis.common.CodeGenerator)11 TrackerBundle (org.hisp.dhis.tracker.bundle.TrackerBundle)11 CategoryService (org.hisp.dhis.category.CategoryService)10 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)10