private Relationship relationship(long id) throws RelationshipNotFoundException {
   try {
     return graphDb.getRelationshipById(id);
   } catch (NotFoundException e) {
     throw new RelationshipNotFoundException();
   }
 }
示例#2
0
 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()));
 }
示例#3
0
 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();
   }
 }
示例#4
0
  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();
    }
  }
示例#5
0
 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();
   }
 }