Search in sources :

Example 1 with RowModelResponse

use of org.neo4j.ogm.drivers.bolt.response.RowModelResponse 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);
}
Also used : RowModelResponse(org.neo4j.ogm.drivers.bolt.response.RowModelResponse) GraphRowModelResponse(org.neo4j.ogm.drivers.bolt.response.GraphRowModelResponse) Statement(org.neo4j.ogm.request.Statement) ArrayList(java.util.ArrayList) RowModel(org.neo4j.ogm.model.RowModel) ClientException(org.neo4j.driver.exceptions.ClientException) CypherException(org.neo4j.ogm.exception.CypherException) Result(org.neo4j.driver.Result)

Aggregations

ArrayList (java.util.ArrayList)1 Result (org.neo4j.driver.Result)1 ClientException (org.neo4j.driver.exceptions.ClientException)1 GraphRowModelResponse (org.neo4j.ogm.drivers.bolt.response.GraphRowModelResponse)1 RowModelResponse (org.neo4j.ogm.drivers.bolt.response.RowModelResponse)1 CypherException (org.neo4j.ogm.exception.CypherException)1 RowModel (org.neo4j.ogm.model.RowModel)1 Statement (org.neo4j.ogm.request.Statement)1