Search in sources :

Example 1 with ValidationResult

use of nl.knaw.huygens.timbuctoo.server.healthchecks.ValidationResult 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);
}
Also used : ElementValidationResult(nl.knaw.huygens.timbuctoo.server.healthchecks.ElementValidationResult) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) CompositeValidationResult(nl.knaw.huygens.timbuctoo.server.healthchecks.CompositeValidationResult) ElementValidationResult(nl.knaw.huygens.timbuctoo.server.healthchecks.ElementValidationResult) ValidationResult(nl.knaw.huygens.timbuctoo.server.healthchecks.ValidationResult) CompositeValidationResult(nl.knaw.huygens.timbuctoo.server.healthchecks.CompositeValidationResult)

Aggregations

Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)1 CompositeValidationResult (nl.knaw.huygens.timbuctoo.server.healthchecks.CompositeValidationResult)1 ElementValidationResult (nl.knaw.huygens.timbuctoo.server.healthchecks.ElementValidationResult)1 ValidationResult (nl.knaw.huygens.timbuctoo.server.healthchecks.ValidationResult)1