Java 类io.vertx.core.json.JsonArray 实例源码

项目:xbrowser    文件:TableView.java   
private TableColumn processChoiceBoxColumnName(String name, JsonArray items){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    ObservableList list = FXCollections.observableArrayList();
    if(items!=null) list.addAll(items.getList());
    column.setCellFactory(ChoiceBoxTableCell.forTableColumn(list));
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
    });
    columnMap.put(name, column);
    return column;
}
项目:mbed-cloud-sdk-java    文件:Serializer.java   
private static JsonArray reformatJsonArray(JsonArray result, CaseConversion conversion, boolean capitalAtStart) {
    if (result == null || result.isEmpty()) {
        return new JsonArray();
    }
    List<Object> reformatedList = new LinkedList<>();
    for (Object obj : result.getList()) {
        if (obj instanceof JsonObject || obj instanceof Map) {
            @SuppressWarnings("unchecked")
            JsonObject jsonObject = (obj instanceof JsonObject) ? (JsonObject) obj
                    : new JsonObject((Map<String, Object>) obj);
            reformatedList.add(reformatJsonObject(jsonObject, conversion, capitalAtStart));
        } else {
            reformatedList.add(obj);
        }
    }
    return new JsonArray(reformatedList);

}
项目:vertx-zero    文件:RpcServerVisitor.java   
private ConcurrentMap<Integer, ServidorOptions> visit(final JsonArray serverData)
        throws ZeroException {
    LOGGER.info(Info.INF_B_VERIFY, KEY, ServerType.IPC, serverData.encode());
    Ruler.verify(KEY, serverData);
    final ConcurrentMap<Integer, ServidorOptions> map =
            new ConcurrentHashMap<>();
    Fn.itJArray(serverData, JsonObject.class, (item, index) -> {
        if (isServer(item)) {
            // 1. Extract port
            final int port = extractPort(item.getJsonObject(YKEY_CONFIG));
            // 2. Convert JsonObject to HttpServerOptions
            final ServidorOptions options = this.transformer.transform(item);
            Fn.safeNull(() -> {
                // 3. Add to map;
                map.put(port, options);
            }, port, options);
        }
    });
    LOGGER.info(Info.INF_A_VERIFY, KEY, ServerType.IPC, map.keySet());
    return map;
}
项目:vertx-musicstore    文件:GenreHandler.java   
@Override
public void handle(RoutingContext rc) {
  Long genreId = PathUtil.parseLongParam(rc.pathParam("genreId"));
  if (genreId == null) {
    rc.next();
    return;
  }

  dbClient.rxGetConnection().flatMap(sqlConnection -> {
    Single<JsonObject> gs = findGenre(sqlConnection, genreId);
    Single<JsonArray> als = findAlbums(sqlConnection, genreId);
    Single<JsonArray> ars = findArtists(sqlConnection, genreId);

    return Single.zip(gs, als, ars, (genre, albums, artists) -> {
      Map<String, Object> data = new HashMap<>();
      data.put("genre", genre);
      data.put("albums", albums);
      data.put("artists", artists);
      return data;
    }).doAfterTerminate(sqlConnection::close);
  }).flatMap(data -> {
    data.forEach(rc::put);
    return templateEngine.rxRender(rc, "templates/genre");
  }).subscribe(rc.response()::end, rc::fail);
}
项目:vertx-sfdc-platformevents    文件:CometD.java   
private JsonArray getSubscriptionBody() {
    final JsonArray result = new JsonArray();
    final JsonObject subscribe = new JsonObject();
    final JsonObject ext = new JsonObject();
    final JsonObject replay = new JsonObject();
    // TODO: Handling of Replay options need to be fixed here!
    replay.put(this.getListenerConfig().getListenSubject(), -2);
    ext.put("replay", replay);
    subscribe.put("ext", ext);
    subscribe.put("clientId", this.clientId);
    subscribe.put("channel", "/meta/subscribe");
    subscribe.put("subscription", this.getListenerConfig().getListenSubject());
    subscribe.put("id", "3");
    result.add(subscribe);
    return result;
}
项目:vertx-guide-for-java-devs    文件:WikiDatabaseServiceImpl.java   
@Override
public WikiDatabaseService fetchPage(String name, Handler<AsyncResult<JsonObject>> resultHandler) {
  dbClient.queryWithParams(sqlQueries.get(SqlQuery.GET_PAGE), new JsonArray().add(name), fetch -> {
    if (fetch.succeeded()) {
      JsonObject response = new JsonObject();
      ResultSet resultSet = fetch.result();
      if (resultSet.getNumRows() == 0) {
        response.put("found", false);
      } else {
        response.put("found", true);
        JsonArray row = resultSet.getResults().get(0);
        response.put("id", row.getInteger(0));
        response.put("rawContent", row.getString(1));
      }
      resultHandler.handle(Future.succeededFuture(response));
    } else {
      LOGGER.error("Database query error", fetch.cause());
      resultHandler.handle(Future.failedFuture(fetch.cause()));
    }
  });
  return this;
}
项目:vertx-musicstore    文件:ArtistHandler.java   
@Override
public void handle(RoutingContext rc) {
  Long artistId = PathUtil.parseLongParam(rc.pathParam("artistId"));
  if (artistId == null) {
    rc.next();
    return;
  }

  dbClient.rxGetConnection().flatMap(sqlConnection -> {
    Single<JsonObject> ars = findArtist(sqlConnection, artistId);
    Single<JsonArray> als = findAlbums(sqlConnection, artistId);

    return Single.zip(ars, als, (artist, albums) -> {
      Map<String, Object> data = new HashMap<>(2);
      data.put("artist", artist);
      data.put("albums", albums);
      return data;
    }).doAfterTerminate(sqlConnection::close);

  }).flatMap(data -> {
    data.forEach(rc::put);
    return templateEngine.rxRender(rc, "templates/artist");
  }).subscribe(rc.response()::end, rc::fail);
}
项目:vertx-sfdc-platformevents    文件:ApplicationStarter.java   
/**
 * Handler for the /api endpoint, listing out routes and loaded verticles
 * 
 * @param ctx
 */
