diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroup.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroup.java
index a7e7c4107f65..f15116a66b59 100644
--- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroup.java
+++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroup.java
@@ -63,6 +63,11 @@ public CategoryOptionGroup(String name) {
this.name = name;
}
+ public CategoryOptionGroup(String name, DataDimensionType dataDimensionType) {
+ this(name);
+ this.dataDimensionType = dataDimensionType;
+ }
+
// -------------------------------------------------------------------------
// DimensionalItemObject
// -------------------------------------------------------------------------
diff --git a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroupSet.java b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroupSet.java
index 1b536a07a9b7..90fff63b1c3e 100644
--- a/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroupSet.java
+++ b/dhis-2/dhis-api/src/main/java/org/hisp/dhis/category/CategoryOptionGroupSet.java
@@ -68,6 +68,11 @@ public CategoryOptionGroupSet(String name) {
this.shortName = name;
}
+ public CategoryOptionGroupSet(String name, DataDimensionType dataDimensionType) {
+ this(name);
+ this.dataDimensionType = dataDimensionType;
+ }
+
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroup.hbm.xml b/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroup.hbm.xml
index f766e8387e8f..5a0aed492b96 100644
--- a/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroup.hbm.xml
+++ b/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroup.hbm.xml
@@ -36,7 +36,7 @@
-
+
diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroupSet.hbm.xml b/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroupSet.hbm.xml
index 54485ba1b9fd..3c98531a8f9f 100644
--- a/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroupSet.hbm.xml
+++ b/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/category/hibernate/CategoryOptionGroupSet.hbm.xml
@@ -35,7 +35,7 @@
foreign-key="fk_categoryoptiongroupsetmembers_categoryoptiongroupid" />
-
+
diff --git a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java
index 183b58b4a44b..f9bdbf8899e1 100644
--- a/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java
+++ b/dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java
@@ -430,6 +430,9 @@ private List categoryOptionGroupsFromCsv(CsvReader reader)
CategoryOptionGroup object = new CategoryOptionGroup();
setIdentifiableObject(object, values);
object.setShortName(getSafe(values, 3, object.getName(), 50));
+ object.setDataDimensionType(
+ DataDimensionType.fromValue(
+ getSafe(values, 4, DataDimensionType.DISAGGREGATION.getValue(), 50)));
list.add(object);
}
}
diff --git a/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java b/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
index a0d4e56ccb83..891e3fed09fc 100644
--- a/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
+++ b/dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
@@ -726,6 +726,7 @@ public static CategoryOptionGroup createCategoryOptionGroup(
new CategoryOptionGroup("CategoryOptionGroup" + uniqueIdentifier);
categoryOptionGroup.setShortName("ShortName" + uniqueIdentifier);
categoryOptionGroup.setAutoFields();
+ categoryOptionGroup.setDataDimensionType(DISAGGREGATION);
categoryOptionGroup.setMembers(new HashSet<>());
@@ -747,6 +748,7 @@ public static CategoryOptionGroupSet createCategoryOptionGroupSet(
CategoryOptionGroupSet categoryOptionGroupSet =
new CategoryOptionGroupSet("CategoryOptionGroupSet" + categoryGroupSetUniqueIdentifier);
categoryOptionGroupSet.setAutoFields();
+ categoryOptionGroupSet.setDataDimensionType(DISAGGREGATION);
for (CategoryOptionGroup categoryOptionGroup : categoryOptionGroups) {
categoryOptionGroupSet.addCategoryOptionGroup(categoryOptionGroup);
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java
index ca10b84684ce..7ec621a4f207 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/analytics/data/AnalyticsServiceTest.java
@@ -451,7 +451,8 @@ private void setUpValidation() {
categoryService.saveCategoryOptionGroup(optionGroupA);
categoryService.saveCategoryOptionGroup(optionGroupB);
- CategoryOptionGroupSet optionGroupSetB = new CategoryOptionGroupSet("OptionGroupSetB");
+ CategoryOptionGroupSet optionGroupSetB =
+ new CategoryOptionGroupSet("OptionGroupSetB", DataDimensionType.DISAGGREGATION);
categoryService.saveCategoryOptionGroupSet(optionGroupSetB);
optionGroupSetB.addCategoryOptionGroup(optionGroupA);
optionGroupSetB.addCategoryOptionGroup(optionGroupB);
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/category/CategoryOptionGroupStoreTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/category/CategoryOptionGroupStoreTest.java
index 44623146ace0..9b67c0795170 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/category/CategoryOptionGroupStoreTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/category/CategoryOptionGroupStoreTest.java
@@ -28,10 +28,13 @@
package org.hisp.dhis.category;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
+import org.hibernate.PropertyValueException;
import org.hisp.dhis.test.integration.SingleSetupIntegrationTestBase;
+import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -140,4 +143,25 @@ void testGetByGroupSet() {
assertTrue(groupsB.contains(cogC));
assertTrue(groupsB.contains(cogD));
}
+
+ @Test
+ @DisplayName("Should throw error if adding category option group without data dimension type")
+ void testAddCogWithoutDataDimensionType() {
+ CategoryOptionGroup cogA = createCategoryOptionGroup('A', coA, coB);
+ cogA.setDataDimensionType(null);
+ assertThrows(PropertyValueException.class, () -> categoryOptionGroupStore.save(cogA));
+ }
+
+ @Test
+ @DisplayName("Should throw error if adding category option group set without data dimension type")
+ void testAddCogsWithoutDataDimensionType() {
+ CategoryOptionGroup cogA = createCategoryOptionGroup('A', coA, coB);
+ CategoryOptionGroup cogB = createCategoryOptionGroup('B', coC, coD);
+ categoryOptionGroupStore.save(cogA);
+ categoryOptionGroupStore.save(cogB);
+ CategoryOptionGroupSet cogsA = createCategoryOptionGroupSet('A', cogA, cogB);
+ cogsA.setDataDimensionType(null);
+ assertThrows(
+ PropertyValueException.class, () -> categoryService.saveCategoryOptionGroupSet(cogsA));
+ }
}
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalAuditServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalAuditServiceTest.java
index 12a07ef83ba8..237183fc7e8f 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalAuditServiceTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalAuditServiceTest.java
@@ -47,6 +47,7 @@
import org.hisp.dhis.category.CategoryOptionGroupSet;
import org.hisp.dhis.category.CategoryService;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -246,7 +247,8 @@ public void setUpTest() throws Exception {
optionGroupB = createCategoryOptionGroup('B', optionB);
categoryService.saveCategoryOptionGroup(optionGroupA);
categoryService.saveCategoryOptionGroup(optionGroupB);
- optionGroupSetB = new CategoryOptionGroupSet("OptionGroupSetB");
+ optionGroupSetB =
+ new CategoryOptionGroupSet("OptionGroupSetB", DataDimensionType.DISAGGREGATION);
categoryService.saveCategoryOptionGroupSet(optionGroupSetB);
optionGroupSetB.addCategoryOptionGroup(optionGroupA);
optionGroupSetB.addCategoryOptionGroup(optionGroupB);
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java
index c6f52a08c5f5..5bccdb7396d2 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java
@@ -40,6 +40,7 @@
import java.util.Set;
import org.hisp.dhis.category.CategoryOptionGroupSet;
import org.hisp.dhis.category.CategoryService;
+import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.test.integration.TransactionalIntegrationTest;
@@ -144,10 +145,10 @@ public void setUpTest() {
// ---------------------------------------------------------------------
// Add supporting data
// ---------------------------------------------------------------------
- setA = new CategoryOptionGroupSet("Set A");
- setB = new CategoryOptionGroupSet("Set B");
- setC = new CategoryOptionGroupSet("Set C");
- setD = new CategoryOptionGroupSet("Set D");
+ setA = new CategoryOptionGroupSet("Set A", DataDimensionType.DISAGGREGATION);
+ setB = new CategoryOptionGroupSet("Set B", DataDimensionType.DISAGGREGATION);
+ setC = new CategoryOptionGroupSet("Set C", DataDimensionType.DISAGGREGATION);
+ setD = new CategoryOptionGroupSet("Set D", DataDimensionType.DISAGGREGATION);
categoryService.saveCategoryOptionGroupSet(setA);
categoryService.saveCategoryOptionGroupSet(setB);
categoryService.saveCategoryOptionGroupSet(setC);
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java
index ddcba9c4a7ca..2cf731817a63 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java
@@ -52,6 +52,7 @@
import org.hisp.dhis.category.CategoryOptionGroupSet;
import org.hisp.dhis.category.CategoryService;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dataapproval.exceptions.DataApprovalException;
import org.hisp.dhis.dataset.DataSet;
@@ -537,8 +538,8 @@ public void setUpTest() throws Exception {
setAccess(partner2, globalUsers, chinaInteragencyUsers, chinaAgencyAUsers, chinaPartner2Users);
// Agencies and partners category option group sets
- agencies = new CategoryOptionGroupSet("Agencies");
- partners = new CategoryOptionGroupSet("Partners");
+ agencies = new CategoryOptionGroupSet("Agencies", DataDimensionType.DISAGGREGATION);
+ partners = new CategoryOptionGroupSet("Partners", DataDimensionType.DISAGGREGATION);
categoryService.saveCategoryOptionGroupSet(partners);
categoryService.saveCategoryOptionGroupSet(agencies);
setAccess(
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java
index 0d363bdfa820..96554e36ae69 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java
@@ -50,6 +50,7 @@
import org.hisp.dhis.category.CategoryOptionGroup;
import org.hisp.dhis.category.CategoryOptionGroupSet;
import org.hisp.dhis.category.CategoryService;
+import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.dataapproval.exceptions.DataMayNotBeApprovedException;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
@@ -559,8 +560,8 @@ private void setUpCategories() {
categoryService.saveCategoryOptionGroup(groupCD);
categoryService.saveCategoryOptionGroup(groupEF);
categoryService.saveCategoryOptionGroup(groupGH);
- groupSetABCD = new CategoryOptionGroupSet("GroupSetABCD");
- groupSetEFGH = new CategoryOptionGroupSet("GroupSetEFGH");
+ groupSetABCD = new CategoryOptionGroupSet("GroupSetABCD", DataDimensionType.DISAGGREGATION);
+ groupSetEFGH = new CategoryOptionGroupSet("GroupSetEFGH", DataDimensionType.DISAGGREGATION);
categoryService.saveCategoryOptionGroupSet(groupSetABCD);
categoryService.saveCategoryOptionGroupSet(groupSetEFGH);
groupSetABCD.addCategoryOptionGroup(groupAB);
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java
index 08c9cde3dc94..9f28c35a9280 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/dxf2/csv/CsvImportServiceTest.java
@@ -32,9 +32,11 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.List;
import org.hisp.dhis.category.Category;
import org.hisp.dhis.category.CategoryCombo;
import org.hisp.dhis.category.CategoryOption;
+import org.hisp.dhis.category.CategoryOptionGroup;
import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dxf2.metadata.Metadata;
@@ -222,4 +224,41 @@ void testImportIndicator() throws IOException {
assertEquals("#{h0xKKjijTdI}", indicatorB.getNumerator());
assertEquals(indicatorType.getUid(), indicatorB.getIndicatorType().getUid());
}
+
+ @Test
+ void testImportCategoryOptionGroup() throws IOException {
+ InputStream in = new ClassPathResource("csv/category_option_group.csv").getInputStream();
+ Metadata metadata =
+ csvImportService.fromCsv(
+ in,
+ new CsvImportOptions()
+ .setImportClass(CsvImportClass.CATEGORY_OPTION_GROUP)
+ .setFirstRowIsHeader(true));
+ assertEquals(3, metadata.getCategoryOptionGroups().size());
+ // make sure all groups have data dimension type set
+ for (CategoryOptionGroup group : metadata.getCategoryOptionGroups()) {
+ assertNotNull(group.getDataDimensionType());
+ }
+
+ ImportReport report =
+ importService.importMetadata(
+ new MetadataImportParams(),
+ new MetadataObjects().addMetadata(schemaService.getMetadataSchemas(), metadata));
+
+ assertEquals(Status.OK, report.getStatus());
+ List allGroups = manager.getAll(CategoryOptionGroup.class);
+ assertEquals(3, allGroups.size());
+ CategoryOptionGroup groupA =
+ allGroups.stream().filter(g -> g.getName().equals("GroupA")).findFirst().orElse(null);
+ assertNotNull(groupA);
+ assertEquals(DataDimensionType.DISAGGREGATION, groupA.getDataDimensionType());
+ CategoryOptionGroup groupB =
+ allGroups.stream().filter(g -> g.getName().equals("GroupB")).findFirst().orElse(null);
+ assertNotNull(groupB);
+ assertEquals(DataDimensionType.DISAGGREGATION, groupB.getDataDimensionType());
+ CategoryOptionGroup groupC =
+ allGroups.stream().filter(g -> g.getName().equals("GroupC")).findFirst().orElse(null);
+ assertNotNull(groupC);
+ assertEquals(DataDimensionType.ATTRIBUTE, groupC.getDataDimensionType());
+ }
}
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/security/acl/AclServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/security/acl/AclServiceTest.java
index 962c1d55b645..760ad67857b3 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/security/acl/AclServiceTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/security/acl/AclServiceTest.java
@@ -37,6 +37,7 @@
import org.apache.commons.collections4.MapUtils;
import org.hisp.dhis.category.CategoryOption;
import org.hisp.dhis.category.CategoryOptionGroupSet;
+import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.dashboard.Dashboard;
import org.hisp.dhis.dataelement.DataElement;
@@ -1075,6 +1076,7 @@ void testCanDataOrMetadataRead() {
manager.save(user1);
// non data shareable object //
CategoryOptionGroupSet categoryOptionGroupSet = new CategoryOptionGroupSet();
+ categoryOptionGroupSet.setDataDimensionType(DataDimensionType.DISAGGREGATION);
categoryOptionGroupSet.setAutoFields();
categoryOptionGroupSet.setName("cogA");
categoryOptionGroupSet.setShortName("cogA");
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/validation/ValidationResultStoreTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/validation/ValidationResultStoreTest.java
index 60c3f8244b70..d06eb6298024 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/validation/ValidationResultStoreTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/validation/ValidationResultStoreTest.java
@@ -51,6 +51,7 @@
import org.hisp.dhis.category.CategoryOptionGroupSet;
import org.hisp.dhis.category.CategoryService;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.common.IdentifiableObjectManager;
import org.hisp.dhis.expression.Expression;
import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -229,7 +230,8 @@ public void setUpTest() throws Exception {
optionGroupB = createCategoryOptionGroup('B', optionB);
categoryService.saveCategoryOptionGroup(optionGroupA);
categoryService.saveCategoryOptionGroup(optionGroupB);
- optionGroupSetB = new CategoryOptionGroupSet("OptionGroupSetB");
+ optionGroupSetB =
+ new CategoryOptionGroupSet("OptionGroupSetB", DataDimensionType.DISAGGREGATION);
categoryService.saveCategoryOptionGroupSet(optionGroupSetB);
optionGroupSetB.addCategoryOptionGroup(optionGroupA);
optionGroupSetB.addCategoryOptionGroup(optionGroupB);
diff --git a/dhis-2/dhis-test-integration/src/test/resources/csv/category_option_group.csv b/dhis-2/dhis-test-integration/src/test/resources/csv/category_option_group.csv
new file mode 100644
index 000000000000..396153b599af
--- /dev/null
+++ b/dhis-2/dhis-test-integration/src/test/resources/csv/category_option_group.csv
@@ -0,0 +1,4 @@
+name,uid,code,shortname,datadimensiontype
+GroupA,,GroupA,,
+GroupB,,GroupB,,disaggregation
+GroupC,,GroupC,,attribute
\ No newline at end of file
diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java
index df0ba3105186..fcc9920f8850 100644
--- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java
+++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java
@@ -50,6 +50,7 @@
import org.hisp.dhis.category.CategoryOption;
import org.hisp.dhis.category.CategoryOptionGroupSet;
import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DataDimensionType;
import org.hisp.dhis.feedback.ErrorCode;
import org.hisp.dhis.jsontree.JsonArray;
import org.hisp.dhis.jsontree.JsonBoolean;
@@ -973,6 +974,7 @@ void testRemoveCogCatDimFromUserCredentialsLegacyFormat() {
CategoryOptionGroupSet categoryOptionGroupSet = new CategoryOptionGroupSet();
categoryOptionGroupSet.setAutoFields();
+ categoryOptionGroupSet.setDataDimensionType(DataDimensionType.DISAGGREGATION);
categoryOptionGroupSet.setName("cogA");
categoryOptionGroupSet.setShortName("cogA");
manager.save(categoryOptionGroupSet);
diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetExcessGroupMembershipControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetExcessGroupMembershipControllerTest.java
index 665f53e205ce..2d81322aa103 100644
--- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetExcessGroupMembershipControllerTest.java
+++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetExcessGroupMembershipControllerTest.java
@@ -61,7 +61,7 @@ void testCategoryOptionInMultipleGroups() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Taste', 'shortName': 'Taste' , 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Taste', 'shortName': 'Taste' , 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionSweet
+ "'}, {'id': '"
+ categoryOptionSour
@@ -73,7 +73,7 @@ void testCategoryOptionInMultipleGroups() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroupSets",
- "{ 'name': 'Taste and Color', 'shortName': 'Taste and Color', 'categoryOptionGroups' : [{'id': '"
+ "{ 'name': 'Taste and Color', 'shortName': 'Taste and Color', 'dataDimensionType':'DISAGGREGATION', 'categoryOptionGroups' : [{'id': '"
+ categoryOptionGroupColor
+ "'}, {'id' : '"
+ categoryOptionGroupTaste
@@ -92,7 +92,7 @@ void testCategoryOptionsInOneGroup() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Taste', 'shortName': 'Taste' , 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Taste', 'dataDimensionType':'DISAGGREGATION', 'shortName': 'Taste' , 'categoryOptions' : [{'id' : '"
+ categoryOptionSweet
+ "'}, {'id': '"
+ categoryOptionSour
@@ -102,7 +102,7 @@ void testCategoryOptionsInOneGroup() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroupSets",
- "{ 'name': 'Taste and Color', 'shortName': 'Taste and Color', 'categoryOptionGroups' : [{'id': '"
+ "{ 'name': 'Taste and Color', 'shortName': 'Taste and Color', 'dataDimensionType':'DISAGGREGATION', 'categoryOptionGroups' : [{'id': '"
+ categoryOptionGroupColor
+ "'}, {'id' : '"
+ categoryOptionGroupTaste
@@ -142,7 +142,7 @@ void setUpTest() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Color', 'shortName': 'Color', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Color', 'shortName': 'Color', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionRed
+ "'}, {'id': '"
+ categoryOptionBlue
diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetIncompleteControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetIncompleteControllerTest.java
index 0d4181d260ab..3ffa9dc2f6e2 100644
--- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetIncompleteControllerTest.java
+++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityCategoryOptionGroupSetIncompleteControllerTest.java
@@ -61,7 +61,7 @@ void testCategoryOptionGroupSetIncomplete() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Warm', 'shortName': 'Warm', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Warm', 'shortName': 'Warm', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionRed
+ "'}]}"));
@@ -70,7 +70,7 @@ void testCategoryOptionGroupSetIncomplete() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Cold', 'shortName': 'Cold', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Cold', 'shortName': 'Cold', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionBlue
+ "'}]}"));
@@ -79,7 +79,7 @@ void testCategoryOptionGroupSetIncomplete() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroupSets",
- "{ 'name': 'Color set', 'shortName': 'Color set', 'categoryOptionGroups' : [{'id': '"
+ "{ 'name': 'Color set', 'shortName': 'Color set', 'dataDimensionType':'DISAGGREGATION', 'categoryOptionGroups' : [{'id': '"
+ warmGroup
+ "'}, {'id' : '"
+ coldGroup
@@ -98,7 +98,7 @@ void testCategoryOptionGroupComplete() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Warm', 'shortName': 'Warm', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Warm', 'shortName': 'Warm', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionRed
+ "'}, {'id' : '"
+ categoryOptionYellow
@@ -109,7 +109,7 @@ void testCategoryOptionGroupComplete() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Cold', 'shortName': 'Cold', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Cold', 'shortName': 'Cold', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionBlue
+ "'}]}"));
@@ -117,7 +117,7 @@ void testCategoryOptionGroupComplete() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroupSets",
- "{ 'name': 'Color set', 'shortName': 'Color set', 'categoryOptionGroups' : [{'id': '"
+ "{ 'name': 'Color set', 'shortName': 'Color set', 'dataDimensionType':'DISAGGREGATION', 'categoryOptionGroups' : [{'id': '"
+ warmGroup
+ "'}, {'id' : '"
+ coldGroup
diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupSetControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupSetControllerTest.java
index ad5830d2c52b..6496de41c293 100644
--- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupSetControllerTest.java
+++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupSetControllerTest.java
@@ -57,14 +57,16 @@ void testCategoryOptionGroupSetSizeTooLow() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroupSets",
- "{'name': 'One', 'shortName' : 'One', 'categoryOptionGroups' : [{'id' : '"
+ "{'name': 'One', 'shortName' : 'One', 'dataDimensionType':'DISAGGREGATION', 'categoryOptionGroups' : [{'id' : '"
+ categoryOptionGroupTaste
+ "'}]}"));
String categoryOptionGroupSetNil =
assertStatus(
HttpStatus.CREATED,
- POST("/categoryOptionGroupSets", "{ 'name': 'Nil', 'shortName': 'Nil' }"));
+ POST(
+ "/categoryOptionGroupSets",
+ "{ 'name': 'Nil', 'shortName': 'Nil', 'dataDimensionType':'DISAGGREGATION'}"));
assertHasDataIntegrityIssues(
detailsIdType,
@@ -105,7 +107,7 @@ void setUpTest() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Color', 'shortName': 'Color', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Color', 'shortName': 'Color', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionRed
+ "'}, {'id': '"
+ categoryOptionBlue
@@ -121,7 +123,7 @@ void setUpTest() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Taste', 'shortName': 'Taste', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Taste', 'shortName': 'Taste', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionSweet
+ "'}]}"));
@@ -129,7 +131,7 @@ void setUpTest() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroupSets",
- "{'name': 'Two', 'shortName' : 'Two', 'categoryOptionGroups' : [{'id' : '"
+ "{'name': 'Two', 'shortName' : 'Two', 'dataDimensionType':'DISAGGREGATION', 'categoryOptionGroups' : [{'id' : '"
+ categoryOptionGroupTaste
+ "'},{'id' : '"
+ categoryOptionGroupColors
diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupsControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupsControllerTest.java
index 9d66cbd15a69..6484e49b63ac 100644
--- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupsControllerTest.java
+++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/dataintegrity/DataIntegrityGroupSizeCategoryOptionGroupsControllerTest.java
@@ -60,13 +60,15 @@ void testCategoryOptionGroupSizeTooSmall() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Taste', 'shortName': 'Taste', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Taste', 'shortName': 'Taste', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionSweet
+ "'}]}"));
String categoryOptionGroupNil =
assertStatus(
HttpStatus.CREATED,
- POST("/categoryOptionGroups", "{ 'name': 'Nil', 'shortName': 'Nil' }"));
+ POST(
+ "/categoryOptionGroups",
+ "{ 'name': 'Nil', 'shortName': 'Nil', 'dataDimensionType':'DISAGGREGATION' }"));
assertHasDataIntegrityIssues(
detailsIdType,
@@ -106,7 +108,7 @@ void setUpTest() {
HttpStatus.CREATED,
POST(
"/categoryOptionGroups",
- "{ 'name': 'Color', 'shortName': 'Color', 'categoryOptions' : [{'id' : '"
+ "{ 'name': 'Color', 'shortName': 'Color', 'dataDimensionType':'DISAGGREGATION', 'categoryOptions' : [{'id' : '"
+ categoryOptionRed
+ "'}, {'id': '"
+ categoryOptionBlue