Пример #1
0
 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();
   }
 }