Package org.codehaus.jackson.node

Examples of org.codehaus.jackson.node.ArrayNode


        }
    }

    private void setStringArrayProperty(ObjectNode node, String property, String[] strings) {
        if (strings != null) {
            ArrayNode arrayNode = node.putArray(property);
            for (String string : strings) {
                arrayNode.add(string);
            }
            node.put(property, arrayNode);
        }
    }
View Full Code Here


            throw new JsonFormatException("Error reading binary data in property " + prop, e);
        }
    }

    public static List<String> getStrings(JsonNode node, String prop, List<String> defaultValue) throws JsonFormatException {
        ArrayNode arrayNode = getArray(node, prop, null);
        if (arrayNode == null) {
            return defaultValue;
        }
        List<String> elements = new ArrayList<String>();
        Iterator<JsonNode> elementItr = arrayNode.getElements();
        while (elementItr.hasNext()) {
            elements.add(elementItr.next().getValueAsText());
        }
        return elements;
    }
View Full Code Here

  @RequestMapping("/facebook/info")
  public String photos(Model model) throws Exception {
    ObjectNode result = facebookRestTemplate
        .getForObject("https://graph.facebook.com/me/friends", ObjectNode.class);
    ArrayNode data = (ArrayNode) result.get("data");
    ArrayList<String> friends = new ArrayList<String>();
    for (JsonNode dataNode : data) {
      friends.add(dataNode.get("name").getTextValue());
    }
    model.addAttribute("friends", friends);
View Full Code Here

    ObjectNode resultObj = mapper.createObjectNode();
    resultObj.put("code", "/api/status/ok");
    resultObj.put("status", "200 OK");
    resultObj.put("prefix", prefix);
   
    ArrayNode resultArr = mapper.createArrayNode();
    for(SearchResultItem item: results){
      ObjectNode resultItemObj = mapper.createObjectNode();
      resultItemObj.put("id", item.getId());
      resultItemObj.put("name", item.getName());
     
      //FIXME id is used instead of type to enable the suggest autocomplete to function as it doesn't work when no type is given
      ObjectNode tmpObj = mapper.createObjectNode();
      tmpObj.put("id", item.getId());
      tmpObj.put("name", item.getId());
      resultItemObj.put("type", tmpObj);     
     
      resultArr.add(resultItemObj);
    }
    resultObj.put("result", resultArr);
   
    return resultObj;
  }
View Full Code Here

  }
 
  private ObjectNode getResponse(ReconciliationResponse response, PrefixManager prefixManager) {
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode responseObj = mapper.createObjectNode();
    ArrayNode resultArr = mapper.createArrayNode();
    for(ReconciliationCandidate result:response.getResults()){
      ObjectNode resultItemObj = getResultItem(result,prefixManager);
      resultArr.add(resultItemObj);
    }
    responseObj.put("result", resultArr);
   
    return responseObj;
  }
View Full Code Here

    resultItemObj.put("id", item.getId());
    resultItemObj.put("name", item.getName());
    resultItemObj.put("score", item.getScore());
    resultItemObj.put("match", item.isMatch());

    ArrayNode typesArr = mapper.createArrayNode();
    for(int i=0;i<item.getTypes().length;i++){
      String id = item.getTypes()[i];
      int index = getNamespaceEndPosition(id);
      String prefix = prefixManager.getPrefix(id.substring(0,index));
      ObjectNode typeObj = mapper.createObjectNode();
      typeObj.put("id", id);
      if(prefix!=null){
        String localName = id.substring(index);
        typeObj.put("name", prefix +":" + localName);
      }else{
        typeObj.put("name", id);
      }
      typesArr.add(typeObj);
    }
    resultItemObj.put("type", typesArr);
   
    return resultItemObj;
  }
