use of org.neo4j.server.rest.repr.IndexRepresentation in project neo4j by neo4j.
the class TransactionWrappedDatabaseActions method createNodeIndex.
@Override
public IndexRepresentation createNodeIndex(Map<String, Object> indexSpecification) {
try (Transaction transaction = graph.beginTx()) {
IndexRepresentation indexRepresentation = super.createNodeIndex(indexSpecification);
transaction.success();
return indexRepresentation;
}
}
use of org.neo4j.server.rest.repr.IndexRepresentation in project neo4j by neo4j.
the class DatabaseActions method getIndexedNodes.
public ListRepresentation getIndexedNodes(String indexName, final String key, final String value) {
if (!graphDb.index().existsForNodes(indexName)) {
throw new NotFoundException();
}
Index<Node> index = graphDb.index().forNodes(indexName);
final IndexRepresentation indexRepresentation = new NodeIndexRepresentation(indexName);
final IndexHits<Node> indexHits = index.get(key, value);
final IterableWrapper<Representation, Node> results = new IterableWrapper<Representation, Node>(indexHits) {
@Override
protected Representation underlyingObjectToObject(Node node) {
return new IndexedEntityRepresentation(node, key, value, indexRepresentation);
}
};
return new ListRepresentation(RepresentationType.NODE, results);
}
use of org.neo4j.server.rest.repr.IndexRepresentation in project neo4j by neo4j.
the class DatabaseActions method getIndexedRelationships.
public ListRepresentation getIndexedRelationships(String indexName, final String key, final String value) {
if (!graphDb.index().existsForRelationships(indexName)) {
throw new NotFoundException();
}
Index<Relationship> index = graphDb.index().forRelationships(indexName);
final IndexRepresentation indexRepresentation = new RelationshipIndexRepresentation(indexName);
IterableWrapper<Representation, Relationship> result = new IterableWrapper<Representation, Relationship>(index.get(key, value)) {
@Override
protected Representation underlyingObjectToObject(Relationship relationship) {
return new IndexedEntityRepresentation(relationship, key, value, indexRepresentation);
}
};
return new ListRepresentation(RepresentationType.RELATIONSHIP, result);
}
Aggregations