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

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

Introduction

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

Prototype

public JsonObject put(String key, Object value) 

Source Link

Document

Put an Object into the JSON object with the specified key.

Usage

From source file:io.rebind.vertx.orientdb.model.RecordConverter.java

License:Apache License

public static void toJson(Record obj, JsonObject json) {
    if (obj.getConnections() != null) {
        json.put("connections", new JsonArray(obj.getConnections().stream().map(item -> item.toJson())
                .collect(java.util.stream.Collectors.toList())));
    }/*  w  ww.  j ava 2  s  .c  om*/
    if (obj.getProperties() != null) {
        json.put("properties", obj.getProperties());
    }
    if (obj.getRid() != null) {
        json.put("rid", obj.getRid());
    }
    if (obj.getVersion() != null) {
        json.put("version", obj.getVersion());
    }
}

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.  ja va  2s .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;
    }// www  .  j ava 2 s.c  om
    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;
    }//from   ww w .  j  av a2 s  .  c  o  m
    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;
    }//  ww w .j ava  2 s. com
    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;
    }//  w w  w.j  a v  a2  s .c  o m
    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 w  w w. 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;
    }/*from   ww w  . j av a 2 s. c  o m*/
    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.ja va 2s .  c om*/
    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;
    }/* w  ww.j  av a2s.  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;
}