use of org.openforis.idm.metamodel.validation.ValidationResult in project collect by openforis.
the class ValidationMessageBuilder method getValidationMessages.
public List<String> getValidationMessages(Attribute<?, ?> attribute, ValidationResults validationResults, Flag flag, Locale locale) {
List<String> result = new ArrayList<String>();
List<ValidationResult> items = flag == Flag.ERROR ? validationResults.getErrors() : validationResults.getWarnings();
if (items != null) {
for (ValidationResult validationResult : items) {
String message = getValidationMessage(attribute, validationResult, locale);
if (!result.contains(message)) {
result.add(message);
}
}
}
return result;
}
use of org.openforis.idm.metamodel.validation.ValidationResult in project collect by openforis.
the class CollectRecordIntegrationTest method checkHasError.
private void checkHasError(CollectRecord record, int attributeId, Class<?> checkType) {
ValidationResults validationResults = record.getValidationCache().getAttributeValidationResults(attributeId);
List<ValidationResult> errors = validationResults.getErrors();
for (ValidationResult validationResult : errors) {
if (checkType.isAssignableFrom(validationResult.getValidator().getClass())) {
return;
}
}
Assert.fail("Error of class " + checkType + " not found in validation results");
}
use of org.openforis.idm.metamodel.validation.ValidationResult in project collect by openforis.
the class ValidationResultsProxy method extractValidationResultMessages.
private List<String> extractValidationResultMessages(List<ValidationResult> validationResultList) {
List<String> result = new ArrayList<String>();
ValidationMessageBuilder validationMessageBuilder = ValidationMessageBuilder.createInstance(context.getMessageSource());
for (ValidationResult validationResult : validationResultList) {
result.add(validationMessageBuilder.getValidationMessage(attribute, validationResult, context.getLocale()));
}
return result;
}
use of org.openforis.idm.metamodel.validation.ValidationResult in project collect by openforis.
the class CollectRecordIntegrationTest method checkHasWarning.
private void checkHasWarning(CollectRecord record, int attributeId, Class<?> checkType) {
ValidationResults validationResults = record.getValidationCache().getAttributeValidationResults(attributeId);
List<ValidationResult> warnings = validationResults.getWarnings();
for (ValidationResult validationResult : warnings) {
if (checkType.isAssignableFrom(validationResult.getValidator().getClass())) {
return;
}
}
Assert.fail();
}
use of org.openforis.idm.metamodel.validation.ValidationResult in project collect by openforis.
the class RecordValidationReportGenerator method extractAttributeValidationResultItem.
protected List<RecordValidationReportItem> extractAttributeValidationResultItem(Locale locale, Integer attrId, ValidationResultFlag level, boolean includeConfirmedErrors) {
List<RecordValidationReportItem> items = new ArrayList<RecordValidationReportItem>();
Attribute<?, ?> attr = (Attribute<?, ?>) record.getNodeByInternalId(attrId);
ValidationResults validationResults = validationCache.getAttributeValidationResults(attrId);
List<ValidationResult> failed = validationResults.getFailed();
if (CollectionUtils.isNotEmpty(failed)) {
String path = getPath(attr);
String prettyFormatPath = messageBuilder.getPrettyFormatPath(attr, locale);
for (ValidationResult validationResult : failed) {
ValidationResultFlag flag = validationResult.getFlag();
if (isInLevel(flag, level) || flag == ValidationResultFlag.WARNING && includeConfirmedErrors && record.isErrorConfirmed(attr)) {
String message = messageBuilder.getValidationMessage(attr, validationResult, locale);
RecordValidationReportItem recordValidationItem = new RecordValidationReportItem(attrId, path, prettyFormatPath, flag, message);
items.add(recordValidationItem);
}
}
}
return items;
}
Aggregations