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.engagingspaces.graphql.marshaller.schema.decorators.GraphQLSchemaDO.java

License:Open Source License

private void marshallScalarTypes(JsonObject schemaJson) {
    if (!context.getScalarTypes().isEmpty()) {
        JsonObject scalars = new JsonObjectHelper();
        context.getScalarTypes().entrySet()
                .forEach(entry -> scalars.put(entry.getKey(), context.marshall(entry.getValue())));
        schemaJson.put(SCALAR_TYPES, scalars);
    }/*  www  . j  a v a  2  s.  c o m*/
}

From source file:io.engagingspaces.graphql.marshaller.schema.decorators.GraphQLSchemaDO.java

License:Open Source License

private JsonObject marshallSchemaEntry(JsonObject schemaJson) {
    return schemaJson.put(SCHEMAS, new JsonObject().put(jsonReference.getTargetKey(), toJson(true)));
}

From source file:io.engagingspaces.graphql.query.QueryableVertxEBProxy.java

License:Apache License

public void query(String graphqlQuery, Handler<AsyncResult<QueryResult>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from   w w  w  .  ja v a2s  . c om*/
    }
    JsonObject _json = new JsonObject();
    _json.put("graphqlQuery", graphqlQuery);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "query");
    _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() == null ? null : new QueryResult(res.result().body())));
        }
    });
}

From source file:io.engagingspaces.graphql.query.QueryableVertxEBProxy.java

License:Apache License

public void queryWithVariables(String graphqlQuery, JsonObject variables,
        Handler<AsyncResult<QueryResult>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from   ww w .  ja v  a 2 s.c om*/
    }
    JsonObject _json = new JsonObject();
    _json.put("graphqlQuery", graphqlQuery);
    _json.put("variables", variables);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "queryWithVariables");
    _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() == null ? null : new QueryResult(res.result().body())));
        }
    });
}

From source file:io.engagingspaces.graphql.query.QueryableVertxEBProxy.java

License:Apache License

public void resolveType(String typeResolverId, JsonObject typeHolder,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*w  ww .j a  v  a 2 s .  c  om*/
    }
    JsonObject _json = new JsonObject();
    _json.put("typeResolverId", typeResolverId);
    _json.put("typeHolder", typeHolder);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "resolveType");
    _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:io.engagingspaces.graphql.query.QueryableVertxEBProxy.java

License:Apache License

public void fetchData(String dataFetcherId, JsonObject dataFetchingEnvironment,
        Handler<AsyncResult<JsonObject>> resultHandler) {
    if (closed) {
        resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
        return;/*from www . j a  v  a2s .c  o m*/
    }
    JsonObject _json = new JsonObject();
    _json.put("dataFetcherId", dataFetcherId);
    _json.put("dataFetchingEnvironment", dataFetchingEnvironment);
    DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options)
            : new DeliveryOptions();
    _deliveryOptions.addHeader("action", "fetchData");
    _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:io.engagingspaces.graphql.schema.SchemaDefinition.java

License:Open Source License

/**
 * Creates schema metadata for the GraphQL schema proxy being created using the provided marshaled proxy json.
 *
 * @param proxyJson the marshaled schema json that is used by the client proxy
 * @param metadata  additional metadata to pass to the service
 * @return the schema metadata data object
 *///from  www .  j a va 2  s.co  m
default SchemaMetadata createServiceMetadata(JsonObject proxyJson, JsonObject metadata) {
    if (options().getSchemaName() == null) {
        options().setSchemaName(schema().getQueryType().getName());
    }
    metadata.put(SchemaMetadata.METADATA_QUERIES, schema().getQueryType().getFieldDefinitions().stream()
            .map(GraphQLFieldDefinition::getName).collect(Collectors.toList()));
    metadata.put(SchemaMetadata.METADATA_MUTATIONS,
            !schema().isSupportingMutations() ? Collections.emptyList()
                    : schema().getMutationType().getFieldDefinitions().stream()
                            .map(GraphQLFieldDefinition::getName).collect(Collectors.toList()));

    return SchemaMetadata.create(proxyJson, metadata, this.options());
}

From source file:io.fabric8.devops.apps.bughunter.model.AppInfoConverter.java

License:Apache License

public static void toJson(AppInfo obj, JsonObject json) {
    if (obj.getBranch() != null) {
        json.put("branch", obj.getBranch());
    }/*from ww w. j  a va  2  s  .c o m*/
    if (obj.getGroup() != null) {
        json.put("group", obj.getGroup());
    }
    if (obj.getIssueTrackerUrl() != null) {
        json.put("issueTrackerUrl", obj.getIssueTrackerUrl());
    }
    if (obj.getProject() != null) {
        json.put("project", obj.getProject());
    }
    if (obj.getProjectUrl() != null) {
        json.put("projectUrl", obj.getProjectUrl());
    }
    if (obj.getRevision() != null) {
        json.put("revision", obj.getRevision());
    }
    if (obj.getVersion() != null) {
        json.put("version", obj.getVersion());
    }
}

From source file:io.fabric8.devops.apps.bughunter.model.BugInfoConverter.java

License:Apache License

public static void toJson(BugInfo obj, JsonObject json) {
    if (obj.getApp() != null) {
        json.put("app", obj.getApp().toJson());
    }/*from  ww  w . j  a  va 2s . co  m*/
    json.put("count", obj.getCount());
    if (obj.getId() != null) {
        json.put("id", obj.getId());
    }
    if (obj.getLogMessage() != null) {
        json.put("logMessage", obj.getLogMessage());
    }
    if (obj.getPod() != null) {
        json.put("pod", obj.getPod().toJson());
    }
    json.put("score", obj.getScore());
    if (obj.getTimestamp() != null) {
        json.put("timestamp", obj.getTimestamp());
    }
}

From source file:io.fabric8.devops.apps.bughunter.model.PodInfoConverter.java

License:Apache License

public static void toJson(PodInfo obj, JsonObject json) {
    if (obj.getContainerName() != null) {
        json.put("containerName", obj.getContainerName());
    }/*  w w  w.  j a v a 2 s.c  o  m*/
    if (obj.getHost() != null) {
        json.put("host", obj.getHost());
    }
    if (obj.getNamespace() != null) {
        json.put("namespace", obj.getNamespace());
    }
    if (obj.getPodId() != null) {
        json.put("podId", obj.getPodId());
    }
    if (obj.getPodName() != null) {
        json.put("podName", obj.getPodName());
    }
}