use of nl.knaw.huygens.timbuctoo.server.healthchecks.CompositeValidationResult in project timbuctoo by HuygensING.
the class InvariantsCheck method check.
@Override
public ValidationResult check(Vertex vertex) {
List<ValidationResult> validationResults = Lists.newArrayList();
String[] vertexTypes = getEntityTypesOrDefault(vertex);
String id = vertex.value("tim_id");
vertex.edges(Direction.BOTH).forEachRemaining(edge -> {
if (!Objects.equals(edge.label(), "VERSION_OF")) {
// ignore the VERSION_OF relations
String[] edgeTypes = getEntityTypesOrDefault(edge);
for (String edgeType : edgeTypes) {
Optional<Collection> collectionOptional = vres.getCollectionForType(edgeType);
String edgeId = edge.value("tim_id");
if (!collectionOptional.isPresent()) {
validationResults.add(new ElementValidationResult(false, String.format("Edge with tim_id '%s' has contains unknown variant '%s'", edgeId, edgeType)));
continue;
}
Collection edgeCollection = collectionOptional.get();
// Only check accepted edges / relations, Timbuctoo sees not accepted relations as deleted.
if (isAccepted(edge, edgeType) && vreContainsAVariationOfTheVertex(vertexTypes, edgeCollection)) {
addInvalidVertex(validationResults, id, vertexTypes, edgeType, edgeId);
}
}
}
});
return new CompositeValidationResult(validationResults);
}
Aggregations