use of org.neo4j.ogm.request.Statement in project neo4j-ogm by neo4j.
the class BoltRequest method execute.
@Override
public Response<RowModel> execute(DefaultRequest query) {
final List<RowModel> rowModels = new ArrayList<>();
String[] columns = null;
for (Statement statement : query.getStatements()) {
Result result = executeRequest(statement);
if (columns == null) {
try {
List<String> columnSet = result.keys();
columns = columnSet.toArray(new String[columnSet.size()]);
} catch (ClientException e) {
throw new CypherException(e.code(), e.getMessage(), e);
}
}
try (RowModelResponse rowModelResponse = new RowModelResponse(result, entityAdapter)) {
RowModel model;
while ((model = rowModelResponse.next()) != null) {
rowModels.add(model);
}
result.consume();
} catch (ClientException e) {
throw new CypherException(e.code(), e.getMessage(), e);
}
}
return new MultiStatementBasedResponse(columns, rowModels);
}
use of org.neo4j.ogm.request.Statement in project neo4j-ogm by neo4j.
the class MultiStatementCypherCompiler method deleteRelationshipEntityStatements.
@Override
public List<Statement> deleteRelationshipEntityStatements() {
assertStatementFactoryExists();
// Group relationships by type
Map<String, Set<Edge>> deletedRelsByType = groupRelationshipsByType(deletedRelationshipEntityBuilders);
List<Statement> statements = new ArrayList<>();
for (Set<Edge> edges : deletedRelsByType.values()) {
DeletedRelationshipEntityStatementBuilder deletedRelationshipBuilder = new DeletedRelationshipEntityStatementBuilder(edges, statementFactory);
statements.add(deletedRelationshipBuilder.build());
}
return statements;
}
use of org.neo4j.ogm.request.Statement in project neo4j-ogm by neo4j.
the class MultiStatementCypherCompiler method updateRelationshipStatements.
@Override
public List<Statement> updateRelationshipStatements() {
assertStatementFactoryExists();
if (existingRelationshipBuilders.isEmpty()) {
return Collections.emptyList();
}
Map<Boolean, Set<Edge>> collect = existingRelationshipBuilders.values().stream().collect(partitioningBy(RelationshipBuilder::isDirty, Collectors.mapping(RelationshipBuilder::edge, Collectors.toSet())));
List<Statement> result = new ArrayList<>();
if (!collect.get(true).isEmpty()) {
ExistingRelationshipStatementBuilder builder = new ExistingRelationshipStatementBuilder(collect.get(true), statementFactory, true);
result.add(builder.build());
}
if (!collect.get(false).isEmpty()) {
ExistingRelationshipStatementBuilder builder = new ExistingRelationshipStatementBuilder(collect.get(false), statementFactory, false);
result.add(builder.build());
}
return result;
}
use of org.neo4j.ogm.request.Statement in project neo4j-ogm by neo4j.
the class MultiStatementCypherCompiler method updateNodesStatements.
@Override
public List<Statement> updateNodesStatements() {
assertStatementFactoryExists();
Map<String, Set<Node>> existingNodesByLabels = groupNodesByLabel(existingNodeBuilders.values());
List<Statement> statements = new ArrayList<>(existingNodesByLabels.size());
for (Set<Node> nodeModels : existingNodesByLabels.values()) {
ExistingNodeStatementBuilder existingNodeBuilder = new ExistingNodeStatementBuilder(nodeModels, statementFactory);
statements.add(existingNodeBuilder.build());
}
return statements;
}
use of org.neo4j.ogm.request.Statement 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();
}
Aggregations