use of org.hisp.dhis.tracker.validation.TrackerImportValidationContext in project dhis2-core by dhis2.
the class EventDataValuesValidationHook method validateMandatoryDataValues.
private void validateMandatoryDataValues(Event event, TrackerImportValidationContext context, ValidationErrorReporter reporter) {
if (StringUtils.isNotEmpty(event.getProgramStage())) {
ProgramStage programStage = context.getProgramStage(event.getProgramStage());
final List<String> mandatoryDataElements = programStage.getProgramStageDataElements().stream().filter(ProgramStageDataElement::isCompulsory).map(de -> context.getIdentifiers().getDataElementIdScheme().getIdentifier(de.getDataElement())).collect(Collectors.toList());
List<String> missingDataValue = validateMandatoryDataValue(programStage, event, mandatoryDataElements);
missingDataValue.forEach(de -> reporter.addError(event, E1303, de));
}
}
use of org.hisp.dhis.tracker.validation.TrackerImportValidationContext in project dhis2-core by dhis2.
the class EventGeoValidationHook method validateEvent.
@Override
public void validateEvent(ValidationErrorReporter reporter, Event event) {
TrackerImportValidationContext context = reporter.getValidationContext();
ProgramStage programStage = context.getProgramStage(event.getProgramStage());
checkNotNull(programStage, TrackerImporterAssertErrors.PROGRAM_STAGE_CANT_BE_NULL);
if (event.getGeometry() != null) {
ValidationUtils.validateGeometry(reporter, event, event.getGeometry(), programStage.getFeatureType());
}
}
use of org.hisp.dhis.tracker.validation.TrackerImportValidationContext in project dhis2-core by dhis2.
the class EventRuleValidationHook method validateEvent.
@Override
public void validateEvent(ValidationErrorReporter reporter, Event event) {
TrackerImportValidationContext context = reporter.getValidationContext();
List<ProgramRuleIssue> programRuleIssues = validators.stream().flatMap(v -> v.validateEvents(context.getBundle()).getOrDefault(event.getEvent(), Lists.newArrayList()).stream()).collect(Collectors.toList());
addIssuesToReporter(reporter, event, programRuleIssues);
}
use of org.hisp.dhis.tracker.validation.TrackerImportValidationContext in project dhis2-core by dhis2.
the class PreCheckExistenceValidationHook method validateTrackedEntity.
@Override
public void validateTrackedEntity(ValidationErrorReporter reporter, TrackedEntity trackedEntity) {
TrackerImportValidationContext context = reporter.getValidationContext();
TrackerImportStrategy importStrategy = context.getStrategy(trackedEntity);
TrackedEntityInstance existingTe = context.getTrackedEntityInstance(trackedEntity.getTrackedEntity());
// If the tracked entity is soft-deleted no operation is allowed
if (existingTe != null && existingTe.isDeleted()) {
reporter.addError(trackedEntity, E1114, trackedEntity.getTrackedEntity());
return;
}
if (existingTe != null && importStrategy.isCreate()) {
reporter.addError(trackedEntity, E1002, trackedEntity.getTrackedEntity());
} else if (existingTe == null && importStrategy.isUpdateOrDelete()) {
reporter.addError(trackedEntity, E1063, trackedEntity.getTrackedEntity());
}
}
use of org.hisp.dhis.tracker.validation.TrackerImportValidationContext in project dhis2-core by dhis2.
the class PreCheckExistenceValidationHook method validateRelationship.
@Override
public void validateRelationship(ValidationErrorReporter reporter, Relationship relationship) {
TrackerImportValidationContext context = reporter.getValidationContext();
org.hisp.dhis.relationship.Relationship existingRelationship = context.getRelationship(relationship);
if (existingRelationship != null) {
reporter.addWarning(relationship, E4015, relationship.getRelationship());
}
}
Aggregations