private void rootHandler(final RoutingContext ctx) {
    ctx.response().putHeader(Constants.CONTENT_HEADER, Constants.CONTENT_TYPE_JSON);
    final JsonObject result = new JsonObject().put("RunningSince", Utils.getDateString(this.startDate));
    final JsonObject routeObject = new JsonObject();
    for (final Route r : this.router.getRoutes()) {
        final String p = r.getPath();
        if (p != null) {
            routeObject.put(p, String.valueOf(r));
        }
    }
    result.put("Routes", routeObject);
    final JsonArray verticleArray = new JsonArray(this.loadedVerticles);
    result.put("Verticles", verticleArray);
    ctx.response().end(result.encodePrettily());
}
项目:grafana-vertx-datasource    文件:BitcoinAdjustedData.java   
void enrichData(final Message<JsonArray> msg) {
    //array of
    /*
        [
            {target: "name", datapoints: [ [value,ts],[value,ts]] }
        ]
     */
    msg.reply(msg.body()
                 .stream()
                 .parallel()
                 .map(o -> (JsonObject) o)
                 .map(target -> new JsonObject().put("target", target.getString("target") + "_btc")
                                                .put("datapoints",
                                                     adjustByBitcoingPrice(target.getJsonArray("datapoints")))

                 )
                 .collect(toJsonArray()));
}
项目:vertx-postgresql-starter    文件:BookDatabaseServiceImpl.java   
@Override
public BookDatabaseService getBookById(int id, Handler<AsyncResult<JsonObject>> resultHandler) {
  pgConnectionPool.rxPreparedQuery(SQL_FIND_BOOK_BY_ID, Tuple.of(id))
    .map(PgResult::getDelegate)
    .subscribe(pgResult -> {
      JsonArray jsonArray = transformPgResultToJson(pgResult);
      if (jsonArray.size() == 0) {
        resultHandler.handle(Future.succeededFuture(new JsonObject()));
      } else {
        JsonObject dbResponse = jsonArray.getJsonObject(0);
        resultHandler.handle(Future.succeededFuture(dbResponse));
      }
    }, throwable -> {
      LOGGER.error("Failed to get the book by id " + id, throwable);
      resultHandler.handle(Future.failedFuture(throwable));
    });
  return this;
}
项目:jspare-vertx-ms-blueprint    文件:NotificationServiceVertxProxyHandler.java   
private Handler<AsyncResult<Set<Character>>> createSetCharHandler(Message msg) {
  return res -> {
    if (res.failed()) {
      if (res.cause() instanceof ServiceException) {
        msg.reply(res.cause());
      } else {
        msg.reply(new ServiceException(-1, res.cause().getMessage()));
      }
    } else {
      JsonArray arr = new JsonArray();
      for (Character chr: res.result()) {
        arr.add((int) chr);
      }
      msg.reply(arr);
    }
  };
}
项目:vertx-guide-for-java-devs    文件:WikiDatabaseServiceImpl.java   
@Override
public WikiDatabaseService fetchAllPages(Handler<AsyncResult<JsonArray>> resultHandler) {
  dbClient.query(sqlQueries.get(SqlQuery.ALL_PAGES), res -> {
    if (res.succeeded()) {
      JsonArray pages = new JsonArray(res.result()
        .getResults()
        .stream()
        .map(json -> json.getString(0))
        .sorted()
        .collect(Collectors.toList()));
      resultHandler.handle(Future.succeededFuture(pages));
    } else {
      LOGGER.error("Database query error", res.cause());
      resultHandler.handle(Future.failedFuture(res.cause()));
    }
  });
  return this;
}
项目:erp-frontend    文件:DefaultMenuManager.java   
protected void parseMenu (Stage stage, MenuBar menuBar, JsonArray jsonArray) {
    Platform.runLater(() -> {
        for (int i = 0; i < jsonArray.size(); i++) {
            //get menu entry
            JsonObject entry = jsonArray.getJsonObject(i);

            //get event and title
            //String event = entry.getString("event");
            String title = entry.getString("title");

            //create new menu
            Menu menu = new Menu(title);

            //add sub menus
            this.parseSubMenus(menu, entry.getJsonArray("submenus"));

            //add menu to menu bar
            menuBar.getMenus().add(menu);
        }

        menuBar.prefWidthProperty().bind(stage.widthProperty());
    });
}
项目:redpipe    文件:FCSPlugin.java   
@Override
public Single<Void> deployToResteasy(VertxResteasyDeployment deployment) {
    JsonArray packages = AppGlobals.get().getConfig().getJsonArray("scan");
    if(packages == null) {
        System.err.println("Not scanning any packages, please specify the 'scan' array of packages in configuration");
    }else {
        String[] packagesToScan = (String[]) packages.getList().toArray(new String[packages.size()+1]);
        packagesToScan[packagesToScan.length-1] = "net.redpipe.engine";
        new FastClasspathScanner(packagesToScan)
            .matchClassesWithAnnotation(Path.class, klass -> {
                if(!Modifier.isAbstract(klass.getModifiers()))
                    deployment.getActualResourceClasses().add(klass);
            })
            .matchClassesWithAnnotation(Provider.class, klass -> {
                if(!Modifier.isAbstract(klass.getModifiers()))
                    deployment.getActualProviderClasses().add(klass);
            })
            .scan();
    }
    return Single.just(null);
}
项目:vertx-sfdc-platformevents    文件:CometD.java   
private void step4ActionSubscribe() {
    if (this.shuttingDown || this.shutdownCompleted) {
        this.shutdownCompleted = true;
        return;
    }

    final JsonArray body = this.getSubscriptionBody();
    final HttpRequest<Buffer> request = this.initWebPostRequest(Constants.URL_SUBSCRIBE);

    request.sendJson(body, postReturn -> {
        if (postReturn.succeeded()) {
            this.step4ResultSubscribe(postReturn.result());
        } else {
            this.logger.error(postReturn.cause());
        }
    });
}
项目:AlipayWechatPlatform    文件:OfficialAccountSubRouter.java   
/**
 * 查询所有账号
 * 返回JSON包括id,name,email字段
 * 需要管理员权限
 */