View Full Code Here

    String[] types;
   
    JsonNode typesNode = node.path("type");
    if(! typesNode.isMissingNode()){
      if(typesNode.isArray()){
        ArrayNode typesNodeArray = (ArrayNode) typesNode;
        types = new String[typesNodeArray.size()];
        for(int i=0;i<typesNodeArray.size();i++){
          types[i] = typesNodeArray.get(i).getTextValue();
        }
      }else{
        types = new String[] {typesNode.getTextValue()};
      }
    }else{
      types = new String[]{};
    }
    //get limit
    int limit = node.path("limit").isMissingNode()?getDefaultLimit(types.length):node.path("limit").getIntValue();
    //get type_strict
    //TODO this is ignored for now
    String type_strict = node.path("type_strict").getTextValue();
   
   
    //get context i.e. additional properties
    JsonNode propertiesNode = node.path("properties");
    Set<PropertyContext> props = new HashSet<ReconciliationRequestContext.PropertyContext>();
    if(propertiesNode.isArray()){
      ArrayNode propertiesArray = (ArrayNode) propertiesNode;
      for(int i=0; i<propertiesArray.size();i+=1){
        JsonNode propertyNode = propertiesArray.get(0);
        JsonNode pidNode = propertyNode.path("pid");
        if(pidNode.isMissingNode()){
          //only support strongly-identified properties
          continue;
        }
View Full Code Here

                // Confirm that the HTTP request was handled successfully by
                // checking the API response's HTTP response code.
                if (rootNode.get("status").asText().equals("200 OK")) {
                    // In the API response, the "result" field contains the
                    // list of needed results.
                    ArrayNode arrayNodeResults = (ArrayNode) rootNode.get("result");
                    // Prompt the user to select a topic from the list of API
                    // results.
                    topicsId = getUserChoice(arrayNodeResults);
                }
            } finally {
View Full Code Here

  /**
   * 初始化处理命令类型
   * @param rootNode
   */
  private void initTaskCommandType(JsonNode rootNode){
     ArrayNode baseNodeArray = (ArrayNode)rootNode.get("propertyPackages");
         JsonNode commandInfoBase = JsonConverterUtil.getChildElementByProperty("commandinfobase", "name", baseNodeArray);
         commandInfoBase = commandInfoBase.get("properties").get(0);
         ArrayNode complexItemsNode =(ArrayNode)commandInfoBase.get("complexItems");
         JsonNode commandType = JsonConverterUtil.getChildElementByProperty("commandtype", "id", complexItemsNode);
         ArrayNode arrayNode = objectMapper.createArrayNode();
         TaskCommandConfig  taskCommandConfig = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getTaskCommandConfig();
         List<TaskCommandDef> commandDefs = taskCommandConfig.getTaskCommandDef();
         for(TaskCommandDef taskCommandDef :commandDefs){
            ObjectNode typeNode = objectMapper.createObjectNode();
            if(StringUtil.getBoolean(taskCommandDef.getIsEnabled())&& !"system".equals(taskCommandDef.getType())){
              typeNode.put("id",taskCommandDef.getId());
                 typeNode.put("title", taskCommandDef.getName());
                 typeNode.put("value", taskCommandDef.getId());
                 typeNode.put("refToView", "");
                 arrayNode.add(typeNode);
            }
         }
         ((ObjectNode)commandType).put("items", arrayNode);
  }
View Full Code Here

  /**
   * 初始化分配策略
   * @param rootNode
   */
  private void initAssigneeType(JsonNode rootNode){
    ArrayNode baseNodeArray = (ArrayNode)rootNode.get("propertyPackages");
        JsonNode taskAssignBase = JsonConverterUtil.getChildElementByProperty("taskassignbase", "name", baseNodeArray);
        taskAssignBase = taskAssignBase.get("properties");
        JsonNode assigneeType = JsonConverterUtil.getChildElementByProperty("assignpolicytype", "id", (ArrayNode)taskAssignBase);
        ArrayNode arrayNode = objectMapper.createArrayNode();
       
       
        AssignPolicyConfig assignPolicyConfig = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getAssignPolicyConfig();
        List<AssignPolicy> assignPolicys = assignPolicyConfig.getAssignPolicy();
        for(AssignPolicy assignPolicy :assignPolicys){
           ObjectNode typeNode = objectMapper.createObjectNode();
         typeNode.put("id",assignPolicy.getId());
             typeNode.put("title", assignPolicy.getName());
             typeNode.put("value", assignPolicy.getId());
             arrayNode.add(typeNode);
        }
        ((ObjectNode)assigneeType).put("items", arrayNode);
  }
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.node.ArrayNode

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.