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:controllers.api.v1.Dataset.java

public static Result renameLogicalDatasetFile(Long datasetId) {
    ObjectNode result = Json.newObject();
    // String username = session("user");
    Map<String, String[]> params = request().body().asFormUrlEncoded();
    //if (StringUtils.isNotBlank(username)) {
    String errorMsg = DatasetsDAO.renameLogicalDatasetFile(datasetId, params);
    if (StringUtils.isBlank(errorMsg)) {
        result.put("status", "success");
    } else {/* w  ww  .  ja v  a  2 s . c  o  m*/
        result.put("status", "failed");
        result.put("msg", errorMsg);
    }
    /*} else {
    result.put("status", "failed");
    result.put("msg", "Authentication Required");
    }*/
    return ok(result);
}

From source file:com.clicktravel.infrastructure.persistence.aws.cloudsearch.client.JsonDocumentUpdateMarshaller.java

private ObjectNode createJsonNode(final DocumentUpdate document) throws IOException {
    final ObjectNode documentUpdateNode = mapper.createObjectNode();
    documentUpdateNode.put("id", document.getId());
    documentUpdateNode.put("type", document.getType().name().toLowerCase());
    final ObjectNode fields = mapper.createObjectNode();
    for (final Field field : document.getFields()) {
        if (field.getValue() != null) {
            final String fieldValueStr = mapper.writeValueAsString(field.getValue());
            final JsonNode fieldValueJsonNode = mapper.readTree(fieldValueStr);
            fields.put(field.getName().toLowerCase(), fieldValueJsonNode);
        }//from   w  w  w  . j  av a 2 s .c  o  m
    }
    if (fields.size() > 0) {
        documentUpdateNode.put("fields", fields);
    }
    return documentUpdateNode;
}

From source file:eu.europa.ec.fisheries.uvms.rest.FeatureToGeoJsonJacksonMapper.java

@SuppressWarnings("unchecked")
private ObjectNode buildFeatureCollection(FeatureCollection featureCollection) throws IOException {
    List<ObjectNode> features = new LinkedList<>();
    FeatureIterator simpleFeatureIterator = featureCollection.features();
    while (simpleFeatureIterator.hasNext()) {
        Feature simpleFeature = simpleFeatureIterator.next();
        features.add(buildFeature((SimpleFeature) simpleFeature));
    }//from  w  ww .ja  v  a 2 s.  c o m

    ObjectNode obj = mapper.createObjectNode();
    obj.put(TYPE, FEATURE_COLLECTION);
    obj.putArray(FEATURES).addAll(features);
    return obj;
}

From source file:org.apache.taverna.gis.GisActivityTest.java

@Test(expected = ActivityConfigurationException.class)
public void invalidConfiguration() throws ActivityConfigurationException {
    ObjectNode invalidBean = JsonNodeFactory.instance.objectNode();
    invalidBean.put("exampleString", "invalidExample");
    // Should throw ActivityConfigurationException
    activity.configure(invalidBean);//from  ww  w. ja v a2  s .  c o  m
}

From source file:org.jongo.NonPojoTest.java

@Test
public void canSaveANewJsonNode() throws Exception {
    JsonNodeFactory factory = new JsonNodeFactory(false);
    ObjectNode node = factory.objectNode();
    node.put("test", "value");

    collection.save(node);//ww  w.  java  2s.  com

    JsonNode result = collection.findOne().as(JsonNode.class);
    assertThat(result.get("_id")).isNotNull();
    assertThat(result.get("test").asText()).isEqualTo("value");
}

From source file:org.lendingclub.mercator.aws.SQSScanner.java

private void scanQueue(String url) {
    rateLimit();/*from w  ww.  j  ava 2 s  .c o  m*/
    GetQueueAttributesResult result = getClient().getQueueAttributes(url, Lists.newArrayList("All"));

    ObjectNode n = convertAwsObject(result.getAttributes(), getRegion());
    n.put("url", url);

    mergeQueue(n);
}

From source file:org.numenta.nupic.algorithms.Statistic.java

/**
 * Creates and returns a JSON ObjectNode containing this Statistic's data.
 * /*from   w  w  w  . j  av  a2s . c  o m*/
 * @param factory
 * @return
 */
public ObjectNode toJson(JsonNodeFactory factory) {
    ObjectNode distribution = factory.objectNode();
    distribution.put("mean", mean);
    distribution.put("variance", variance);
    distribution.put("stdev", stdev);

    return distribution;
}

From source file:net.sf.taverna.t2.activities.spreadsheet.servicedescriptions.SpreadsheetImportTemplateService.java

@Override
public Configuration getActivityConfiguration() {
    Configuration configuration = new Configuration();
    configuration.setType(ACTIVITY_TYPE.resolve("#Config"));
    ObjectNode json = (ObjectNode) configuration.getJson();
    json.put("columnRange", json.objectNode().put("start", 0).put("end", 1));
    json.put("rowRange", json.objectNode().put("start", 0).put("end", -1));
    json.put("emptyCellValue", "");
    json.put("allRows", true);
    json.put("excludeFirstRow", false);
    json.put("ignoreBlankRows", false);
    json.put("emptyCellPolicy", "EMPTY_STRING");
    json.put("outputFormat", "PORT_PER_COLUMN");
    json.put("csvDelimiter", ",");
    return configuration;
}

From source file:org.envirocar.server.rest.encoding.json.PhenomenonJSONEncoder.java

@Override
public ObjectNode encodeJSON(Phenomenon t, AccessRights rights, MediaType mediaType) {
    ObjectNode phenomenon = getJsonFactory().objectNode();
    if (t.hasName()) {
        phenomenon.put(JSONConstants.NAME_KEY, t.getName());
    }/* w  ww  .j a  va  2 s  . c om*/
    if (t.hasUnit()) {
        phenomenon.put(JSONConstants.UNIT_KEY, t.getUnit());
    }
    if (mediaType.equals(MediaTypes.PHENOMENON_TYPE)) {
        if (t.hasCreationTime()) {
            phenomenon.put(JSONConstants.CREATED_KEY, getDateTimeFormat().print(t.getCreationTime()));
        }
        if (t.hasModificationTime()) {
            phenomenon.put(JSONConstants.MODIFIED_KEY, getDateTimeFormat().print(t.getModificationTime()));
        }
    }
    return phenomenon;
}

From source file:org.trustedanalytics.h2oscoringengine.publisher.steps.RegisteringInApplicationBrokerStep.java

private String prepareAppBrokerJsonRequest(String serviceName, String serviceDescription) {
    String planId = UUID.randomUUID().toString();
    String serviceId = UUID.randomUUID().toString();

    ObjectMapper mapper = new ObjectMapper();

    ArrayNode plansArray = mapper.createArrayNode();
    ObjectNode planNode = mapper.createObjectNode();
    planNode.put("id", planId);
    plansArray.add(planNode);/*ww w  . j a  v  a2s . co  m*/

    ObjectNode guidNode = mapper.createObjectNode();
    guidNode.put("guid", appGuid);

    ObjectNode metadataNode = mapper.createObjectNode();
    metadataNode.set("metadata", guidNode);

    ObjectNode json = mapper.createObjectNode();
    json.set("app", metadataNode);
    json.put("id", serviceId);
    json.set("plans", plansArray);
    json.put("description", serviceDescription);
    json.put("name", serviceName);

    return json.toString();
}