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);
});
}
Aggregations