Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Replace data element no groups Java check with SQL based check #15812

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading