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;
}
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();
}
Aggregations