private void getAccountList(RoutingContext rc) {
    if (forbidAccess(rc, "id", false)) {
        return;
    }
    log.debug("即将发送EventBus消息查询所有账号");
    vertx.eventBus().<JsonArray>send(ADDR_ACCOUNT_DB.get(), makeMessage(COMMAND_GET_ALL_ACCOUNT), ar -> {
        HttpServerResponse response = rc.response();
        if(ar.succeeded()){
            JsonArray rows = ar.result().body();
            response.putHeader("content-type", "application/json; charset=utf-8").end(rows.toString());
        } else {
            log.error("EventBus消息响应错误", ar.cause());
            response.setStatusCode(500).end("EventBus error!");
        }
    });
}
项目:moviediary    文件:UiMoviesPageTest.java   
@Test
public void testAddingView() throws Exception {
    goAndWaitForPageToLoad();
    searchForMovie();
    openDetailView();
    WebElement addToViewsButton = driver.findElementByCssSelector("#add-watch > div.card-content");
    sleep(driver, 5, visibilityOf(addToViewsButton));
    addToViewsButton.click();
    WebElement watchStartNowButton = driver.findElementById("watchStartNow");
    sleep(driver, 5, visibilityOf(watchStartNowButton));
    watchStartNowButton.click();
    driver.findElement(id("watchEndCalculate")).click();
    driver.findElement(id("add-btn")).click();
    await().atMost(5, SECONDS).until(() -> localDatabase
            .queryBlocking("SELECT * FROM Views WHERE MovieId = ?", new JsonArray().add(315837))
            .size() > 0);
}
项目:vertx-sfdc-platformevents    文件:Utils.java   
public static Map<String, Object> mappifyJsonObject(final JsonObject sourceJson) {
    final Map<String, Object> result = new LinkedHashMap<>();
    final Map<String, Object> sourceMap = sourceJson.getMap();
    sourceMap.forEach((key, value) -> {
        // Check for nested JSONObjects and JSONArrays
        if ((key != null) && (value != null)) {
            if (value instanceof JsonArray) {
                final JsonArray workArray = (JsonArray) value;
                result.put(key, Utils.mappifyJsonArray(workArray));
            } else if (value instanceof JsonObject) {
                final JsonObject workJson = (JsonObject) value;
                result.put(key, Utils.mappifyJsonObject(workJson));
            } else {
                result.put(key, value);
            }
        }

    });
    return result;
}
项目:AlipayWechatPlatform    文件:OrderDao.java   
/**
 * 支付完成后,更新订单信息
 * 包括支付平台的订单ID,以及支付时间
 */
