Search in sources :

Example 6 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class InternalAutoIndexOperations method propertyChanged.

@Override
public void propertyChanged(DataWriteOperations ops, long entityId, Property oldProperty, Property newProperty) throws AutoIndexingKernelException {
    if (enabled) {
        try {
            String name = propertyKeyLookup.getTokenById(oldProperty.propertyKeyId()).name();
            if (propertyKeysToInclude.get().contains(name)) {
                ensureIndexExists(ops);
                type.remove(ops, entityId, name, oldProperty.value());
                type.add(ops, entityId, name, newProperty.value());
            }
        } catch (LegacyIndexNotFoundKernelException | EntityNotFoundException | PropertyNotFoundException e) {
            throw new AutoIndexingKernelException(e);
        } catch (TokenNotFoundException e) {
            // KernelException now
            throw new AutoIndexingKernelException(new PropertyKeyIdNotFoundKernelException(oldProperty.propertyKeyId(), e));
        }
    }
}
Also used : PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) LegacyIndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) TokenNotFoundException(org.neo4j.kernel.impl.core.TokenNotFoundException) AutoIndexingKernelException(org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 7 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class GraphPropertiesProxy method getAllProperties.

@Override
public Map<String, Object> getAllProperties() {
    try (Statement statement = actions.statement()) {
        Map<String, Object> properties = new HashMap<>();
        ReadOperations readOperations = statement.readOperations();
        PrimitiveIntIterator propertyKeys = readOperations.graphGetPropertyKeys();
        while (propertyKeys.hasNext()) {
            int propertyKeyId = propertyKeys.next();
            properties.put(readOperations.propertyKeyGetName(propertyKeyId), readOperations.graphGetProperty(propertyKeyId));
        }
        return properties;
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
}
Also used : ReadOperations(org.neo4j.kernel.api.ReadOperations) KeyReadOperations(org.neo4j.kernel.impl.api.operations.KeyReadOperations) HashMap(java.util.HashMap) Statement(org.neo4j.kernel.api.Statement) PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 8 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class NodeProxy method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    try (Statement statement = actions.statement()) {
        List<String> keys = new ArrayList<>();
        PrimitiveIntIterator properties = statement.readOperations().nodeGetPropertyKeys(getId());
        while (properties.hasNext()) {
            keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
        }
        return keys;
    } catch (EntityNotFoundException e) {
        throw new NotFoundException("Node not found", e);
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
}
Also used : Statement(org.neo4j.kernel.api.Statement) ArrayList(java.util.ArrayList) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Example 9 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class RelationshipProxy method getAllProperties.

@Override
public Map<String, Object> getAllProperties() {
    try (Statement statement = actions.statement()) {
        try (Cursor<RelationshipItem> relationship = statement.readOperations().relationshipCursorById(getId())) {
            try (Cursor<PropertyItem> propertyCursor = statement.readOperations().relationshipGetProperties(relationship.get())) {
                Map<String, Object> properties = new HashMap<>();
                // Get all properties
                while (propertyCursor.next()) {
                    String name = statement.readOperations().propertyKeyGetName(propertyCursor.get().propertyKeyId());
                    properties.put(name, propertyCursor.get().value());
                }
                return properties;
            }
        } catch (EntityNotFoundException e) {
            throw new NotFoundException("Relationship not found", e);
        }
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.", e);
    }
}
Also used : HashMap(java.util.HashMap) Statement(org.neo4j.kernel.api.Statement) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException) PropertyItem(org.neo4j.storageengine.api.PropertyItem) RelationshipItem(org.neo4j.storageengine.api.RelationshipItem)

Example 10 with PropertyKeyIdNotFoundKernelException

use of org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException in project neo4j by neo4j.

the class RelationshipProxy method getPropertyKeys.

@Override
public Iterable<String> getPropertyKeys() {
    try (Statement statement = actions.statement()) {
        List<String> keys = new ArrayList<>();
        PrimitiveIntIterator properties = statement.readOperations().relationshipGetPropertyKeys(getId());
        while (properties.hasNext()) {
            keys.add(statement.readOperations().propertyKeyGetName(properties.next()));
        }
        return keys;
    } catch (EntityNotFoundException e) {
        throw new NotFoundException("Relationship not found", e);
    } catch (PropertyKeyIdNotFoundKernelException e) {
        throw new IllegalStateException("Property key retrieved through kernel API should exist.");
    }
}
Also used : Statement(org.neo4j.kernel.api.Statement) ArrayList(java.util.ArrayList) NotFoundException(org.neo4j.graphdb.NotFoundException) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyNotFoundException(org.neo4j.kernel.api.exceptions.PropertyNotFoundException) PrimitiveIntIterator(org.neo4j.collection.primitive.PrimitiveIntIterator) EntityNotFoundException(org.neo4j.kernel.api.exceptions.EntityNotFoundException) PropertyKeyIdNotFoundKernelException(org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)

Aggregations

PropertyKeyIdNotFoundKernelException (org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)10 EntityNotFoundException (org.neo4j.kernel.api.exceptions.EntityNotFoundException)7 Statement (org.neo4j.kernel.api.Statement)6 PropertyNotFoundException (org.neo4j.kernel.api.exceptions.PropertyNotFoundException)6 PrimitiveIntIterator (org.neo4j.collection.primitive.PrimitiveIntIterator)4 NotFoundException (org.neo4j.graphdb.NotFoundException)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 AutoIndexingKernelException (org.neo4j.kernel.api.exceptions.legacyindex.AutoIndexingKernelException)3 LegacyIndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.legacyindex.LegacyIndexNotFoundKernelException)3 TokenNotFoundException (org.neo4j.kernel.impl.core.TokenNotFoundException)3 PropertyItem (org.neo4j.storageengine.api.PropertyItem)3 NodeItem (org.neo4j.storageengine.api.NodeItem)2 RelationshipItem (org.neo4j.storageengine.api.RelationshipItem)2 Relationship (org.neo4j.graphdb.Relationship)1 ReadOperations (org.neo4j.kernel.api.ReadOperations)1 LabelNotFoundKernelException (org.neo4j.kernel.api.exceptions.LabelNotFoundKernelException)1 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)1 KeyReadOperations (org.neo4j.kernel.impl.api.operations.KeyReadOperations)1 Lock (org.neo4j.kernel.impl.locking.Lock)1