use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getInvalidIndicators.
private List<DataIntegrityIssue> getInvalidIndicators(Function<Indicator, String> getter) {
List<DataIntegrityIssue> issues = new ArrayList<>();
I18n i18n = i18nManager.getI18n();
for (Indicator indicator : indicatorService.getAllIndicators()) {
ExpressionValidationOutcome result = expressionService.expressionIsValid(getter.apply(indicator), INDICATOR_EXPRESSION);
if (!result.isValid()) {
issues.add(toIssue(indicator, i18n.getString(result.getKey())));
}
}
return issues;
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method registerNonDatabaseIntegrityCheck.
private void registerNonDatabaseIntegrityCheck(DataIntegrityCheckType type, Supplier<List<DataIntegrityIssue>> check) {
String name = type.getName();
checksByName.put(name, DataIntegrityCheck.builder().name(name).severity(DataIntegritySeverity.WARNING).section("Legacy").description(name.replace('_', ' ')).runDetailsCheck(c -> new DataIntegrityDetails(c, new Date(), null, check.get())).runSummaryCheck(c -> new DataIntegritySummary(c, new Date(), null, check.get().size(), null)).build());
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getInvalidValidationRuleExpressions.
private List<DataIntegrityIssue> getInvalidValidationRuleExpressions(Function<ValidationRule, Expression> getter) {
List<DataIntegrityIssue> issues = new ArrayList<>();
I18n i18n = i18nManager.getI18n();
for (ValidationRule rule : validationRuleService.getAllValidationRules()) {
ExpressionValidationOutcome result = expressionService.expressionIsValid(getter.apply(rule).getExpression(), VALIDATION_RULE_EXPRESSION);
if (!result.isValid()) {
issues.add(toIssue(rule, i18n.getString(result.getKey())));
}
}
return issues;
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getIndicatorsWithIdenticalFormulas.
// -------------------------------------------------------------------------
// Indicator
// -------------------------------------------------------------------------
/**
* Gets all indicators with identical numerator and denominator.
*/
List<DataIntegrityIssue> getIndicatorsWithIdenticalFormulas() {
List<DataIntegrityIssue> issues = new ArrayList<>();
Map<String, List<Indicator>> byFormula = indicatorService.getAllIndicators().stream().collect(groupingBy(indicator -> indicator.getNumerator() + FORMULA_SEPARATOR + indicator.getDenominator()));
for (Entry<String, List<Indicator>> e : byFormula.entrySet()) {
if (e.getValue().size() > 1) {
issues.add(new DataIntegrityIssue(null, e.getKey(), null, toRefsList(e.getValue().stream())));
}
}
return issues;
}
use of org.hisp.dhis.dataintegrity.DataIntegrityDetails.DataIntegrityIssue in project dhis2-core by dhis2.
the class DefaultDataIntegrityService method getDuplicatePeriods.
// -------------------------------------------------------------------------
// Period
// -------------------------------------------------------------------------
/**
* Lists all Periods which are duplicates, based on the period type and
* start date.
*/
List<DataIntegrityIssue> getDuplicatePeriods() {
List<Period> periods = periodService.getAllPeriods();
List<DataIntegrityIssue> issues = new ArrayList<>();
for (Entry<String, List<Period>> group : periods.stream().collect(groupingBy(p -> p.getPeriodType().getName() + p.getStartDate().toString())).entrySet()) {
if (group.getValue().size() > 1) {
issues.add(new DataIntegrityIssue(null, group.getKey(), null, group.getValue().stream().map(p -> p.toString() + ":" + p.getUid()).collect(toUnmodifiableList())));
}
}
return issues;
}
Aggregations