public void updateAfterPaid(JsonObject order, Handler<Integer> callback) {
    String platOrderId = order.getString(PLATORDERID);
    if (platOrderId == null || platOrderId.length() == 0) {
        throw new IllegalArgumentException("OrderId of pay platform cannot be null!!!");
    }
    String orderId = order.getString(ORDERID);
    if (orderId == null || orderId.length() == 0)
        throw new IllegalArgumentException("OrderId in Order object cannot be null!!!");
    Integer type = order.getInteger(TYPE);
    if (type == null)
        throw new IllegalArgumentException("Type in Order object cannot be null!!!");
    String sql = "UPDATE awp_order SET platOrderId = ?, payTime = NOW() where orderId=? and type=?";
    JsonArray params = new JsonArray().add(platOrderId).add(orderId).add(type);
    update(sql, params, callback);
}
项目:vertx-kubernetes-workshop    文件:AuditVerticle.java   
private void storeInDatabase(JsonObject operation) {
    // 1. need to retrieve a connection
    // 2. execute the insertion statement
    // 3. close the connection


    // Step 1 get the connection
    Single<SQLConnection> connectionRetrieved = jdbc.rxGetConnection();

    // Step 2, when the connection is retrieved (this may have failed), do the insertion (upon success)
    Single<UpdateResult> update = connectionRetrieved
        .flatMap(connection ->
            connection.rxUpdateWithParams(INSERT_STATEMENT, new JsonArray().add(operation.encode()))

                // Step 3, when the insertion is done, close the connection.
                .doAfterTerminate(connection::close));

    update.subscribe(result -> {
        // Ok
    }, err -> {
        System.err.println("Failed to insert operation in database: " + err);
    });
}
项目:moviediary    文件:DatabaseServiceImpl.java   
/**
 * Inserts a Facebook, Google or IdCard user into database.
 */
