use of org.openforis.collect.manager.validation.SurveyValidator.SurveyValidationResult in project collect by openforis.
the class AttributeDefinitionFormValidator method validateReferencedAttribute.
private void validateReferencedAttribute(ValidationContext ctx) {
String referencedAttributePath = getValue(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, false);
if (StringUtils.isNotBlank(referencedAttributePath)) {
AttributeDefinition attrDef = (AttributeDefinition) getEditedNode(ctx);
CollectSurvey survey = attrDef.getSurvey();
AttributeDefinition referencedAttribute = (AttributeDefinition) survey.getSchema().getDefinitionByPath(referencedAttributePath);
if (referencedAttribute == null) {
addInvalidMessage(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, Labels.getLabel(REFERENCED_ATTRIBUTE_DELETED_MESSAGE_KEY));
} else {
SurveyValidationResult validationResult = new SurveyValidator().validateReferencedKeyAttribute(attrDef, referencedAttribute);
if (validationResult.getFlag() == Flag.ERROR) {
addInvalidMessage(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, Labels.getLabel(validationResult.getMessageKey(), validationResult.getMessageArgs()));
}
}
}
}
Aggregations