use of org.openforis.idm.metamodel.validation.Validator in project collect by openforis.
the class RecordUpdater method validateCardinality.
private Set<NodePointer> validateCardinality(Record record, Collection<NodePointer> pointers, NodeChangeMap changeMap) {
Set<NodePointer> updatedPointers = new HashSet<NodePointer>();
Validator validator = record.getSurveyContext().getValidator();
for (NodePointer nodePointer : pointers) {
Entity entity = nodePointer.getEntity();
NodeDefinition childDef = nodePointer.getChildDefinition();
ValidationResultFlag minCountResult, maxCountResult;
if (entity.isRelevant(childDef)) {
minCountResult = validator.validateMinCount(entity, childDef);
maxCountResult = validator.validateMaxCount(entity, childDef);
} else {
minCountResult = maxCountResult = ValidationResultFlag.OK;
}
if (entity.getMinCountValidationResult(childDef) != minCountResult) {
entity.setMinCountValidationResult(childDef, minCountResult);
changeMap.addMinCountValidationResultChange(nodePointer, minCountResult);
updatedPointers.add(nodePointer);
}
if (entity.getMaxCountValidationResult(childDef) != maxCountResult) {
entity.setMaxCountValidationResult(childDef, maxCountResult);
changeMap.addMaxCountValidationResultChange(nodePointer, maxCountResult);
updatedPointers.add(nodePointer);
}
}
return updatedPointers;
}
use of org.openforis.idm.metamodel.validation.Validator in project collect by openforis.
the class RecordUpdater method validateAttributes.
private void validateAttributes(Record record, Set<Attribute<?, ?>> attributes, NodeChangeMap changeMap) {
Validator validator = record.getSurveyContext().getValidator();
for (Attribute<?, ?> a : attributes) {
ValidationResults validationResults;
if (a.isRelevant()) {
validationResults = validator.validate(a);
} else {
validationResults = new ValidationResults();
}
a.setValidationResults(validationResults);
changeMap.addValidationResultChange(a, validationResults);
}
}
Aggregations