@Override
public Future<JsonObject> insertUser(String username, String password, String firstname, String lastname) {
    if (!nonNull(username, password, firstname, lastname) || contains("", username, firstname, lastname)) {
        return failedFuture("Email, firstname and lastname must exist!");
    }
    return future(fut -> ifPresent(genString(), salt -> updateOrInsert(SQL_INSERT_USER, new JsonArray()
            .add(username)
            .add(firstname)
            .add(lastname)
            .add(hash(password, salt))
            .add(salt)).rxSetHandler()
            .doOnError(fut::fail)
            .subscribe(res -> insert(Table.SETTINGS, createDataMap(username)).rxSetHandler()
                    .subscribe(result -> fut.complete(res), fut::fail))));
}
项目:he-rss-poll    文件:JDGPutVerticle.java   
private void processEntries(Message<JsonArray> message) {

        long start = System.currentTimeMillis();
        vertx.executeBlocking(future -> {

            JsonArray entries = message.body();

            for (Object obj : entries.getList()) {
                JsonObject jobj = (JsonObject) obj;
                HEElementModel model = gson.fromJson(jobj.toString(), HEElementModel.class);

                this.getCache(cacheName).put(model.getGuid(), model);
            }

            future.complete();
        }, res -> {
            long stop = System.currentTimeMillis();
            log.info(String.format(PUT_MSG_FORMAT, stop - start));
        });
    }
