Search in sources :

Example 1 with Property

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;
}
Also used : ValidationResults(py.org.fundacionparaguaya.pspserver.surveys.validation.ValidationResults) SurveySchema(py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveySchema) NewSurveyDefinition(py.org.fundacionparaguaya.pspserver.surveys.dtos.NewSurveyDefinition) SurveyDefinition(py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyDefinition) Property(py.org.fundacionparaguaya.pspserver.surveys.dtos.Property)

Aggregations

NewSurveyDefinition (py.org.fundacionparaguaya.pspserver.surveys.dtos.NewSurveyDefinition)1 Property (py.org.fundacionparaguaya.pspserver.surveys.dtos.Property)1 SurveyDefinition (py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveyDefinition)1 SurveySchema (py.org.fundacionparaguaya.pspserver.surveys.dtos.SurveySchema)1 ValidationResults (py.org.fundacionparaguaya.pspserver.surveys.validation.ValidationResults)1