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