项目:moviediary    文件:DatabaseServiceImpl.java   
@Override
public Future<JsonObject> getViewsMeta(String username, String jsonParam) {
    JsonObject json = new JsonObject(jsonParam);
    System.out.println(json.encodePrettily());
    json.put("start", formToDBDate(json.getString("start"), false));
    json.put("end", formToDBDate(json.getString("end"), true));
    StringBuilder sb = new StringBuilder(SQL_QUERY_VIEWS_META);
    ifTrue(json.getBoolean("is-first"), () -> sb.append(" AND WasFirst"));
    ifTrue(json.getBoolean("is-cinema"), () -> sb.append(" AND WasCinema"));
    System.out.println("QUERY");
    System.out.println(sb.toString());
    return query(sb.toString(), new JsonArray()
            .add(username)
            .add(json.getString("start"))
            .add(json.getString("end")));
}
项目:moviediary    文件:DatabaseServiceImpl.java   
@Override
public Future<JsonObject> insertSeasonViews(String username, JsonObject seasonData, String seriesId) { // TODO: 18/05/2017 test
    StringBuilder query = new StringBuilder(SQL_INSERT_SEASON);
    JsonArray episodes = seasonData.getJsonArray("episodes");
    JsonArray values = new JsonArray();
    ifFalse(episodes.isEmpty(), () -> {
        episodes.stream()
                .map(obj -> (JsonObject) obj)
                .peek(json -> query.append(" (?, ?, ?, ?, ?),"))
                .forEach(json -> values
                        .add(username)
                        .add(seriesId)
                        .add(json.getInteger("id"))
                        .add(seasonData.getString("_id"))
                        .add(currentTimeMillis()));
        query.deleteCharAt(query.length() - 1);
    });
    return updateOrInsert(query.toString(), values);
}
项目:vertx-zero    文件:EtcdData.java   
public <T> JsonObject write(final String path, final T data, final int ttl) {
    return Fn.getJvm(null, () -> {
        final EtcdKeyPutRequest request = this.client.put(path,
                Fn.getSemi(data instanceof JsonObject || data instanceof JsonArray,
                        LOGGER,
                        () -> Instance.invoke(data, "encode"),
                        data::toString));
        if (Values.ZERO != ttl) {
            request.ttl(ttl);
        }
        /** Timeout **/
        if (-1 != this.timeout) {
            request.timeout(this.timeout, TimeUnit.SECONDS);
        }
        final EtcdResponsePromise<EtcdKeysResponse> promise = request.send();
        final EtcdKeysResponse response = promise.get();
        return Jackson.serializeJson(response.getNode());
    }, path, data);
}
项目:vertx-zero    文件:To.java   
static <T> JsonArray toArray(
        final List<T> list,
        final String pojo
) {
    final JsonArray array = new JsonArray();
    Observable.fromIterable(list)
            .filter(Objects::nonNull)
            .map(item -> toJson(item, pojo))
            .subscribe(array::add);
    return array;
}
项目:moviediary    文件:ConfigRxRetriever.java   
public ConfigRxRetriever withDirectory(String dirPath) {
  options.addStore(new ConfigStoreOptions()
      .setType("directory")
      .setConfig(new JsonObject()
          .put("path", dirPath)
          .put("filesets", new JsonArray()
              .add(new JsonObject().put("pattern", "*.json"))
              .add(new JsonObject().put("pattern", "*.properties").put("format", "properties")))));
  return this;
}
项目:vertx-zero    文件:Async.java   
static <T> Future<Envelop> toUnique(
        final String pojo,
        final CompletableFuture<List<T>> completableFuture
) {
    final Future<Envelop> future = Future.future();
    final Future<JsonArray> arrayFuture = Async.toArrayFuture(pojo, completableFuture);
    // future.complete(To.toEnvelop(To.toUnique(arrayFuture.result(), pojo)));
    arrayFuture.setHandler(item -> future.complete(To.toEnvelop(To.toUnique(item.result(), pojo))));
    return future;
}
项目:vertx-guide-for-java-devs    文件:WikiDatabaseServiceImpl.java   
@Override
public WikiDatabaseService deletePage(int id, Handler<AsyncResult<Void>> resultHandler) {
  JsonArray data = new JsonArray().add(id);
  dbClient.rxUpdateWithParams(sqlQueries.get(SqlQuery.DELETE_PAGE), data)
    .map(res -> (Void) null)
    .subscribe(RxHelper.toSubscriber(resultHandler));
  return this;
}
项目:vertx-guide-for-java-devs_chinese    文件:WikiDatabaseServiceImpl.java   
@Override
public WikiDatabaseService createPage(String title, String markdown, Handler<AsyncResult<Void>> resultHandler) {
  JsonArray data = new JsonArray().add(title).add(markdown);
  dbClient.updateWithParams(sqlQueries.get(SqlQuery.CREATE_PAGE), data, res -> {
    if (res.succeeded()) {
      resultHandler.handle(Future.succeededFuture());
    } else {
      LOGGER.error("Database query error", res.cause());
      resultHandler.handle(Future.failedFuture(res.cause()));
    }
  });
  return this;
}
项目:rms-deployer    文件:BaseUtil.java   
/**
 * Convert JsonArray into list with appropriate type checking
 *
 * @param jsonArray JsonArray to be converted to List
 * @param cls       Class to be used for type checking and casting
 * @param <T>       Type of class used for checking and casting
 * @return Converted List
 */
