Search in sources :

Example 1 with IndexRepresentation

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;
    }
}
Also used : IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) Transaction(org.neo4j.graphdb.Transaction)

Example 2 with 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);
}
Also used : RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) Node(org.neo4j.graphdb.Node) StartNodeNotFoundException(org.neo4j.server.rest.domain.StartNodeNotFoundException) NotFoundException(org.neo4j.graphdb.NotFoundException) EndNodeNotFoundException(org.neo4j.server.rest.domain.EndNodeNotFoundException) PropertiesRepresentation(org.neo4j.server.rest.repr.PropertiesRepresentation) ScoredNodeRepresentation(org.neo4j.server.rest.repr.ScoredNodeRepresentation) NodeRepresentation(org.neo4j.server.rest.repr.NodeRepresentation) ScoredRelationshipRepresentation(org.neo4j.server.rest.repr.ScoredRelationshipRepresentation) PathRepresentation(org.neo4j.server.rest.repr.PathRepresentation) ConstraintDefinitionRepresentation(org.neo4j.server.rest.repr.ConstraintDefinitionRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) Representation(org.neo4j.server.rest.repr.Representation) IndexDefinitionRepresentation(org.neo4j.server.rest.repr.IndexDefinitionRepresentation) WeightedPathRepresentation(org.neo4j.server.rest.repr.WeightedPathRepresentation) RelationshipIndexRootRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRootRepresentation) RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) RelationshipRepresentation(org.neo4j.server.rest.repr.RelationshipRepresentation) ValueRepresentation(org.neo4j.server.rest.repr.ValueRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRootRepresentation(org.neo4j.server.rest.repr.NodeIndexRootRepresentation) DatabaseRepresentation(org.neo4j.server.rest.repr.DatabaseRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) IterableWrapper(org.neo4j.helpers.collection.IterableWrapper) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation)

Example 3 with IndexRepresentation

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);
}
Also used : RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) Relationship(org.neo4j.graphdb.Relationship) StartNodeNotFoundException(org.neo4j.server.rest.domain.StartNodeNotFoundException) NotFoundException(org.neo4j.graphdb.NotFoundException) EndNodeNotFoundException(org.neo4j.server.rest.domain.EndNodeNotFoundException) PropertiesRepresentation(org.neo4j.server.rest.repr.PropertiesRepresentation) ScoredNodeRepresentation(org.neo4j.server.rest.repr.ScoredNodeRepresentation) NodeRepresentation(org.neo4j.server.rest.repr.NodeRepresentation) ScoredRelationshipRepresentation(org.neo4j.server.rest.repr.ScoredRelationshipRepresentation) PathRepresentation(org.neo4j.server.rest.repr.PathRepresentation) ConstraintDefinitionRepresentation(org.neo4j.server.rest.repr.ConstraintDefinitionRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation) Representation(org.neo4j.server.rest.repr.Representation) IndexDefinitionRepresentation(org.neo4j.server.rest.repr.IndexDefinitionRepresentation) WeightedPathRepresentation(org.neo4j.server.rest.repr.WeightedPathRepresentation) RelationshipIndexRootRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRootRepresentation) RelationshipIndexRepresentation(org.neo4j.server.rest.repr.RelationshipIndexRepresentation) RelationshipRepresentation(org.neo4j.server.rest.repr.RelationshipRepresentation) ValueRepresentation(org.neo4j.server.rest.repr.ValueRepresentation) IndexRepresentation(org.neo4j.server.rest.repr.IndexRepresentation) NodeIndexRootRepresentation(org.neo4j.server.rest.repr.NodeIndexRootRepresentation) DatabaseRepresentation(org.neo4j.server.rest.repr.DatabaseRepresentation) NodeIndexRepresentation(org.neo4j.server.rest.repr.NodeIndexRepresentation) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) IterableWrapper(org.neo4j.helpers.collection.IterableWrapper) IndexedEntityRepresentation(org.neo4j.server.rest.repr.IndexedEntityRepresentation) ListRepresentation(org.neo4j.server.rest.repr.ListRepresentation)

Aggregations

IndexRepresentation (org.neo4j.server.rest.repr.IndexRepresentation)3 NotFoundException (org.neo4j.graphdb.NotFoundException)2 IterableWrapper (org.neo4j.helpers.collection.IterableWrapper)2 EndNodeNotFoundException (org.neo4j.server.rest.domain.EndNodeNotFoundException)2 StartNodeNotFoundException (org.neo4j.server.rest.domain.StartNodeNotFoundException)2 ConstraintDefinitionRepresentation (org.neo4j.server.rest.repr.ConstraintDefinitionRepresentation)2 DatabaseRepresentation (org.neo4j.server.rest.repr.DatabaseRepresentation)2 IndexDefinitionRepresentation (org.neo4j.server.rest.repr.IndexDefinitionRepresentation)2 IndexedEntityRepresentation (org.neo4j.server.rest.repr.IndexedEntityRepresentation)2 ListRepresentation (org.neo4j.server.rest.repr.ListRepresentation)2 NodeIndexRepresentation (org.neo4j.server.rest.repr.NodeIndexRepresentation)2 NodeIndexRootRepresentation (org.neo4j.server.rest.repr.NodeIndexRootRepresentation)2 NodeRepresentation (org.neo4j.server.rest.repr.NodeRepresentation)2 PathRepresentation (org.neo4j.server.rest.repr.PathRepresentation)2 PropertiesRepresentation (org.neo4j.server.rest.repr.PropertiesRepresentation)2 RelationshipIndexRepresentation (org.neo4j.server.rest.repr.RelationshipIndexRepresentation)2 RelationshipIndexRootRepresentation (org.neo4j.server.rest.repr.RelationshipIndexRootRepresentation)2 RelationshipRepresentation (org.neo4j.server.rest.repr.RelationshipRepresentation)2 Representation (org.neo4j.server.rest.repr.Representation)2 ScoredNodeRepresentation (org.neo4j.server.rest.repr.ScoredNodeRepresentation)2