use of org.neo4j.ogm.session.request.DefaultRequest in project neo4j-ogm by neo4j.
the class AutoIndexManager method assertIndexes.
private void assertIndexes() {
LOGGER.debug("Asserting indexes and constraints");
List<Statement> dropStatements = new ArrayList<>();
List<AutoIndex> dbIndexes = loadIndexesFromDB();
for (AutoIndex dbIndex : dbIndexes) {
LOGGER.debug("[{}] added to drop statements.", dbIndex.getDescription());
dropStatements.add(dbIndex.getDropStatement());
}
DefaultRequest dropIndexesRequest = new DefaultRequest();
dropIndexesRequest.setStatements(dropStatements);
LOGGER.debug("Dropping all indexes and constraints");
// make sure drop and create happen in separate transactions
// neo does not support that
session.doInTransaction(() -> {
session.requestHandler().execute(dropIndexesRequest);
}, READ_WRITE);
create();
}
use of org.neo4j.ogm.session.request.DefaultRequest in project neo4j-ogm by neo4j.
the class AutoIndexManager method create.
private void create() {
// build indexes according to metadata
List<Statement> statements = new ArrayList<>();
for (AutoIndex index : indexes) {
final Statement createStatement = index.getCreateStatement();
statements.add(createStatement);
LOGGER.debug("[{}] added to create statements.", createStatement);
}
LOGGER.debug("Creating indexes and constraints.");
DefaultRequest request = new DefaultRequest();
request.setStatements(statements);
session.doInTransaction(() -> session.requestHandler().execute(request).close(), READ_WRITE);
}
use of org.neo4j.ogm.session.request.DefaultRequest in project neo4j-ogm by neo4j.
the class AutoIndexManager method executeStatements.
private void executeStatements(List<Statement> statements) {
DefaultRequest request = new DefaultRequest();
request.setStatements(statements);
session.doInTransaction(() -> {
try (Response<RowModel> response = session.requestHandler().execute(request)) {
// Success
}
}, READ_WRITE);
}
Aggregations