use of org.neo4j.graphdb.NotFoundException 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);
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class SchemaImpl method getIndexPopulationProgress.
@Override
public IndexPopulationProgress getIndexPopulationProgress(IndexDefinition index) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
ReadOperations readOps = statement.readOperations();
NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
PopulationProgress progress = readOps.indexGetPopulationProgress(descriptor);
return new IndexPopulationProgress(progress.getCompleted(), progress.getTotal());
} catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class SchemaImpl method getIndexState.
@Override
public IndexState getIndexState(final IndexDefinition index) {
actions.assertInOpenTransaction();
try (Statement statement = statementContextSupplier.get()) {
ReadOperations readOps = statement.readOperations();
NewIndexDescriptor descriptor = getIndexDescriptor(readOps, index);
InternalIndexState indexState = readOps.indexGetState(descriptor);
switch(indexState) {
case POPULATING:
return POPULATING;
case ONLINE:
return ONLINE;
case FAILED:
return FAILED;
default:
throw new IllegalArgumentException(String.format("Illegal index state %s", indexState));
}
} catch (SchemaRuleNotFoundException | IndexNotFoundKernelException e) {
throw new NotFoundException(format("No index for label %s on property %s", index.getLabel().name(), index.getPropertyKeys()));
}
}
use of org.neo4j.graphdb.NotFoundException in project neo4j by neo4j.
the class GraphDatabaseFacade method getRelationshipById.
@Override
public Relationship getRelationshipById(long id) {
if (id < 0) {
throw new NotFoundException(format("Relationship %d not found", id), new EntityNotFoundException(EntityType.RELATIONSHIP, id));
}
try (Statement statement = spi.currentStatement()) {
try {
RelationshipProxy relationship = new RelationshipProxy(relActions, id);
statement.readOperations().relationshipVisit(id, relationship);
return relationship;
} catch (EntityNotFoundException e) {
throw new NotFoundException(format("Relationship %d not found", id), e);
}
}
}
use of org.neo4j.graphdb.NotFoundException 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);
}
}
Aggregations