class RefreshOperation extends AbstractNeo4JOperation {

    @Override
    public void execute(final Connection connection, final Graph<Node, Edge> graph) throws SQLException {
        for (final Node node : graph.vertexSet()) {

            final List<SetExpression> attributes = node.getAttributes().stream().filter(a -> !a.isId())
                    .map(a -> property(identifier(node.getId()).property(a.getName()), literal(a.getValue()))).collect(toList());

            final UpdateNext query = merge(node.toPath().withIdAttributes().build()).set(attributes);

            executeQuery(connection, query.toString());
        }

        for (final Edge edge : graph.edgeSet()) {
            final Node sourceNode = edge.getSourceNode();
            final Node targetNode = edge.getTargetNode();

            final List<SetExpression> attributes = edge.getAttributes().stream()
                    .map(a -> property(identifier(edge.getId()).property(a.getName()), literal(a.getValue()))).collect(toList());

            final UpdateNext query = match(sourceNode.toPath().withIdAttributes().build(), targetNode.toPath().withIdAttributes().build())
                    .merge(edge.toPath().build()).set(attributes);

            executeQuery(connection, query.toString());
        }
    }

}