Example usage for com.fasterxml.jackson.databind.node ObjectNode put

List of usage examples for com.fasterxml.jackson.databind.node ObjectNode put

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind.node ObjectNode put.

Prototype

public ObjectNode put(String paramString1, String paramString2) 

Source Link

Usage

From source file:org.flowable.admin.service.engine.EventSubscriptionService.java

public void triggerSignalEvent(ServerConfig serverConfig, String eventName) {
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    node.put("action", "signalEventReceived");
    node.put("signalName", eventName);

    HttpPut put = clientUtil.createPut("runtime/executions", serverConfig);
    put.setEntity(clientUtil.createStringEntity(node));

    clientUtil.executeRequest(put, serverConfig);
}

From source file:com.almende.eve.test.TestHttp.java

/**
 * Test http./*from www. ja v  a2  s  .  c  o m*/
 * 
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
@Test
public void testHttp() throws IOException {
    final HttpTransportConfig config = new HttpTransportConfig();
    config.setServletUrl("http://localhost:8080/agents/");
    config.setId("testAgent");

    config.setServletLauncher("JettyLauncher");
    final ObjectNode jettyParms = JOM.createObjectNode();
    jettyParms.put("port", 8080);
    config.set("jetty", jettyParms);

    final Transport transport = new TransportBuilder().withConfig(config).withHandle(new myReceiver()).build();

    transport.send(URIUtil.create("http://localhost:8080/agents/testAgent"), "Hello World", null);
}

From source file:org.apache.taverna.gis.ui.serviceprovider.GisServiceDesc.java

@Override
public Configuration getActivityConfiguration() {
    Configuration configuration = new Configuration();
    configuration.setType(ACTIVITY_TYPE.resolve("#Config"));
    ObjectNode json = configuration.getJsonAsObjectNode();
    json.put("ogcServiceUri", ogcServiceUri.toASCIIString());
    json.put("processIdentifier", processIdentifier);
    return configuration;
}

From source file:org.ow2.chameleon.everest.impl.TestParameterToBeanSupport.java

@Test
public void testBeaninificationWithNestedBean() {
    ObjectNode nested = objectMapper.createObjectNode().put("message", "a message").put("count", 1);
    nested.putArray("names").add("a").add("b").add("c");

    ObjectNode node = objectMapper.createObjectNode().put("name", "clement").put("id", 1);
    node.put("bean", nested);

    System.out.println(node.toString());

    DefaultRequest request = new DefaultRequest(Action.READ, Path.from("/foo"),
            new ImmutableMap.Builder<String, String>().put("test", node.toString()).build());

    AnotherBean bean = request.get("test", AnotherBean.class);
    assertThat(bean.getId()).isEqualTo(1);
    assertThat(bean.getName()).isEqualTo("clement");
    assertThat(bean.getBean().getCount()).isEqualTo(1);
    assertThat(bean.getBean().getMessage()).isEqualTo("a message");
    assertThat(bean.getBean().getNames()).contains("a").contains("b").contains("c");

}

From source file:org.flowable.admin.service.engine.EventSubscriptionService.java

public void triggerMessageEvent(ServerConfig serverConfig, String eventName, String tenantId) {
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    node.put("message", eventName);
    if (tenantId != null && tenantId.length() > 0) {
        node.put("tenantId", tenantId);
    }//from  w w w.  j a v  a 2  s. co  m

    HttpPost post = clientUtil.createPost("runtime/process-instances", serverConfig);
    post.setEntity(clientUtil.createStringEntity(node));

    clientUtil.executeRequest(post, serverConfig);
}

From source file:com.digitalpebble.storm.crawler.filtering.HostURLFilterTest.java

private HostURLFilter createFilter(boolean ignoreOutsideHost, boolean ignoreOutsideDomain) {
    HostURLFilter filter = new HostURLFilter();
    ObjectNode filterParams = new ObjectNode(JsonNodeFactory.instance);
    filterParams.put("ignoreOutsideHost", Boolean.valueOf(ignoreOutsideHost));
    filterParams.put("ignoreOutsideDomain", Boolean.valueOf(ignoreOutsideDomain));
    Map<String, Object> conf = new HashMap<String, Object>();
    filter.configure(conf, filterParams);
    return filter;
}

From source file:com.ikanow.aleph2.storm.samples.bolts.SampleKafkaOutputBolt.java

private JsonNode createJsonNode(String keyA, String keyB, String message)
        throws JsonProcessingException, IOException {
    ObjectNode objNode = (ObjectNode) new ObjectMapper().readTree(message);
    objNode.put("modifiedKeyA", keyA);
    objNode.put("modifiedKeyB", keyB);
    return objNode;
}

From source file:org.opendaylight.sfc.sbrest.json.SfgExporterFactory.java

@Override
public String exportJsonNameOnly(DataObject dataObject) {

    String ret = null;/*  w  w w . j  a v  a 2 s  .c  o m*/
    if (dataObject instanceof ServiceFunctionGroup) {
        ServiceFunctionGroup obj = (ServiceFunctionGroup) dataObject;

        ObjectNode node = mapper.createObjectNode();
        node.put(_NAME, obj.getName());
        ArrayNode sfArray = mapper.createArrayNode();
        sfArray.add(node);
        ret = "{\"" + _SERVICE_FUNCTION_GROUP + "\":" + sfArray.toString() + "}";
    } else {
        throw new IllegalArgumentException("Argument is not an instance of ServiceFunction");
    }

    return ret;
}

From source file:com.almende.eve.algorithms.test.TestGraph.java

/**
 * Write visGraph./*from  ww w .  ja v  a  2  s.co  m*/
 *
 * @param agents
 *            the agents
 * @return the string
 */
private String writeVisGraph(List<NodeAgent> agents) {
    final ObjectNode result = JOM.createObjectNode();
    final ArrayNode nodes = JOM.createArrayNode();
    final ArrayNode edges = JOM.createArrayNode();

    for (NodeAgent agent : agents) {
        final ObjectNode node = JOM.createObjectNode();
        node.put("id", agent.getId());
        node.put("label", agent.getId());
        nodes.add(node);
        for (Edge edge : agent.getGraph().getEdges()) {
            final ObjectNode edgeNode = JOM.createObjectNode();
            edgeNode.put("from", agent.getId());
            edgeNode.put("to", edge.getAddress().toASCIIString().replace("local:", ""));
            edges.add(edgeNode);
        }
    }

    result.set("nodes", nodes);
    result.set("edges", edges);
    return result.toString();
}

From source file:com.redhat.lightblue.Request.java

/**
 * Returns a JSON representation of this
 *///from   w w w  .  ja va 2 s.  co  m
@Override
public JsonNode toJson() {
    ObjectNode node = getFactory().objectNode();
    node.put("entity", entityVersion.getEntity());
    node.put("entityVersion", entityVersion.getVersion());
    if (client != null) {
        node.set("client", client.toJson());
    }
    if (execution != null) {
        node.set("execution", execution.toJson());
    }
    return node;
}