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

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

Introduction

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

Prototype

public JsonNode get(String paramString) 

Source Link

Usage

From source file:org.apache.taverna.scufl2.translator.t2flow.TestInteractionActivityParser.java

@Test
public void parseMultipleChoice() throws Exception {
    WorkflowBundle researchObj = parseWorkflow(WF_MULTIPLE_CHOICE);

    NamedSet<Profile> profiles = researchObj.getProfiles();
    Profile profile = profiles.getByName("taverna-biodiversity-2.5.0");
    assertNotNull("Could not find profile", profile);

    Processor interaction = researchObj.getMainWorkflow().getProcessors().getByName("Interaction");
    assertNotNull("Could not find processor Interaction", interaction);

    Configuration interactionConfig = scufl2Tools.configurationForActivityBoundToProcessor(interaction,
            profile);/*from w w  w.j av  a 2  s . co  m*/

    Activity interactionAct = (Activity) interactionConfig.getConfigures();
    assertEquals(ACTIVITY_URI, interactionAct.getType());

    ObjectNode interactionResource = interactionConfig.getJsonAsObjectNode();
    assertEquals(ACTIVITY_URI.resolve("#Config"), interactionConfig.getType());

    String presentationOrigin = interactionResource.get("presentationOrigin").textValue();
    assertEquals("http://build.mygrid.org.uk/taverna/internal/biovel/multiple_selection.html",
            presentationOrigin);

    String interactionActivityType = interactionResource.get("interactionActivityType").textValue();
    assertEquals("LocallyPresentedHtml", interactionActivityType);

    boolean progressNotification = interactionResource.get("progressNotification").booleanValue();
    assertFalse(progressNotification);
}

From source file:io.macgyver.neorx.rest.NeoRxClientTest.java

@Test
public void testListParam() {
    NeoRxClient c = new NeoRxClient();

    ObjectNode n = c.createParameters("abc", Lists.newArrayList("x"));

    assertThat(n.get("abc").get(0).asText()).isEqualTo("x");
    assertThat(n.get("abc").isArray()).isTrue();
}

From source file:com.almende.eve.scheduling.SimpleScheduler.java

/**
 * Instantiates a new abstract scheduler.
 * //from w ww .ja  va2s .co m
 * @param params
 *            the params
 * @param handle
 *            the handle
 */
public SimpleScheduler(final ObjectNode params, final Handler<Receiver> handle) {
    if (params.has("senderUrl")) {
        try {
            schedulerUrl = URIUtil.parse(params.get("senderUrl").asText());
        } catch (final URISyntaxException e) {
            LOG.log(Level.WARNING, "Couldn't parse scheduler senderUrl from parameters.", e);
        }
    }
    if (schedulerUrl == null) {
        schedulerUrl = URIUtil.create("local:unnamed_scheduler");
    }
    this.handle = handle;
    myParams = params;
}

From source file:com.almende.eve.transport.http.embed.JettyLauncher.java

@Override
public void add(final ServerEndpointConfig serverConfig, final ObjectNode config) throws ServletException {
    // TODO: config hierarchy...
    if (server == null) {
        if (config != null) {
            initServer((ObjectNode) config.get("jetty"));
        } else {/*from www. ja  va 2s .  c  o  m*/
            initServer(JOM.createObjectNode());
        }
    }
    LOG.info("Registering websocket server endpoint:" + serverConfig.getPath());
    try {
        wscontainer.addEndpoint(serverConfig);
    } catch (final DeploymentException e) {
        LOG.log(Level.WARNING, "Couldn't initialize websocket server endpoint.", e);
    }
}

From source file:com.google.api.server.spi.EndpointsServletTest.java

@Test
public void echo() throws IOException {
    req.setRequestURI("/_ah/api/test/v2/echo");
    req.setMethod("POST");
    req.setParameter("x", "1");

    servlet.service(req, resp);// w w  w  .ja v  a 2  s .  c o m

    assertThat(resp.getStatus()).isEqualTo(HttpServletResponse.SC_OK);
    ObjectMapper mapper = ObjectMapperUtil.createStandardObjectMapper();
    ObjectNode actual = mapper.readValue(resp.getContentAsString(), ObjectNode.class);
    assertThat(actual.size()).isEqualTo(1);
    assertThat(actual.get("x").asInt()).isEqualTo(1);
}

From source file:org.gitana.platform.client.document.DocumentImpl.java

