List of usage examples for io.vertx.core Future succeededFuture
static <T> Future<T> succeededFuture(T result)
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService addVertex(String iClassName, String iClusterName, JsonObject properties, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from ww w.j av a 2 s . c om JsonObject _json = new JsonObject(); _json.put("iClassName", iClassName); _json.put("iClusterName", iClusterName); _json.put("properties", properties); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "addVertex"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService updateVertex(String id, JsonObject properties, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from ww w . j a v a 2 s . co m JsonObject _json = new JsonObject(); _json.put("id", id); _json.put("properties", properties); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "updateVertex"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService removeVertex(String id, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//w w w . java 2s. c om JsonObject _json = new JsonObject(); _json.put("id", id); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "removeVertex"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService getVertex(String id, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from ww w . j ava 2s.co m JsonObject _json = new JsonObject(); _json.put("id", id); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getVertex"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService getVerticesOfClass(String iClassName, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from w ww . java 2 s.c om JsonObject _json = new JsonObject(); _json.put("iClassName", iClassName); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getVerticesOfClass"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService getVertices(String iClassName, JsonObject vertexQuery, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }/*from www . j a v a 2 s .c o m*/ JsonObject _json = new JsonObject(); _json.put("iClassName", iClassName); _json.put("vertexQuery", vertexQuery); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getVertices"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService getRelatedVertices(String sourceId, String label, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }/* w w w .java 2 s. c om*/ JsonObject _json = new JsonObject(); _json.put("sourceId", sourceId); _json.put("label", label); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getRelatedVertices"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService addEdge(String sourceId, String destinationId, String label, JsonObject properties, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from w ww .java 2 s .co m JsonObject _json = new JsonObject(); _json.put("sourceId", sourceId); _json.put("destinationId", destinationId); _json.put("label", label); _json.put("properties", properties); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "addEdge"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService removeEdge(String id, Handler<AsyncResult<Record>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//from www . ja v a 2s . c om JsonObject _json = new JsonObject(); _json.put("id", id); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "removeEdge"); _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future .succeededFuture(res.result().body() == null ? null : new Record(res.result().body()))); } }); return this; }
From source file:io.rebind.vertx.orientdb.OrientDBServiceVertxEBProxy.java
License:Apache License
public OrientDBService removeEdges(String sourceId, String destinationId, String label, Handler<AsyncResult<List<Record>>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }/* ww w. java 2 s .c o m*/ JsonObject _json = new JsonObject(); _json.put("sourceId", sourceId); _json.put("destinationId", destinationId); _json.put("label", label); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "removeEdges"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { handler.handle(Future.failedFuture(res.cause())); } else { handler.handle(Future.succeededFuture(res.result().body().stream().map( o -> o instanceof Map ? new Record(new JsonObject((Map) o)) : new Record((JsonObject) o)) .collect(Collectors.toList()))); } }); return this; }