Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JsonNode


    public AbsoluteRange getHistogramBoundaries() {
        if (boundaries == null) {
            try {
                ObjectMapper mapper = new ObjectMapper();
                JsonParser jp = mapper.getFactory().createParser(getBuiltQuery());
                JsonNode rootNode = mapper.readTree(jp);
                JsonNode timestampNode = rootNode.findValue("range").findValue("timestamp");
                String from = Tools.elasticSearchTimeFormatToISO8601(timestampNode.findValue("from").asText());
                String to = Tools.elasticSearchTimeFormatToISO8601(timestampNode.findValue("to").asText());
                boundaries = new AbsoluteRange(from, to);
            } catch (Exception ignored) {}
        }

        return boundaries;
View Full Code Here


    }

    private Map<String, Map<String,Object>> parseGauges(String json) throws IOException {
        Map<String, Map<String,Object>> result = Maps.newHashMap();

        JsonNode userData = objectMapper.readTree(json);
        JsonNode gauges = userData.get("gauges");

        for (JsonNode node : gauges) {
            Map<String, Object> gauge = Maps.newHashMap();
            gauge.put("source", node.get("source").asText());
            gauge.put("name", node.get("name").asText());
View Full Code Here

                        try {
                            // Try the HTTP API endpoint
                            final ListenableFuture<Response> future = httpClient.prepareGet("http://" + hostAndPort.getHostText() + ":9200/_nodes").execute();
                            final Response response = future.get();

                            final JsonNode resultTree = new ObjectMapper().readTree(response.getResponseBody());
                            final String clusterName = resultTree.get("cluster_name").textValue();
                            final JsonNode nodesList = resultTree.get("nodes");

                            final Iterator<String> nodes = nodesList.fieldNames();
                            while (nodes.hasNext()) {
                                final String id = nodes.next();
                                final Version clusterVersion = Version.fromString(nodesList.get(id).get("version").textValue());

                                if (!configuration.isEsDisableVersionCheck()) {
                                    checkClusterVersion(clusterVersion);
                                }
                            }
View Full Code Here

            String output;
            while ((output = reader.readLine()) != null) {
                contentString.append(output);
            }

            JsonNode node = Json.parse(contentString.toString());
            Item item = new Item();

            if (node.size() > 0) {
                item = Item.parseItemFromJSON(node);
            }

            String endpoint = conn.getURL().toString();
            User user = new User();
View Full Code Here

            String output;
            while ((output = reader.readLine()) != null) {
                contentString.append(output);
            }

            JsonNode jsonNode = Json.parse(contentString.toString());

            List<Community> communities = new ArrayList<Community>();

            if(jsonNode.size()>0) {
                for(JsonNode comm : jsonNode) {
                    Community community = Community.parseCommunityFromJSON(comm);
                    communities.add(community);
                }
            }
View Full Code Here

        request.setHeader("Accept", "application/json");
        request.addHeader("Content-Type", "application/json");
        request.addHeader("rest-dspace-token", token);
        HttpResponse httpResponse = httpClient.execute(request);

        JsonNode collNode = Json.parse(httpResponse.getEntity().getContent());

        Collection collection = new Collection();

        if (collNode.size() > 0) {
            collection = Collection.parseCollectionFromJSON(collNode);
        }

        restResponse.httpResponse = httpResponse;
        restResponse.endpoint = request.getURI().toString();
View Full Code Here

        if(collectionJSON.has("numberItems")) {
            collection.countItems = collectionJSON.get("numberItems").asInt();
        }

        if(collectionJSON.has("logo")) {
            JsonNode logoNode = collectionJSON.get("logo");
            if(!logoNode.isNull()) {
                collection.logo = Bitstream.parseBitstreamFromJSON(logoNode);
            }
        }

        //@TODO Is it comm.introductoryText and coll.introText ?
        List<String> introductoryText = collectionJSON.findValuesAsText("introductoryText");
        if(! introductoryText.isEmpty()) {
            collection.introText = introductoryText.get(0);
        }

        List<String> shortDescription = collectionJSON.findValuesAsText("shortDescription");
        if(! shortDescription.isEmpty()) {
            collection.shortDescription = shortDescription.get(0);
        }

        List<String> sidebarText = collectionJSON.findValuesAsText("sidebarText");
        if(! sidebarText.isEmpty()) {
            collection.sidebarText = sidebarText.get(0);
        }

        JsonNode commNodes = collectionJSON.get("parentCommunityList");
        if(commNodes != null) {
            for(JsonNode comm : commNodes) {
                Community community = Community.parseCommunityFromJSON(comm);
                collection.parentCommunities.add(community);
            }
        }

        JsonNode itemNodes = collectionJSON.get("items");
        if(itemNodes != null) {
            for(JsonNode itemNode : itemNodes) {
                Item item = Item.parseItemFromJSON(itemNode);
                collection.items.add(item);
            }
View Full Code Here

        //item.isWithdrawn = itemNode.get("isWithdrawn").asBoolean();

        //item.submitterFullName = itemNode.get("submitter").get("fullName").asText();

        if(itemNode.has("metadata")) {
            JsonNode metadataNode = itemNode.get("metadata");
            item.metadata = new ArrayList<MetadataField>();

            for(JsonNode field : metadataNode) {
                String key = field.get("key").asText();
                String value = field.get("value").asText();
                item.metadata.add(new MetadataField(key, value));
            }
        }

        if(itemNode.has("bitstreams")) {
            item.bitstreams = new ArrayList<Bitstream>();
            JsonNode bitstreamsNode = itemNode.get("bitstreams");
            for(JsonNode bitstreamNode : bitstreamsNode) {
                Bitstream bitstream = Bitstream.parseBitstreamFromJSON(bitstreamNode);
                item.bitstreams.add(bitstream);
            }
        }

        if(itemNode.has("parentCollectionList")) {
            JsonNode collectionNodes = itemNode.get("parentCollectionList");
            for(JsonNode collectionNode : collectionNodes) {
                Collection collection = Collection.parseCollectionFromJSON(collectionNode);
                item.collections.add(collection);
            }
        }

        if(itemNode.has("parentCommunityList")) {
            JsonNode communityNodes = itemNode.get("parentCommunityList");
            for(JsonNode communityNode : communityNodes) {
                Community community = Community.parseCommunityFromJSON(communityNode);
                item.communities.add(community);
            }
        }
View Full Code Here

            String output;
            while ((output = reader.readLine()) != null) {
                contentString.append(output);
            }

            JsonNode comm = Json.parse(contentString.toString());
            restResponse.endpoint = conn.getURL().toString();

            ObjectMapper mapper = new ObjectMapper();
            String pretty = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(comm);
            restResponse.jsonString = pretty;

            if (comm.size() > 0) {
                Community community = Community.parseCommunityFromJSON(comm);
                restResponse.modelObject = community;
            }
        } catch (IOException e) {
            Logger.error(e.getMessage(), e);
View Full Code Here

        List<String> introductoryText = communityJSON.findValuesAsText("introductoryText");
        List<String> shortDescription = communityJSON.findValuesAsText("shortDescription");
        List<String> sidebarText = communityJSON.findValuesAsText("sidebarText");

        if(communityJSON.has("logo")) {
            JsonNode logoNode = communityJSON.get("logo");
            if(!logoNode.isNull()) {
                community.logo = Bitstream.parseBitstreamFromJSON(logoNode);
            }
        }


        JsonNode parentCommunityNode = communityJSON.get("parentCommunity");
        if(parentCommunityNode != null && parentCommunityNode.has("id")) {
            Community parentCommunity = Community.parseCommunityFromJSON(parentCommunityNode);
            community.parentCommunities.add(parentCommunity);
        }

        JsonNode subCommNodes = communityJSON.get("subCommunities");
        if(subCommNodes != null) {

            for(JsonNode subComm : subCommNodes) {
                if(subComm.has("id")) {
                    community.subCommunities.add(parseCommunityFromJSON(subComm));
                }
            }
        }

        JsonNode subCollNodes = communityJSON.get("collections");
        if(subCollNodes != null) {
            for(JsonNode subColl : subCollNodes) {
                community.collections.add(Collection.parseCollectionFromJSON(subColl));
            }
        }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.JsonNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.