Search in sources :

Example 1 with E1075

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());
    }
}
Also used : Attribute(org.hisp.dhis.tracker.domain.Attribute) TrackedEntityAttributeValue(org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Program(org.hisp.dhis.program.Program) E1019(org.hisp.dhis.tracker.report.TrackerErrorCode.E1019) Enrollment(org.hisp.dhis.tracker.domain.Enrollment) E1018(org.hisp.dhis.tracker.report.TrackerErrorCode.E1018) TrackerImportValidationContext(org.hisp.dhis.tracker.validation.TrackerImportValidationContext) Map(java.util.Map) TrackerIdScheme(org.hisp.dhis.tracker.TrackerIdScheme) ReferenceTrackerEntity(org.hisp.dhis.tracker.preheat.ReferenceTrackerEntity) BaseIdentifiableObject(org.hisp.dhis.common.BaseIdentifiableObject) TrackedEntity(org.hisp.dhis.tracker.domain.TrackedEntity) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) E1076(org.hisp.dhis.tracker.report.TrackerErrorCode.E1076) Set(java.util.Set) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) TrackedAttributeValidationService(org.hisp.dhis.tracker.validation.service.attribute.TrackedAttributeValidationService) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) E1075(org.hisp.dhis.tracker.report.TrackerErrorCode.E1075) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Component(org.springframework.stereotype.Component) E1006(org.hisp.dhis.tracker.report.TrackerErrorCode.E1006) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) Optional(java.util.Optional) Collections(java.util.Collections) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) ProgramTrackedEntityAttribute(org.hisp.dhis.program.ProgramTrackedEntityAttribute)

Aggregations

Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Maps (com.google.common.collect.Maps)1 Streams (com.google.common.collect.Streams)1 Collections (java.util.Collections)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 BaseIdentifiableObject (org.hisp.dhis.common.BaseIdentifiableObject)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Program (org.hisp.dhis.program.Program)1 ProgramTrackedEntityAttribute (org.hisp.dhis.program.ProgramTrackedEntityAttribute)1 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)1 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)1 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)1 TrackerIdScheme (org.hisp.dhis.tracker.TrackerIdScheme)1 TrackerBundle (org.hisp.dhis.tracker.bundle.TrackerBundle)1 Attribute (org.hisp.dhis.tracker.domain.Attribute)1 Enrollment (org.hisp.dhis.tracker.domain.Enrollment)1 TrackedEntity (org.hisp.dhis.tracker.domain.TrackedEntity)1