use of ddf.catalog.validation.impl.report.MetacardValidationReportImpl in project ddf by codice.
the class ReportingMetacardValidatorImpl method getReport.
private Optional<MetacardValidationReport> getReport(final Set<ValidationViolation> violations) {
final MetacardValidationReportImpl report = new MetacardValidationReportImpl();
violations.forEach(report::addAttributeViolation);
return Optional.of(report);
}
use of ddf.catalog.validation.impl.report.MetacardValidationReportImpl in project ddf by codice.
the class DuplicationValidator method getReport.
private Optional<MetacardValidationReport> getReport(final Set<ValidationViolation> violations) {
if (CollectionUtils.isNotEmpty(violations)) {
final MetacardValidationReportImpl report = new MetacardValidationReportImpl();
violations.forEach(report::addMetacardViolation);
return Optional.of(report);
}
return Optional.empty();
}
use of ddf.catalog.validation.impl.report.MetacardValidationReportImpl in project ddf by codice.
the class RelationshipValidator method validateMetacard.
@Override
public Optional<MetacardValidationReport> validateMetacard(Metacard metacard) {
Attribute attribute = metacard.getAttribute(sourceAttribute);
if (attribute != null && attribute.getValues().stream().anyMatch(Objects::nonNull) && (StringUtils.isEmpty(sourceValue) || attribute.getValues().contains(sourceValue))) {
MetacardValidationReportImpl report = new MetacardValidationReportImpl();
Attribute actualAttribute = metacard.getAttribute(targetAttribute);
Collection<String> actualValues = actualAttribute == null ? Collections.emptyList() : actualAttribute.getValues().stream().map(Objects::toString).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
Optional<ValidationViolation> violation = relationships.get(relationship).apply(actualValues);
violation.ifPresent(report::addAttributeViolation);
if (violation.isPresent()) {
return Optional.of(report);
} else {
return Optional.empty();
}
} else {
return Optional.empty();
}
}
use of ddf.catalog.validation.impl.report.MetacardValidationReportImpl in project ddf by codice.
the class RequiredAttributesMetacardValidator method getReport.
private Optional<MetacardValidationReport> getReport(final Set<ValidationViolation> violations) {
final MetacardValidationReportImpl report = new MetacardValidationReportImpl();
violations.forEach(report::addMetacardViolation);
return Optional.of(report);
}
use of ddf.catalog.validation.impl.report.MetacardValidationReportImpl in project ddf by codice.
the class SchematronValidationService method generateReport.
private MetacardValidationReport generateReport(Metacard metacard) throws ValidationExceptionImpl {
MetacardValidationReportImpl report = new MetacardValidationReportImpl();
Set<String> attributes = ImmutableSet.of("metadata");
String metadata = metacard.getMetadata();
boolean canBeValidated = !(StringUtils.isEmpty(metadata) || (namespace != null && !namespace.equals(XML_UTILS.getRootNamespace(metadata))));
if (canBeValidated) {
try {
for (Future<Templates> validator : validators) {
schematronReport = generateReport(metadata, validator.get(10, TimeUnit.MINUTES));
schematronReport.getErrors().forEach(errorMsg -> report.addMetacardViolation(new ValidationViolationImpl(attributes, sanitize(errorMsg), ValidationViolation.Severity.ERROR)));
schematronReport.getWarnings().forEach(warningMsg -> report.addMetacardViolation(new ValidationViolationImpl(attributes, sanitize(warningMsg), ValidationViolation.Severity.WARNING)));
}
} catch (TimeoutException | ExecutionException e) {
throw new ValidationExceptionImpl(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ValidationExceptionImpl(e);
}
}
return report;
}
Aggregations