use of org.hisp.dhis.tracker.report.TrackerErrorCode.E1075 in project dhis2-core by dhis2.
the class EnrollmentAttributeValidationHook method validateRequiredProperties.
protected void validateRequiredProperties(ValidationErrorReporter reporter, Enrollment enrollment, Attribute attribute, Program program) {
reporter.addErrorIfNull(attribute.getAttribute(), enrollment, E1075, attribute);
Optional<ProgramTrackedEntityAttribute> optionalTrackedAttr = program.getProgramAttributes().stream().filter(pa -> pa.getAttribute().getUid().equals(attribute.getAttribute()) && pa.isMandatory()).findFirst();
if (optionalTrackedAttr.isPresent()) {
reporter.addErrorIfNull(attribute.getValue(), enrollment, E1076, TrackedEntityAttribute.class.getSimpleName(), attribute.getAttribute());
}
if (attribute.getAttribute() != null) {
TrackedEntityAttribute teAttribute = reporter.getValidationContext().getTrackedEntityAttribute(attribute.getAttribute());
reporter.addErrorIfNull(teAttribute, enrollment, E1006, attribute.getAttribute());
}
}
Aggregations