public static <T> List<T> jsonArrayToList(JsonArray jsonArray, Class<T> cls) {
    List<T> outList = new ArrayList<T>();
    Iterator<Object> extCpIter = jsonArray.iterator();
    Object obj;

    while (extCpIter.hasNext()) {
        obj = extCpIter.next();
        outList.add(cls.isInstance(obj) ? cls.cast(obj) : null);
    }

    return outList;
}
项目:vertx-guide-for-java-devs_chinese    文件:WikiDatabaseServiceImpl.java   
@Override
public WikiDatabaseService fetchAllPages(Handler<AsyncResult<JsonArray>> resultHandler) {
  dbClient.rxQuery(sqlQueries.get(SqlQuery.ALL_PAGES))
    .flatMapObservable(res -> {
      List<JsonArray> results = res.getResults();
      return Observable.from(results);
    })
    .map(json -> json.getString(0))
    .sorted()
    .collect(JsonArray::new, JsonArray::add)
    .subscribe(RxHelper.toSubscriber(resultHandler));
  return this;
}
项目:redpipe    文件:ApiResource.java   
@RequiresPermissions("delete")
@DELETE
@Path("pages/{id}")
public Single<Response> apiDeletePage(@PathParam("id") String id){
    return SQLUtil.doInConnection(connection -> connection.rxUpdateWithParams(SQL.SQL_DELETE_PAGE, new JsonArray().add(id)))
            .map(res -> Response.ok(new JsonObject().put("success", true)).build());
}
项目:vertx-guide-for-java-devs    文件:WikiDatabaseVerticle.java   
private void deletePage(Message<JsonObject> message) {
  JsonArray data = new JsonArray().add(message.body().getString("id"));

  dbClient.updateWithParams(sqlQueries.get(SqlQuery.DELETE_PAGE), data, res -> {
    if (res.succeeded()) {
      message.reply("ok");
    } else {
      reportQueryError(message, res.cause());
    }
  });
}
项目:vertx-forge    文件:VersionResource.java   
public void findAll(RoutingContext rc) {
    log.debug("REST request to get all Versions");
    eventBus.send("version.query", new JsonObject(), ar -> {
        if (ar.succeeded()) {
            respondJson(rc, (JsonArray) ar.result().body());
        } else {
            error(rc, ar.cause());
        }
    });
}
项目:xbrowser    文件:TableView.java   
public JsonArray getValue() throws InterruptedException,ExecutionException{
    if (Platform.isFxApplicationThread()) {
        return getValueBase();
    }else{
        final FutureTask<JsonArray> task = new FutureTask<>(this::getValueBase);
        Platform.runLater(task);
        return task.get();
    }
}
项目:moviediary    文件:DatabaseServiceImpl.java   
@Override
public Future<JsonObject> getWeekdaysDistribution(String username, String jsonParam) {
    JsonObject json = new JsonObject(jsonParam);
    json.put("start", formToDBDate(json.getString("start"), false));
    json.put("end", formToDBDate(json.getString("end"), true));
    StringBuilder sb = new StringBuilder(SQL_GET_WEEKDAYS_DIST);
    ifTrue(json.getBoolean("is-first"), () -> sb.append(" AND WasFirst"));
    ifTrue(json.getBoolean("is-cinema"), () -> sb.append(" AND WasCinema"));
    return query(sb.append(" GROUP BY Day ORDER BY Day").toString(), new JsonArray()
            .add(username)
            .add(json.getString("start"))
            .add(json.getString("end")));
}
项目:vertx-zero    文件:Jackson.java   
private static JsonObject findByKey(final JsonArray source,
                                    final String key,
                                    final Object value) {
    return Fn.getJvm(() -> Observable.fromIterable(source)
            .filter(Objects::nonNull)
            .map(item -> (JsonObject) item)
            .filter(item -> null != item.getValue(key))
            .filter(item -> value == item.getValue(key) || item.getValue(key).equals(value))
            .first(new JsonObject()).blockingGet(), source, key);
}
项目:moviediary    文件:DatabaseServiceImpl.java   
@Override
public Future<JsonObject> getMonthYearDistribution(String username, String jsonParam) {
    JsonObject json = new JsonObject(jsonParam);
    json.put("start", formToDBDate(json.getString("start"), false));
    json.put("end", formToDBDate(json.getString("end"), true));
    StringBuilder sb = new StringBuilder(SQL_GET_MONTH_YEAR_DIST);
    ifTrue(json.getBoolean("is-first"), () -> sb.append(" AND WasFirst"));
    ifTrue(json.getBoolean("is-cinema"), () -> sb.append(" AND WasCinema"));
    return query(sb.append(" GROUP BY Month, Year ORDER BY Year, Month").toString(), new JsonArray()
            .add(username)
            .add(json.getString("start"))
            .add(json.getString("end")));
}
项目:domino-event-bus    文件:VertxConfigSockJsConfigurator.java   
private SockJSHandler configureSockJsHandler(VertxContext vertxContext, BridgeOptions bridgeOptions,
                                             JsonObject config) {
    SockJSHandler sockJSHandler = SockJSHandler.create(vertxContext.vertx());
    sockJSHandler.bridge(bridgeOptions, event -> event.complete(true));
    JsonArray jsonArray=config.getJsonArray(ALLOWED_ORIGINS, new JsonArray().add("*"));

    sockJSHandler.socketHandler(event -> jsonArray.forEach(o -> event.headers().set(ACCESS_CONTROL_ALLOW_ORIGIN, (String)o)));
    return sockJSHandler;
}