use of org.hisp.dhis.dataelement.CategoryComboMap.CategoryComboMapException in project dhis2-core by dhis2.
the class DefaultAdxDataService method getCatOptComboFromAttributes.
private DataElementCategoryOptionCombo getCatOptComboFromAttributes(Map<String, String> attributes, DataElementCategoryCombo catcombo, IdentifiableProperty scheme) throws AdxException {
CategoryComboMap catcomboMap;
try {
catcomboMap = new CategoryComboMap(catcombo, scheme);
} catch (CategoryComboMapException ex) {
log.info("Failed to create category combo map from: " + catcombo);
throw new AdxException(ex.getMessage());
}
String compositeIdentifier = StringUtils.EMPTY;
for (DataElementCategory category : catcomboMap.getCategories()) {
String categoryCode = category.getCode();
if (categoryCode == null) {
throw new AdxException("No category matching: " + categoryCode);
}
String catAttribute = attributes.get(categoryCode);
if (catAttribute == null) {
throw new AdxException("Missing required attribute from category combo: " + categoryCode);
}
compositeIdentifier += "\"" + catAttribute + "\"";
}
DataElementCategoryOptionCombo catOptionCombo = catcomboMap.getCategoryOptionCombo(compositeIdentifier);
if (catOptionCombo == null) {
throw new AdxException("Invalid attributes:" + attributes);
}
return catOptionCombo;
}
Aggregations