use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.
the class DefaultCsvImportService method categoryOptionsFromCsv.
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private List<DataElementCategoryOption> categoryOptionsFromCsv(CsvReader reader) throws IOException {
List<DataElementCategoryOption> list = new ArrayList<>();
while (reader.readRecord()) {
String[] values = reader.getValues();
if (values != null && values.length > 0) {
DataElementCategoryOption object = new DataElementCategoryOption();
setIdentifiableObject(object, values);
object.setShortName(getSafe(values, 3, object.getName(), 50));
list.add(object);
}
}
return list;
}
use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.
the class DhisConvenienceTest method createDataElementCategory.
/**
* @param categoryUniqueIdentifier A unique character to identify the
* category.
* @param categoryOptions the category options.
* @return DataElementCategory
*/
public static DataElementCategory createDataElementCategory(char categoryUniqueIdentifier, DataElementCategoryOption... categoryOptions) {
DataElementCategory dataElementCategory = new DataElementCategory("DataElementCategory" + categoryUniqueIdentifier, DataDimensionType.DISAGGREGATION);
dataElementCategory.setAutoFields();
for (DataElementCategoryOption categoryOption : categoryOptions) {
dataElementCategory.addCategoryOption(categoryOption);
}
return dataElementCategory;
}
use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.
the class DhisConvenienceTest method createCategoryOptionCombo.
/**
* @param categoryComboUniqueIdentifier A unique character to identify the
* category option combo.
* @param dataElementCategoryCombo The associated category combination.
* @param categoryOptions the category options.
* @return DataElementCategoryOptionCombo
*/
public static DataElementCategoryOptionCombo createCategoryOptionCombo(char categoryComboUniqueIdentifier, DataElementCategoryCombo dataElementCategoryCombo, DataElementCategoryOption... categoryOptions) {
DataElementCategoryOptionCombo categoryOptionCombo = new DataElementCategoryOptionCombo();
categoryOptionCombo.setAutoFields();
categoryOptionCombo.setCategoryCombo(dataElementCategoryCombo);
for (DataElementCategoryOption categoryOption : categoryOptions) {
categoryOptionCombo.getCategoryOptions().add(categoryOption);
categoryOption.getCategoryOptionCombos().add(categoryOptionCombo);
}
return categoryOptionCombo;
}
use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.
the class DataValueDimensionTest method testGetDimensions.
@Test
public void testGetDimensions() {
List<DataElementCategoryOption> categoryOptions = new ArrayList<>();
categoryOptions.add(male);
categoryOptions.add(under15);
DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
DataValue dataValue = dataValueService.getDataValue(dataElementA, periodA, sourceA, categoryOptionCombo);
assertNotNull(dataValue);
}
use of org.hisp.dhis.dataelement.DataElementCategoryOption in project dhis2-core by dhis2.
the class DataValueDimensionTest method testGetByCategoryOptionCombos.
@Test
public void testGetByCategoryOptionCombos() {
List<DataElementCategoryOption> categoryOptions = new ArrayList<>();
categoryOptions.add(male);
categoryOptions.add(under15);
DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
assertNotNull(categoryOptionCombo);
assertEquals(genderAndAgeGroup, categoryOptionCombo.getCategoryCombo());
assertTrue(CollectionUtils.isEqualCollection(categoryOptions, categoryOptionCombo.getCategoryOptions()));
categoryOptions.clear();
categoryOptions.add(female);
categoryOptions.add(over15);
categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
assertNotNull(categoryOptionCombo);
assertEquals(genderAndAgeGroup, categoryOptionCombo.getCategoryCombo());
assertTrue(CollectionUtils.isEqualCollection(categoryOptions, categoryOptionCombo.getCategoryOptions()));
categoryOptions.clear();
categoryOptions.add(male);
categoryOptions.add(female);
categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo(categoryOptions);
assertNull(categoryOptionCombo);
}
Aggregations