Search in sources :

Example 11 with ArrayNode

use of org.codehaus.jackson.node.ArrayNode in project ovirt-engine by oVirt.

the class WebAdminHostPageServlet method getPluginDefinitionsArray.

protected ArrayNode getPluginDefinitionsArray(List<PluginData> pluginData) {
    ArrayNode arr = createArrayNode();
    for (PluginData data : pluginData) {
        ObjectNode dataObj = createObjectNode();
        // $NON-NLS-1$
        dataObj.put("name", data.getName());
        // $NON-NLS-1$
        dataObj.put("url", data.getUrl());
        // $NON-NLS-1$
        dataObj.put("config", data.mergeConfiguration());
        // $NON-NLS-1$
        dataObj.put("lazyLoad", data.isLazyLoad());
        // $NON-NLS-1$
        dataObj.put("enabled", data.isEnabled());
        arr.add(dataObj);
    }
    return arr;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) PluginData(org.ovirt.engine.ui.frontend.server.gwt.plugin.PluginData) ArrayNode(org.codehaus.jackson.node.ArrayNode)

Example 12 with ArrayNode

use of org.codehaus.jackson.node.ArrayNode in project openmrs-module-coreapps by openmrs.

the class VisitTypeHelper method getVisitTypeColorCodes.

private Map<String, Object> getVisitTypeColorCodes(VisitType visitType) {
    Map<String, Object> colorCode = new HashMap<String, Object>();
    AdministrationService adminService = Context.getAdministrationService();
    String propertyValue = adminService.getGlobalProperty(CoreAppsConstants.VISIT_TYPE_COLORS);
    try {
        if (StringUtils.isNotEmpty(propertyValue)) {
            ArrayNode array = new ObjectMapper().readValue(propertyValue, ArrayNode.class);
            for (JsonNode node : array) {
                String visitTypeUuid = node.path("uuid").getTextValue();
                if (visitType.getUuid().equalsIgnoreCase(visitTypeUuid)) {
                    colorCode.put("uuid", visitTypeUuid);
                    String color = node.path("color").getTextValue();
                    colorCode.put("color", color);
                    String shortName = node.path("shortName").getTextValue();
                    colorCode.put("shortName", shortName);
                }
            }
        }
    } catch (IOException ex) {
        LOG.error("Error retrieving visit type color codes, " + ex);
    }
    return colorCode;
}
Also used : AdministrationService(org.openmrs.api.AdministrationService) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) JsonNode(org.codehaus.jackson.JsonNode) ArrayNode(org.codehaus.jackson.node.ArrayNode) IOException(java.io.IOException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 13 with ArrayNode

use of org.codehaus.jackson.node.ArrayNode in project openmrs-module-mirebalais by PIH.

the class CustomAppLoaderUtil method objectNode.

public static ObjectNode objectNode(Object... obj) {
    ObjectNode objectNode = new ObjectMapper().createObjectNode();
    for (int i = 0; i < obj.length; i = i + 2) {
        String key = (String) obj[i];
        Object value = obj[i + 1];
        if (value instanceof Boolean) {
            objectNode.put(key, (Boolean) value);
        } else if (value instanceof String) {
            objectNode.put(key, (String) value);
        } else if (value instanceof Integer) {
            objectNode.put(key, (Integer) value);
        } else if (value instanceof ArrayNode) {
            objectNode.put(key, (ArrayNode) value);
        } else if (value instanceof ObjectNode) {
            objectNode.put(key, (ObjectNode) value);
        }
    }
    return objectNode;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) ArrayNode(org.codehaus.jackson.node.ArrayNode) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 14 with ArrayNode

use of org.codehaus.jackson.node.ArrayNode in project mongo-hadoop by mongodb.

the class TestStandalone method collectionSettings.

private JsonNode collectionSettings() {
    ArrayNode settings = new ArrayNode(JsonNodeFactory.instance);
    ObjectNode node = new ObjectNode(JsonNodeFactory.instance);
    node.put(INPUT_URI, getInputUri().toString());
    ObjectNode dow = new ObjectNode(JsonNodeFactory.instance);
    dow.put("dayOfWeek", "FRIDAY");
    node.put("query", dow);
    node.put(MONGO_SPLITTER_CLASS, SingleMongoSplitter.class.getName());
    node.put(SPLITS_USE_RANGEQUERY, true);
    node.put(INPUT_NOTIMEOUT, true);
    settings.add(node);
    MongoClientURI inputUri3 = authCheck(new MongoClientURIBuilder().collection("mongo_hadoop", "yield_historical.in3")).build();
    node = new ObjectNode(JsonNodeFactory.instance);
    node.put(INPUT_URI, inputUri3.toString());
    node.put(SPLITS_USE_RANGEQUERY, true);
    node.put(INPUT_NOTIMEOUT, true);
    settings.add(node);
    return settings;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) MongoClientURIBuilder(com.mongodb.hadoop.util.MongoClientURIBuilder) SingleMongoSplitter(com.mongodb.hadoop.splitter.SingleMongoSplitter) MongoClientURI(com.mongodb.MongoClientURI) ArrayNode(org.codehaus.jackson.node.ArrayNode)

Example 15 with ArrayNode

use of org.codehaus.jackson.node.ArrayNode in project stanbol by apache.

the class PosTagSupport method serialize.

@Override
public ObjectNode serialize(ObjectMapper mapper, PosTag value) {
    ObjectNode jPosTag = mapper.createObjectNode();
    jPosTag.put("tag", value.getTag());
    if (value.getPos().size() == 1) {
        jPosTag.put("pos", value.getPos().iterator().next().ordinal());
    } else if (!value.getPos().isEmpty()) {
        ArrayNode jPos = mapper.createArrayNode();
        for (Pos pos : value.getPos()) {
            jPos.add(pos.ordinal());
        }
        jPosTag.put("pos", jPos);
    }
    if (!value.getCategories().isEmpty()) {
        // we need only the categories not covered by Pos elements
        EnumSet<LexicalCategory> categories = EnumSet.noneOf(LexicalCategory.class);
        categories.addAll(value.getCategories());
        for (Pos pos : value.getPos()) {
            categories.removeAll(pos.categories());
        }
        if (categories.size() == 1) {
            jPosTag.put("lc", categories.iterator().next().ordinal());
        } else if (!categories.isEmpty()) {
            ArrayNode jCategory = mapper.createArrayNode();
            for (LexicalCategory lc : categories) {
                jCategory.add(lc.ordinal());
            }
            jPosTag.put("lc", jCategory);
        }
    }
    return jPosTag;
}
Also used : ObjectNode(org.codehaus.jackson.node.ObjectNode) Pos(org.apache.stanbol.enhancer.nlp.pos.Pos) ArrayNode(org.codehaus.jackson.node.ArrayNode) LexicalCategory(org.apache.stanbol.enhancer.nlp.pos.LexicalCategory)

Aggregations

ArrayNode (org.codehaus.jackson.node.ArrayNode)44 ObjectNode (org.codehaus.jackson.node.ObjectNode)29 JsonNode (org.codehaus.jackson.JsonNode)17 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)11 GET (javax.ws.rs.GET)10 Test (org.junit.Test)10 Path (javax.ws.rs.Path)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Date (java.util.Date)4 List (java.util.List)4 HelixDataAccessor (org.apache.helix.HelixDataAccessor)4 Produces (javax.ws.rs.Produces)3 RegressionTestHelper (org.openmrs.module.htmlformentry.RegressionTestHelper)3 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2