@Override
public void reload(ObjectNode source) {
    boolean merge = true;
    if (source.has(Document.FIELD_ID)) {
        if (source.get(Document.FIELD_ID).textValue().equals(getId())) {
            merge = false;//from www.ja  v  a 2s  .  c om
        }
    }

    ObjectNode replacement = null;
    if (merge) {
        // create a copy of our properties
        ObjectNode original = JsonUtil.copyObject(getObject());

        // create a copy of the incoming object
        ObjectNode incoming = JsonUtil.copyObject(source);

        // merge properties
        replacement = mergeProperties(original, incoming);
    } else {
        replacement = JsonUtil.copyObject(source);
    }

    // if the replacement doesn't have "_system", copy from original
    if (!replacement.has(Document.SYSTEM)) {
        mergePropertyIfExists(this.getObject(), replacement, Document.SYSTEM);
    }

    // only hard condition - make sure _id copies over
    if (this.has("_id")) {
        replacement.put("_id", this.getString("_id"));
    }

    // clear our own object and push new properties
    this.getObject().removeAll();
    this.getObject().putAll(replacement);
}

From source file:com.google.api.server.spi.EndpointsServletTest.java

@Test
public void methodOverride() throws IOException {
    req.setRequestURI("/_ah/api/test/v2/increment");
    req.setMethod("POST");
    req.addHeader("X-HTTP-Method-Override", "PATCH");
    req.setParameter("x", "1");

    servlet.service(req, resp);/*from w ww.jav a  2 s  .  c o m*/

    assertThat(resp.getStatus()).isEqualTo(HttpServletResponse.SC_OK);
    ObjectMapper mapper = ObjectMapperUtil.createStandardObjectMapper();
    ObjectNode actual = mapper.readValue(resp.getContentAsString(), ObjectNode.class);
    assertThat(actual.size()).isEqualTo(1);
    assertThat(actual.get("x").asInt()).isEqualTo(2);
}

From source file:com.almende.eve.transport.http.embed.JettyLauncher.java

@Override
public void add(final Servlet servlet, final URI servletPath, final ObjectNode config) throws ServletException {
    // TODO: config hierarchy...
    if (server == null) {
        if (config != null) {
            initServer((ObjectNode) config.get("jetty"));
        } else {/*from www .  j  av  a2  s . c  om*/
            initServer(JOM.createObjectNode());
        }
    }
    LOG.info("Registering servlet:" + servletPath.getPath());
    ServletHolder sh = new ServletHolder(servlet);

    if (config.has("initParams")) {
        ArrayNode params = (ArrayNode) config.get("initParams");
        for (JsonNode param : params) {
            LOG.warning("Setting init param:" + param.toString());
            sh.setInitParameter(param.get("key").asText(), param.get("value").asText());
        }

    }

    context.addServlet(sh, servletPath.getPath() + "*");
}

From source file:org.gitana.platform.client.beans.TraversalResults.java

public void parse(ObjectFactory factory, Branch branch, Response response) {
    // NODES//from w  ww . j a  v  a  2 s .  c om
    ObjectNode nodes = (ObjectNode) response.getObjectNode().get("nodes");
    Iterator<String> it1 = nodes.fieldNames();
    while (it1.hasNext()) {
        String fieldName = it1.next();

        ObjectNode obj = (ObjectNode) nodes.get(fieldName);

        Node node = (Node) factory.produce(branch, obj, true);
        this.nodes.put(node.getId(), node);
    }

    // ASSOCIATIONS
    ObjectNode associations = (ObjectNode) response.getObjectNode().get("associations");
    Iterator<String> it2 = associations.fieldNames();
    while (it2.hasNext()) {
        String fieldName = it2.next();

        ObjectNode obj = (ObjectNode) associations.get(fieldName);

        Association association = (Association) factory.produce(branch, obj, true);
        this.associations.put(association.getId(), association);
    }
}

From source file:eu.bittrade.libs.steemj.communication.jrpc.JsonRPCResponse.java

/**
 * Check if the given <code>response</code> has the expected <code> id.
 * /*from  w  w  w  .ja va  2  s .  co  m*/
 * &#64;param id The request id to compare with.
 * &#64;param response The JSON returned from the node.
 * @return <code>true</code> if the <code>response</code> contains the
 *         <code>id</code> or <code>false</code> if not.
 */
private boolean hasExpectedId(long id, ObjectNode response) {
    return response.has(ID_FIELD_NAME) && response.get(ID_FIELD_NAME) != null
            && response.get(ID_FIELD_NAME).asLong() == id;
}