use of py.org.fundacionparaguaya.pspserver.surveys.dtos.Property in project FP-PSP-SERVER by FundacionParaguaya.
the class SurveyServiceImpl method checkSchemaCompliance.
@Override
public ValidationResults checkSchemaCompliance(NewSnapshot snapshot) {
SurveyDefinition surveyDefinition = this.getSurveyDefinition(snapshot.getSurveyId());
SurveySchema schema = surveyDefinition.getSurveySchema();
ValidationResults results = ValidationSupport.validResults();
schema.getProperties().entrySet().stream().forEach(propertyEntry -> {
Property property = propertyEntry.getValue();
Object propertyValue = snapshot.getAllSurveyData().get(propertyEntry.getKey());
results.add(propertyValue != null ? validType().apply(property, propertyEntry.getKey(), propertyValue) : ValidationResult.valid());
results.add(requiredValue().apply(schema, propertyEntry.getKey(), propertyValue));
});
snapshot.getAllSurveyData().entrySet().stream().forEach(surveyData -> {
results.add(presentInSchema().apply(schema, surveyData.getKey(), surveyData.getValue()));
});
return results;
}
Aggregations