Search in sources :

Example 1 with CastingIterator

use of org.neo4j.helpers.collection.CastingIterator in project neo4j by neo4j.

the class ConstraintEnforcingEntityOperations method nodeSetProperty.

@Override
public Property nodeSetProperty(KernelStatement state, long nodeId, DefinedProperty property) throws EntityNotFoundException, AutoIndexingKernelException, InvalidTransactionTypeKernelException, ConstraintValidationException {
    try (Cursor<NodeItem> cursor = nodeCursorById(state, nodeId)) {
        NodeItem node = cursor.get();
        Iterator<ConstraintDescriptor> constraints = getConstraintsInvolvingProperty(state, property.propertyKeyId());
        Iterator<UniquenessConstraintDescriptor> uniquenessConstraints = new CastingIterator<>(constraints, UniquenessConstraintDescriptor.class);
        nodeSchemaMatcher.onMatchingSchema(state, uniquenessConstraints, node, property.propertyKeyId(), constraint -> {
            validateNoExistingNodeWithExactValues(state, constraint, getAllPropertyValues(state, constraint.schema(), node, property), node.id());
        });
    }
    return entityWriteOperations.nodeSetProperty(state, nodeId, property);
}
Also used : NodeItem(org.neo4j.storageengine.api.NodeItem) ConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor) UniquenessConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor) NodeExistenceConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.NodeExistenceConstraintDescriptor) RelExistenceConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.RelExistenceConstraintDescriptor) UniquenessConstraintDescriptor(org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor) CastingIterator(org.neo4j.helpers.collection.CastingIterator)

Aggregations

CastingIterator (org.neo4j.helpers.collection.CastingIterator)1 ConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.ConstraintDescriptor)1 NodeExistenceConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.NodeExistenceConstraintDescriptor)1 RelExistenceConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.RelExistenceConstraintDescriptor)1 UniquenessConstraintDescriptor (org.neo4j.kernel.api.schema_new.constaints.UniquenessConstraintDescriptor)1 NodeItem (org.neo4j.storageengine.api.NodeItem)1