Example usage for io.vertx.core.json JsonObject JsonObject

List of usage examples for io.vertx.core.json JsonObject JsonObject

Introduction

In this page you can find the example usage for io.vertx.core.json JsonObject JsonObject.

Prototype

public JsonObject() 

Source Link

Document

Create a new, empty instance

Usage

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void getDocument(JsonObject docQuery, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//  www .  j av a2s  .com
    }
    JsonObject _json = new JsonObject();
    _json.put("docQuery", docQuery);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getDocument");
    _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()));
        }
    });
}

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void getVertex(JsonObject vertexQuery, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from  w ww  .j ava2 s . c  om
    }
    JsonObject _json = new JsonObject();
    _json.put("vertexQuery", vertexQuery);
    DeliveryOptions _deliveryOptions = 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()));
        }
    });
}

From source file:com.emikra.vertx.orientdb.OrientDBServiceVertxEBProxy.java

License:Apache License

public void getEdge(JsonObject edgeQuery, Handler<AsyncResult<JsonObject>> handler) {
    if (closed) {
        handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from   w  w  w. ja  v a 2 s.com*/
    }
    JsonObject _json = new JsonObject();
    _json.put("edgeQuery", edgeQuery);
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "getEdge");
    _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()));
        }
    });
}

From source file:com.englishtown.vertx.elasticsearch.ElasticSearchAdminServiceVertxEBProxy.java

License:Apache License

public void putMapping(List<String> indices, String type, JsonObject source, MappingOptions options,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from www  . java 2  s.c  om
    }
    JsonObject _json = new JsonObject();
    _json.put("indices", new JsonArray(indices));
    _json.put("type", type);
    _json.put("source", source);
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "putMapping");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java

License:Apache License

public void index(String index, String type, JsonObject source, IndexOptions options,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*  w w  w. ja va 2s. co m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("index", index);
    _json.put("type", type);
    _json.put("source", source);
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "index");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java

License:Apache License

public void update(String index, String type, String id, UpdateOptions options,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from w w w. jav a 2 s. c  o  m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("index", index);
    _json.put("type", type);
    _json.put("id", id);
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "update");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java

License:Apache License

public void get(String index, String type, String id, GetOptions options,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//www. j  av a 2s. c  om
    }
    JsonObject _json = new JsonObject();
    _json.put("index", index);
    _json.put("type", type);
    _json.put("id", id);
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "get");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java

License:Apache License

public void search(List<String> indices, SearchOptions options,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from w  w w  .  ja v a 2s .c o m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("indices", new JsonArray(indices));
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "search");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java

License:Apache License

public void searchScroll(String scrollId, SearchScrollOptions options,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from   w  ww  .  j  a  v  a2 s  .  c  o m
    }
    JsonObject _json = new JsonObject();
    _json.put("scrollId", scrollId);
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "searchScroll");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}

From source file:com.englishtown.vertx.elasticsearch.ElasticSearchServiceVertxEBProxy.java

License:Apache License

public void delete(String index, String type, String id, DeleteOptions options,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;//from w w  w  . j  a v  a2s. c  o m
    }
    JsonObject _json = new JsonObject();
    _json.put("index", index);
    _json.put("type", type);
    _json.put("id", id);
    _json.put("options", options == null ? null : options.toJson());
    DeliveryOptions _deliveryOptions = new DeliveryOptions();
    _deliveryOptions.addHeader("action", "delete");
    _vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
        if (res.failed()) {
            resultHandler.handle(Future.failedFuture(res.cause()));
        } else {
            resultHandler.handle(Future.succeededFuture(res.result().body()));
        }
    });
}