private Relationship relationship(long id) throws RelationshipNotFoundException { try { return graphDb.getRelationshipById(id); } catch (NotFoundException e) { throw new RelationshipNotFoundException(); } }
public IndexedEntityRepresentation getIndexedRelationship( String indexName, String key, String value, long id) { if (!relationshipIsIndexed(indexName, key, value, id)) throw new NotFoundException(); Relationship node = graphDb.getRelationshipById(id); return new IndexedEntityRepresentation( node, key, value, new RelationshipIndexRepresentation(indexName, Collections.<String, String>emptyMap())); }
public void removeFromRelationshipIndexNoKeyValue(String indexName, long id) { RelationshipIndex index = graphDb.index().forRelationships(indexName); Transaction tx = graphDb.beginTx(); try { index.remove(graphDb.getRelationshipById(id)); tx.success(); } finally { tx.finish(); } }
public boolean relationshipIsIndexed( String indexName, String key, Object value, long relationshipId) throws DatabaseBlockedException { Index<Relationship> index = graphDb.index().forRelationships(indexName); Transaction tx = graphDb.beginTx(); try { Relationship expectedNode = graphDb.getRelationshipById(relationshipId); IndexHits<Relationship> hits = index.get(key, value); boolean contains = iterableContains(hits, expectedNode); tx.success(); return contains; } finally { tx.finish(); } }
public IndexedEntityRepresentation addToRelationshipIndex( String indexName, String key, String value, long relationshipId) { Transaction tx = graphDb.beginTx(); try { Relationship relationship = graphDb.getRelationshipById(relationshipId); Index<Relationship> index = graphDb.index().forRelationships(indexName); index.add(relationship, key, value); tx.success(); return new IndexedEntityRepresentation( relationship, key, value, new RelationshipIndexRepresentation(indexName, Collections.<String, String>emptyMap())); } finally { tx.finish(); } }