Package com.fasterxml.jackson.databind.node

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


    public static Result getTypes() {
        ArrayNode result = new ArrayNode(JsonNodeFactory.instance);

        for(LinkType linkType : LinkType.values()){
            ObjectNode typeJson = Json.newObject();
            typeJson.put("id", linkType.name());
            typeJson.put("label", linkType.getLabel());
            typeJson.put("icon", linkType.getIcon());
            typeJson.put("url", linkType.getUrl());
            result.add(typeJson);
        }


View Full Code Here


         */
        @Override
        public QueryFilter4 deserialize(JsonParser jp, DeserializationContext ctxt)
                throws IOException {

            ObjectNode root = jp.readValueAsTree();

            // pass in our objectCodec so that the subJsonParser knows about our configured Modules and Annotations
            JsonParser subJsonParser = root.traverse( jp.getCodec() );

            // Check if it is a "RealFilter"
            JsonNode valueParam = root.get("value");

            if ( valueParam == null ) {
                 return subJsonParser.readValueAs( LogicalFilter4.class );
            }
            if ( valueParam.isBoolean() ) {
View Full Code Here

         */
        @Override
        public QueryFilter deserialize(JsonParser jp, DeserializationContext ctxt)
                throws IOException {

            ObjectNode root = jp.readValueAsTree();

            JsonNode queryParam = root.get("queryParam");
            String value = queryParam.asText();

            // pass in our objectCodec so that the subJsonParser knows about our configured Modules and Annotations
            JsonParser subJsonParser = root.traverse( jp.getCodec() );

            // Determine the "type" of filter we are dealing with Real or Logical and specify type
            if ( "OR".equals( value ) || "AND".equals( value ) ) {
                return subJsonParser.readValueAs( LogicalFilter1.class );
            }
View Full Code Here

        @Override
        public LogicalFilter4 deserialize( JsonParser jp, DeserializationContext ctxt ) throws IOException, JsonProcessingException {

            ObjectCodec objectCodec = jp.getCodec();
            ObjectNode root = jp.readValueAsTree();

            // We assume it is a LogicalFilter
            Iterator<String> iter = root.fieldNames();
            String key = iter.next();

            JsonNode arrayNode = root.iterator().next();
            if ( arrayNode == null || arrayNode.isMissingNode() || ! arrayNode.isArray() ) {
                throw new RuntimeException( "Invalid format of LogicalFilter encountered." );
            }

            // pass in our objectCodec so that the subJsonParser knows about our configured Modules and Annotations
View Full Code Here

         */
        @Override
        public QueryFilter deserialize(JsonParser jp, DeserializationContext ctxt)
                throws IOException {

            ObjectNode root = jp.readValueAsTree();

            // pass in our objectCodec so that the subJsonParser knows about our configured Modules and Annotations
            JsonParser subJsonParser = root.traverse( jp.getCodec() );

            // Check if it is a "RealFilter"
            JsonNode queryParam = root.get("queryParam");
            if ( queryParam != null && queryParam.isValueNode() ) {
                return subJsonParser.readValueAs( RealFilter.class );
            }
            else {
                return subJsonParser.readValueAs( LogicalFilter3.class );
View Full Code Here

        @Override
        public LogicalFilter3 deserialize( JsonParser jp, DeserializationContext ctxt ) throws IOException, JsonProcessingException {

            ObjectCodec objectCodec = jp.getCodec();
            ObjectNode root = jp.readValueAsTree();

            // We assume it is a LogicalFilter
            Iterator<String> iter = root.fieldNames();
            String key = iter.next();

            JsonNode arrayNode = root.iterator().next();
            if ( arrayNode == null || arrayNode.isMissingNode() || ! arrayNode.isArray() ) {
                throw new RuntimeException( "Invalid format of LogicalFilter encountered." );
            }

            // pass in our objectCodec so that the subJsonParser knows about our configured Modules and Annotations
View Full Code Here

    public static Object fromJsonNode(final JsonNode node) {
        if (node.isNull())
            return null;
        else if (node.isObject()) {
            final Map<String, Object> map = new HashMap<>();
            final ObjectNode objectNode = (ObjectNode) node;
            final Iterator<String> iterator = objectNode.fieldNames();
            while (iterator.hasNext()) {
                String key = iterator.next();
                map.put(key, fromJsonNode(objectNode.get(key)));
            }
            return map;
        } else if (node.isArray()) {
            final ArrayNode arrayNode = (ArrayNode) node;
            final ArrayList<Object> array = new ArrayList<>();
View Full Code Here

    final int rightId = implementInput(implementor, 1, leftCount, right);

    /*
     * E.g. { op: "join", left: 2, right: 4, conditions: [ {relationship: "==", left: "deptId", right: "deptId"} ] }
     */
    final ObjectNode join = implementor.mapper.createObjectNode();
    join.put("op", "join");
    join.put("left", leftId);
    join.put("right", rightId);
    join.put("type", toDrill(joinType));
    final ArrayNode conditions = implementor.mapper.createArrayNode();
    join.put("conditions", conditions);
    for (Pair<Integer, Integer> pair : Pair.zip(leftKeys, rightKeys)) {
      final ObjectNode condition = implementor.mapper.createObjectNode();
      condition.put("relationship", "==");
      condition.put("left", leftFields.get(pair.left));
      condition.put("right", rightFields.get(pair.right));
      conditions.add(condition);
    }
    return implementor.add(join);
  }
View Full Code Here

      return inputId;
    }
  }

  private int rename(DrillImplementor implementor, int inputId, List<String> inputFields, List<String> outputFields) {
    final ObjectNode project = implementor.mapper.createObjectNode();
    project.put("op", "project");
    project.put("input", inputId);
    final ArrayNode transforms = implementor.mapper.createArrayNode();
    project.put("projections", transforms);
    for (Pair<String, String> pair : Pair.zip(inputFields, outputFields)) {
      final ObjectNode objectNode = implementor.mapper.createObjectNode();
      transforms.add(objectNode);
      objectNode.put("expr", pair.left);
      objectNode.put("ref", "output." + pair.right);
//      objectNode.put("ref", pair.right);
    }
    return implementor.add(project);
  }
View Full Code Here

    super.register(planner);
    DrillOptiq.registerStandardPlannerRules(planner, drillTable.client);
  }

  public int implement(DrillImplementor implementor) {
    final ObjectNode node = implementor.mapper.createObjectNode();
    node.put("op", "scan");
    node.put("memo", "initial_scan");
    node.put("ref", "_MAP"); // output is a record with a single field, '_MAP'
    node.put("storageengine", drillTable.getStorageEngineName());
    node.put("selection", implementor.mapper.convertValue(drillTable.getSelection(), JsonNode.class));
    implementor.registerSource(drillTable);
    return implementor.add(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.