Search in sources :

Example 1 with TrackerDto

use of org.hisp.dhis.tracker.domain.TrackerDto in project dhis2-core by dhis2.

the class ValidationUtils method addIssuesToReporter.

public static void addIssuesToReporter(ValidationErrorReporter reporter, TrackerDto dto, List<ProgramRuleIssue> programRuleIssues) {
    programRuleIssues.stream().filter(issue -> issue.getIssueType().equals(ERROR)).forEach(issue -> {
        List<String> args = Lists.newArrayList(issue.getRuleUid());
        args.addAll(issue.getArgs());
        TrackerErrorReport error = TrackerErrorReport.builder().uid(dto.getUid()).trackerType(dto.getTrackerType()).errorCode(issue.getIssueCode()).addArgs(args.toArray()).build(reporter.getValidationContext().getBundle());
        reporter.addError(error);
    });
    programRuleIssues.stream().filter(issue -> issue.getIssueType().equals(WARNING)).forEach(issue -> {
        List<String> args = Lists.newArrayList(issue.getRuleUid());
        args.addAll(issue.getArgs());
        TrackerWarningReport warning = TrackerWarningReport.builder().uid(dto.getUid()).trackerType(dto.getTrackerType()).warningCode(issue.getIssueCode()).addArgs(args.toArray()).build(reporter.getValidationContext().getBundle());
        reporter.addWarning(warning);
    });
}
Also used : WARNING(org.hisp.dhis.tracker.programrule.IssueType.WARNING) DataValue(org.hisp.dhis.tracker.domain.DataValue) ERROR(org.hisp.dhis.tracker.programrule.IssueType.ERROR) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) StringUtils.isNotEmpty(org.apache.commons.lang3.StringUtils.isNotEmpty) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) Note(org.hisp.dhis.tracker.domain.Note) TrackerImportValidationContext(org.hisp.dhis.tracker.validation.TrackerImportValidationContext) ProgramRuleIssue(org.hisp.dhis.tracker.programrule.ProgramRuleIssue) Event(org.hisp.dhis.tracker.domain.Event) TrackerErrorReport(org.hisp.dhis.tracker.report.TrackerErrorReport) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Set(java.util.Set) EventStatus(org.hisp.dhis.event.EventStatus) Collectors(java.util.stream.Collectors) ProgramStage(org.hisp.dhis.program.ProgramStage) TrackerErrorCode(org.hisp.dhis.tracker.report.TrackerErrorCode) List(java.util.List) FeatureType(org.hisp.dhis.organisationunit.FeatureType) TrackerDto(org.hisp.dhis.tracker.domain.TrackerDto) Geometry(org.locationtech.jts.geom.Geometry) GEOMETRY_CANT_BE_NULL(org.hisp.dhis.tracker.validation.hooks.TrackerImporterAssertErrors.GEOMETRY_CANT_BE_NULL) ValidationStrategy(org.hisp.dhis.program.ValidationStrategy) TrackerWarningReport(org.hisp.dhis.tracker.report.TrackerWarningReport) TrackerWarningReport(org.hisp.dhis.tracker.report.TrackerWarningReport) TrackerErrorReport(org.hisp.dhis.tracker.report.TrackerErrorReport)

Aggregations

Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Lists (com.google.common.collect.Lists)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StringUtils.isNotEmpty (org.apache.commons.lang3.StringUtils.isNotEmpty)1 EventStatus (org.hisp.dhis.event.EventStatus)1 FeatureType (org.hisp.dhis.organisationunit.FeatureType)1 ProgramStage (org.hisp.dhis.program.ProgramStage)1 ValidationStrategy (org.hisp.dhis.program.ValidationStrategy)1 DataValue (org.hisp.dhis.tracker.domain.DataValue)1 Event (org.hisp.dhis.tracker.domain.Event)1 Note (org.hisp.dhis.tracker.domain.Note)1 TrackerDto (org.hisp.dhis.tracker.domain.TrackerDto)1 ERROR (org.hisp.dhis.tracker.programrule.IssueType.ERROR)1 WARNING (org.hisp.dhis.tracker.programrule.IssueType.WARNING)1 ProgramRuleIssue (org.hisp.dhis.tracker.programrule.ProgramRuleIssue)1 TrackerErrorCode (org.hisp.dhis.tracker.report.TrackerErrorCode)1 TrackerErrorReport (org.hisp.dhis.tracker.report.TrackerErrorReport)1