use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getIndicatorsViolatingExclusiveGroupSets.
/**
* Gets all indicators units which are members of more than one group which
* enter into an exclusive group set.
*/
List<DataIntegrityIssue> getIndicatorsViolatingExclusiveGroupSets() {
Collection<IndicatorGroupSet> groupSets = indicatorService.getAllIndicatorGroupSets();
List<DataIntegrityIssue> issues = new ArrayList<>();
for (IndicatorGroupSet groupSet : groupSets) {
Collection<Indicator> duplicates = getDuplicates(new ArrayList<>(groupSet.getIndicators()));
for (Indicator duplicate : duplicates) {
issues.add(DataIntegrityIssue.toIssue(duplicate, duplicate.getGroups()));
}
}
return issues;
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getInvalidProgramIndicators.
private List<DataIntegrityIssue> getInvalidProgramIndicators(Function<ProgramIndicator, String> property, Predicate<ProgramIndicator> filter) {
List<ProgramIndicator> programIndicators = programIndicatorService.getAllProgramIndicators().stream().filter(filter).collect(toList());
List<DataIntegrityIssue> issues = new ArrayList<>();
for (ProgramIndicator programIndicator : programIndicators) {
String description = getInvalidExpressionDescription(property.apply(programIndicator));
if (description != null) {
issues.add(toIssue(programIndicator, description));
}
}
return issues;
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getDataElementsViolatingExclusiveGroupSets.
/**
* Gets all data elements units which are members of more than one group
* which enter into an exclusive group set.
*/
List<DataIntegrityIssue> getDataElementsViolatingExclusiveGroupSets() {
Collection<DataElementGroupSet> groupSets = dataElementService.getAllDataElementGroupSets();
List<DataIntegrityIssue> issues = new ArrayList<>();
for (DataElementGroupSet groupSet : groupSets) {
Set<DataElement> duplicates = getDuplicates(groupSet.getDataElements());
for (DataElement duplicate : duplicates) {
issues.add(DataIntegrityIssue.toIssue(duplicate, duplicate.getGroups()));
}
}
return issues;
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DataIntegrityYamlReaderTest method testReadDataIntegrityYaml.
@Test
void testReadDataIntegrityYaml() {
List<DataIntegrityCheck> checks = new ArrayList<>();
readDataIntegrityYaml("data-integrity-checks.yaml", checks::add, sql -> check -> new DataIntegritySummary(check, new Date(), null, 1, 100d), sql -> check -> new DataIntegrityDetails(check, new Date(), null, List.of(new DataIntegrityIssue("id", "name", sql, List.of()))));
assertEquals(6, checks.size());
DataIntegrityCheck check = checks.get(0);
assertEquals("categories_no_options", check.getName());
assertEquals("Categories with no category options", check.getDescription());
assertEquals("Categories", check.getSection());
assertEquals(DataIntegritySeverity.WARNING, check.getSeverity());
assertEquals("Categories should always have at least a single category options.", check.getIntroduction());
assertEquals("Any categories without category options should either be removed from the" + " system if they are not in use. Otherwise, appropriate category options" + " should be added to the category.", check.getRecommendation());
assertTrue(check.getRunDetailsCheck().apply(check).getIssues().get(0).getComment().startsWith("SELECT uid,name from dataelementcategory"));
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DataIntegrityServiceTest method testInvalidProgramIndicatorFilter.
@Test
void testInvalidProgramIndicatorFilter() {
ProgramIndicator programIndicator = new ProgramIndicator();
programIndicator.setName("Test-PI");
programIndicator.setFilter("A{someuid} + 1");
when(programIndicatorService.filterIsValid(anyString())).thenReturn(false);
when(programIndicatorService.getAllProgramIndicators()).thenReturn(List.of(programIndicator));
when(expressionService.getExpressionDescription(anyString(), any())).thenThrow(new ParserException(INVALID_EXPRESSION));
List<DataIntegrityIssue> issues = subject.getInvalidProgramIndicatorFilters();
assertEquals(1, issues.size(), 1);
DataIntegrityIssue issue = issues.get(0);
assertEquals(issueName(programIndicator), issue.getName());
assertEquals(INVALID_EXPRESSION, issue.getComment());
}
Aggregations