Package com.fasterxml.jackson.databind.node

Examples of com.fasterxml.jackson.databind.node.ObjectNode


        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);

        for (Proposal proposal : proposals) {

            ObjectNode proposalJson = Json.newObject();

            proposalJson.put("id", proposal.getId());
            proposalJson.put("title", proposal.getTitle());


            if (proposal.format != null) {
                ObjectNode formatJson = Json.newObject();
                formatJson.put("id", proposal.format.getId());
                formatJson.put("dureeMinutes", proposal.format.getDureeMinutes());
                formatJson.put("libelle", proposal.format.getLibelle());
                proposalJson.put("format", formatJson);
            } else {
                proposalJson.putNull("format");
            }

            if (proposal.statusProposal != null) {
                proposalJson.put("status", proposal.statusProposal.name());
            } else {
                proposalJson.putNull("status");
            }

            if (proposal.audience != null) {
                proposalJson.put("audience", proposal.audience.getTitle());
            } else {
                proposalJson.putNull("audience");
            }

            if (proposal.getSpeaker() != null) {
                ObjectNode speakerJson = Json.newObject();
                speakerJson.put("id", proposal.getSpeaker().id);
                speakerJson.put("fullname", proposal.getSpeaker().getFullname());
                speakerJson.put("avatar", proposal.getSpeaker().getAvatar());
                proposalJson.put("speaker", speakerJson);
            }

            Vote voteUser = votes.get(proposal.getId());
            if (voteUser != null) {
View Full Code Here


        User user = getLoggedUser();
        if ((!user.admin && !user.hasEvent(getEvent()))) {
            return forbidden();
        }
        ObjectNode result = Json.newObject();
        result.put("nbProposals", Proposal.countProposals(false));
        result.put("nbProposalDraft", Proposal.countProposals(true));
        result.put("nbAcceptes", Proposal.countProposalsAcceptes());
        result.put("nbRejetes", Proposal.countProposalsRejetes());
        result.put("nbVotesUser", Vote.findNbVotesUser(user));
        return ok(result);
    }
View Full Code Here

        if (proposal == null) {
            return notFound();
        }

        ObjectNode proposalJson = proposalToJson(proposal);
        return ok(jsonp(callback, proposalJson));
    }
View Full Code Here

        if (proposal == null) {
            return notFound();
        }

        ObjectNode proposalJson = proposalToJson(proposal);
        return ok(proposalJson);
    }
View Full Code Here

        ObjectNode proposalJson = proposalToJson(proposal);
        return ok(proposalJson);
    }

    private static ObjectNode proposalToJson(Proposal proposal) {
        ObjectNode proposalJson = Json.newObject();
        proposalJson.put("id", proposal.getId());
        proposalJson.put("title", proposal.getTitle());
        proposalJson.put("description", proposal.getDescription());
        proposalJson.put("indicationsOrganisateurs", proposal.getIndicationsOrganisateurs());
        ArrayNode tags = new ArrayNode(JsonNodeFactory.instance);
        for (Tag tag : proposal.getTags()) {
            tags.add(tag.nom);
        }
        proposalJson.put("tags", tags);

        ArrayNode speakers = new ArrayNode(JsonNodeFactory.instance);
        if (proposal.getSpeaker() != null) {
            speakers.add(getSpeakerInJson(proposal.getSpeaker()));
        }
        for (User otherSpeaker : proposal.getCoSpeakers()) {
            speakers.add(getSpeakerInJson(otherSpeaker));
        }
        proposalJson.put("speakers", speakers);
        return proposalJson;
    }
View Full Code Here

        // speaker.proposals.description
        // speaker.proposals.otherspeakers

        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);
        for (User speaker : speakersSorted) {
            ObjectNode speakerJson = getSpeakerInJson(speaker);
            ArrayNode proposalsJson = new ArrayNode(JsonNodeFactory.instance);
            for (Proposal proposal : speakers.get(speaker)) {
                ObjectNode proposalJson = Json.newObject();
                proposalJson.put("id", proposal.getId());
                proposalJson.put("title", proposal.getTitle());
                proposalJson.put("description", proposal.getDescription());
                proposalJson.put("indicationsOrganisateurs", proposal.getIndicationsOrganisateurs());
                ArrayNode otherSpeakers = new ArrayNode(JsonNodeFactory.instance);
                if (proposal.getSpeaker() != null && !speaker.equals(proposal.getSpeaker())) {
                    otherSpeakers.add(getSpeakerInJson(proposal.getSpeaker()));
                }
                for (User otherSpeaker : proposal.getCoSpeakers()) {
                    if (!otherSpeaker.equals(speaker)) {
                        otherSpeakers.add(getSpeakerInJson(otherSpeaker));
                    }
                }
                proposalJson.put("otherspeakers", otherSpeakers);
                proposalsJson.add(proposalJson);
            }
            speakerJson.put("proposals", proposalsJson);
            result.add(speakerJson);
        }
View Full Code Here

        // proposal.coSpeakers

        List<Proposal> proposalsAccepted = Proposal.findByStatusForMinimalData(Proposal.Status.ACCEPTED);
        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);
        for (Proposal proposal : proposalsAccepted) {
            ObjectNode proposalJson = Json.newObject();
            proposalJson.put("id", proposal.getId());
            proposalJson.put("title", proposal.getTitle());
            proposalJson.put("description", proposal.getDescription());
            proposalJson.put("indicationsOrganisateurs", proposal.getIndicationsOrganisateurs());

            if (proposal.getSpeaker() != null) {
                proposalJson.put("speaker", getSpeakerInJson(proposal.getSpeaker()));
            }
            ArrayNode coSpeakers = new ArrayNode(JsonNodeFactory.instance);
            for (User speaker : proposal.getCoSpeakers()) {
                coSpeakers.add(getSpeakerInJson(speaker));
            }
            proposalJson.put("coSpeakers", coSpeakers);
            result.add(proposalJson);
        }
        return ok(jsonp(callback, result));
    }
View Full Code Here

            "}" +
            "]";

    @Test
    public void json_can_be_parsed() {
        ObjectNode node = using(JACKSON_TREE_CONFIGURATION).parse(JSON_DOCUMENT).read("$");
        assertThat(node.get("string-property").asText()).isEqualTo("string-value");
    }
View Full Code Here

        }
    }

    @Override
    public Object getMapValue(Object obj, String key) {
        ObjectNode jsonObject = toJsonObject(obj);
        Object o = jsonObject.get(key);
        if (!jsonObject.has(key)) {
            return UNDEFINED;
        } else {
            return unwrap(o);
        }
    }
View Full Code Here

    }
    return node;
  }

  public JsonNode createJsonNode(Map<String, Object> parameter) {
    ObjectNode node = getConfiguredObjectMapper().getNodeFactory().objectNode();
    for (Map.Entry<String, Object> entry : parameter.entrySet()) {
      node.set(entry.getKey(), createJsonNode(entry.getValue()));
    }
    return node;
  }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.node.ObjectNode

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.