use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j-mobile-android by neo4j-contrib.
the class DbWrapper method deleteRelationshipIndex.
@Override
public void deleteRelationshipIndex(String name, ParcelableError err) throws RemoteException {
try {
checkCallerHasWritePermission();
resumeTrx();
try {
// this
RelationshipIndex index = mDb.index().forRelationships(name);
// will
// create
// the
// index
index.delete();
} finally {
suspendCurrentTrx("deleteRelationshipIndex");
}
} catch (Exception e) {
Log.e(TAG, "Failed to delete relationship index '" + name + "'", e);
err.setError(Errors.TRANSACTION, e.getMessage());
}
}
use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j-mobile-android by neo4j-contrib.
the class DbWrapper method addRelationshipToIndex.
@Override
public void addRelationshipToIndex(String name, long relationshipId, String key, ParcelableIndexValue value, ParcelableError err) throws RemoteException {
try {
checkCallerHasWritePermission();
resumeTrx();
try {
Relationship rel = mDb.getRelationshipById(relationshipId);
// this
RelationshipIndex index = mDb.index().forRelationships(name);
// will
// create
// the
// index
index.add(rel, key, value.get());
} finally {
suspendCurrentTrx("addRelationshipToIndex");
}
} catch (Exception e) {
Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
err.setError(Errors.TRANSACTION, e.getMessage());
}
}
use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j by neo4j.
the class RelatedNodesQuestionTest method question5346011.
@Test
public void question5346011() {
GraphDatabaseService service = new TestGraphDatabaseFactory().newImpermanentDatabase();
try (Transaction tx = service.beginTx()) {
RelationshipIndex index = service.index().forRelationships("exact");
// ...creation of the nodes and relationship
Node node1 = service.createNode();
Node node2 = service.createNode();
String a_uuid = "xyz";
Relationship relationship = node1.createRelationshipTo(node2, RelationshipType.withName("related"));
index.add(relationship, "uuid", a_uuid);
// query
IndexHits<Relationship> hits = index.get("uuid", a_uuid, node1, node2);
assertEquals(1, hits.size());
tx.success();
}
service.shutdown();
}
use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j by neo4j.
the class RecoveryTest method shouldNotAcceptValuesWithNullToString.
@Test
public void shouldNotAcceptValuesWithNullToString() throws Exception {
try (Transaction tx = db.beginTx()) {
Node node = db.createNode();
Node otherNode = db.createNode();
Relationship rel = node.createRelationshipTo(otherNode, DynamicRelationshipType.withName("recovery"));
Index<Node> nodeIndex = db.index().forNodes("node-index");
RelationshipIndex relationshipIndex = db.index().forRelationships("rel-index");
// Add
assertAddFailsWithIllegalArgument(nodeIndex, node, "key1", new ClassWithToStringAlwaysNull());
assertAddFailsWithIllegalArgument(relationshipIndex, rel, "key1", new ClassWithToStringAlwaysNull());
// Remove
assertRemoveFailsWithIllegalArgument(nodeIndex, node, "key1", new ClassWithToStringAlwaysNull());
assertRemoveFailsWithIllegalArgument(relationshipIndex, rel, "key1", new ClassWithToStringAlwaysNull());
tx.success();
}
forceRecover();
}
use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j by neo4j.
the class TestLuceneIndex method shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode.
@Test
public void shouldNotSeeDeletedRelationshipWhenQueryingWithStartAndEndNode() {
// GIVEN
RelationshipIndex index = relationshipIndex(EXACT_CONFIG);
Node start = graphDb.createNode();
Node end = graphDb.createNode();
RelationshipType type = withName("REL");
Relationship rel = start.createRelationshipTo(end, type);
index.add(rel, "Type", type.name());
finishTx(true);
beginTx();
// WHEN
IndexHits<Relationship> hits = index.get("Type", type.name(), start, end);
assertEquals(1, count(hits));
assertEquals(1, hits.size());
index.remove(rel);
// THEN
hits = index.get("Type", type.name(), start, end);
assertEquals(0, count(hits));
assertEquals(0, hits.size());
}
Aggregations