Skip to content

Commit

Permalink
Replace data element no groups Java check with SQL based check (#15812)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-p-pickering authored Dec 4, 2023
1 parent c31321e commit ac87838
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public enum DataIntegrityCheckType {

// DataElements
DATA_ELEMENTS_WITHOUT_DATA_SETS,
DATA_ELEMENTS_WITHOUT_GROUPS,
DATA_ELEMENTS_ASSIGNED_TO_DATA_SETS_WITH_DIFFERENT_PERIOD_TYPES,
DATA_ELEMENTS_VIOLATING_EXCLUSIVE_GROUP_SETS,
DATA_ELEMENTS_IN_DATA_SET_NOT_IN_FORM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ public FlattenedDataIntegrityReport(Map<String, DataIntegrityDetails> detailsByN
listOfDisplayNameOrUid(
detailsByName.get(DataIntegrityCheckType.DATA_ELEMENTS_WITHOUT_DATA_SETS.getName()));
this.dataElementsWithoutGroups =
listOfDisplayNameOrUid(
detailsByName.get(DataIntegrityCheckType.DATA_ELEMENTS_WITHOUT_GROUPS.getName()));
listOfDisplayNameWithUid(detailsByName.get("data_elements_aggregate_no_groups"));
this.invalidCategoryCombos =
listOfDisplayNameOrUid(
detailsByName.get(DataIntegrityCheckType.CATEGORY_COMBOS_BEING_INVALID.getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,6 @@ public void initIntegrityChecks() {
DataIntegrityCheckType.DATA_ELEMENTS_WITHOUT_DATA_SETS,
DataElement.class,
this::getDataElementsWithoutDataSet);
registerNonDatabaseIntegrityCheck(
DataIntegrityCheckType.DATA_ELEMENTS_WITHOUT_GROUPS,
DataElement.class,
this::getDataElementsWithoutGroups);
registerNonDatabaseIntegrityCheck(
DataIntegrityCheckType.DATA_ELEMENTS_ASSIGNED_TO_DATA_SETS_WITH_DIFFERENT_PERIOD_TYPES,
DataElement.class,
Expand Down Expand Up @@ -691,6 +687,7 @@ public FlattenedDataIntegrityReport getReport(Set<String> checks, JobProgress pr
.collect(Collectors.toSet());
// Add additional SQL based checks here
checks.add("organisation_units_without_groups");
checks.add("data_elements_aggregate_no_groups");
}
runDetailsChecks(checks, progress);
return new FlattenedDataIntegrityReport(getDetails(checks, -1L));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,37 @@ private String addOrganisationUnitGroupSet(String name, String... groupIds) {
+ "}"));
}

@Test
void testDataElementsNoGroups() {

String dataElementA =
assertStatus(
HttpStatus.CREATED,
POST(
"/dataElements",
"{ 'name': 'ANC1', 'shortName': 'ANC1', 'valueType' : 'NUMBER',"
+ "'domainType' : 'AGGREGATE', 'aggregationType' : 'SUM' }"));

String dataElementB =
assertStatus(
HttpStatus.CREATED,
POST(
"/dataElements",
"{ 'name': 'ANC2', 'shortName': 'ANC2', 'valueType' : 'NUMBER',"
+ "'domainType' : 'AGGREGATE', 'aggregationType' : 'SUM' }"));

assertStatus(
HttpStatus.CREATED,
POST(
"/dataElementGroups",
"{ 'name': 'ANC', 'shortName': 'ANC' , 'dataElements' : [{'id' : '"
+ dataElementA
+ "'}]}"));
List<String> results =
getDataIntegrityReport().getDataElementsWithoutGroups().toList(JsonString::string);
assertEquals(singletonList("ANC2" + ":" + dataElementB), results);
}

private JsonDataIntegrityReport getDataIntegrityReport() {
return getDataIntegrityReport("/dataIntegrity");
}
Expand Down

0 comments on commit ac87838

Please sign in to comment.