use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j-mobile-android by neo4j-contrib.
the class DbWrapper method updateRelationshipInIndex.
@Override
public void updateRelationshipInIndex(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
// See http://docs.neo4j.org/chunked/stable/indexing-update.html
index.remove(rel, key, value.get());
index.add(rel, key, value.get());
} finally {
suspendCurrentTrx("updateRelationshipInIndex");
}
} catch (Exception e) {
Log.e(TAG, "Failed to update relationship in 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 removeRelationshipKeyFromIndex.
@Override
public void removeRelationshipKeyFromIndex(String name, long relationshipId, String key, 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.remove(rel, key);
} finally {
suspendCurrentTrx("removeRelationshipKeyFromIndex");
}
} 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-mobile-android by neo4j-contrib.
the class DbWrapper method getRelationshipsFromIndex.
@Override
public IRelationshipIterator getRelationshipsFromIndex(String name, String key, ParcelableIndexValue value, ParcelableError err) throws RemoteException {
try {
resumeTrxIfExists();
try {
// this
RelationshipIndex index = mDb.index().forRelationships(name);
// will
// create
// the
// index
IndexHits<Relationship> hits = index.get(key, value.get());
return new RelationshipIteratorWrapper(hits);
} finally {
suspendCurrentTrx("getRelationshipsFromIndex");
}
} catch (Exception e) {
Log.e(TAG, "Failed to add relationship to index '" + name + "'", e);
err.setError(Errors.TRANSACTION, e.getMessage());
return null;
}
}
use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j by neo4j.
the class TestTimeline method relationshipTimeline.
private TimelineIndex<PropertyContainer> relationshipTimeline() {
try (Transaction tx = db.beginTx()) {
RelationshipIndex relationshipIndex = db.index().forRelationships("timeline");
tx.success();
return new LuceneTimeline(db, relationshipIndex);
}
}
use of org.neo4j.graphdb.index.RelationshipIndex in project neo4j by neo4j.
the class TestLuceneIndex method tooLongValuesAreNotAllowedInRelationshipIndex.
@Test
public void tooLongValuesAreNotAllowedInRelationshipIndex() {
RelationshipIndex index = relationshipIndex(EXACT_CONFIG);
String tooLongValue = RandomStringUtils.randomAlphabetic(36000);
try {
index.add(graphDb.createNode().createRelationshipTo(graphDb.createNode(), MyRelTypes.TEST), "key", tooLongValue);
fail("Validation exception expected. Such long values are not allowed in the index.");
} catch (IllegalArgumentException e) {
// expected
}
try {
index.add(graphDb.createNode().createRelationshipTo(graphDb.createNode(), MyRelTypes.TEST), "key", new String[] { "a", tooLongValue, "c" });
fail("Validation exception expected. Such long values are not allowed in the index.");
} catch (IllegalArgumentException e) {
// expected
}
}
Aggregations