List of usage examples for io.vertx.core.json JsonObject JsonObject
public JsonObject()
From source file:com.github.ithildir.airbot.model.Location.java
License:Open Source License
public JsonObject toJson() { JsonObject jsonObject = new JsonObject(); LocationConverter.toJson(this, jsonObject); return jsonObject; }
From source file:com.github.ithildir.airbot.model.Measurement.java
License:Open Source License
public JsonObject toJson() { JsonObject jsonObject = new JsonObject(); MeasurementConverter.toJson(this, jsonObject); return jsonObject; }
From source file:com.github.ithildir.airbot.model.MeasurementConverter.java
License:Apache License
public static void toJson(Measurement obj, JsonObject json) { json.put("aqi", obj.getAqi()); if (obj.getCity() != null) { json.put("city", obj.getCity()); }//from w w w. j a v a2 s . c o m if (obj.getComments() != null) { json.put("comments", obj.getComments()); } if (obj.getMainPollutant() != null) { json.put("mainPollutant", obj.getMainPollutant()); } json.put("time", obj.getTime()); if (obj.getValues() != null) { JsonObject map = new JsonObject(); obj.getValues().forEach((key, value) -> map.put(key, value)); json.put("values", map); } }
From source file:com.github.ithildir.airbot.server.SingleUserAuthProvider.java
License:Open Source License
public SingleUserAuthProvider(String username, String password) { _username = Objects.requireNonNull(username); _password = Objects.requireNonNull(password); _user = new AbstractUser() { @Override/*from ww w .ja v a2 s . c om*/ public JsonObject principal() { JsonObject jsonObject = new JsonObject(); jsonObject.put("username", _username); return jsonObject; } @Override public void setAuthProvider(AuthProvider authProvider) { // Nothing to do } @Override protected void doIsPermitted(String permission, Handler<AsyncResult<Boolean>> handler) { handler.handle(Future.succeededFuture(Boolean.TRUE)); } }; }
From source file:com.github.ithildir.airbot.service.GeoServiceVertxEBProxy.java
License:Apache License
public void getLocationByCoordinates(double latitude, double longitude, Handler<AsyncResult<Location>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;// ww w. j av a 2 s . c o m } JsonObject _json = new JsonObject(); _json.put("latitude", latitude); _json.put("longitude", longitude); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getLocationByCoordinates"); _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 Location(res.result().body()))); } }); }
From source file:com.github.ithildir.airbot.service.GeoServiceVertxEBProxy.java
License:Apache License
public void getLocationByQuery(String query, Handler<AsyncResult<Location>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;//from www .ja v a2 s .c o m } JsonObject _json = new JsonObject(); _json.put("query", query); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getLocationByQuery"); _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 Location(res.result().body()))); } }); }
From source file:com.github.ithildir.airbot.service.MeasurementServiceVertxEBProxy.java
License:Apache License
public void getMeasurement(double latitude, double longitude, Handler<AsyncResult<Measurement>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/*w w w . j a v a 2s. c om*/ } JsonObject _json = new JsonObject(); _json.put("latitude", latitude); _json.put("longitude", longitude); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getMeasurement"); _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 Measurement(res.result().body()))); } }); }
From source file:com.github.ithildir.airbot.service.MeasurementServiceVertxEBProxy.java
License:Apache License
public void getName(Handler<AsyncResult<String>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;// w w w.j av a2s. c o m } JsonObject _json = new JsonObject(); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getName"); _vertx.eventBus().<String>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.github.ithildir.airbot.service.MeasurementServiceVertxEBProxy.java
License:Apache License
public void init(Handler<AsyncResult<Void>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/*from w w w.j a va 2 s . com*/ } JsonObject _json = new JsonObject(); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "init"); _vertx.eventBus().<Void>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.github.ithildir.airbot.service.UserServiceVertxEBProxy.java
License:Apache License
public void getUserLocation(String userId, Handler<AsyncResult<Location>> handler) { if (closed) { handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;/*from www . j av a 2s .c om*/ } JsonObject _json = new JsonObject(); _json.put("userId", userId); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "getUserLocation"); _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 Location(res.result().body()))); } }); }