Search in sources :

Example 16 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project hive by apache.

the class Vertex method extractOpTree.

/**
   * @throws JSONException
   * @throws JsonParseException
   * @throws JsonMappingException
   * @throws IOException
   * @throws Exception
   *           We assume that there is a single top-level Map Operator Tree or a
   *           Reduce Operator Tree in a vertex
   */
public void extractOpTree() throws JSONException, JsonParseException, JsonMappingException, IOException, Exception {
    if (vertexObject.length() != 0) {
        for (String key : JSONObject.getNames(vertexObject)) {
            if (key.equals("Map Operator Tree:")) {
                extractOp(vertexObject.getJSONArray(key).getJSONObject(0));
            } else if (key.equals("Reduce Operator Tree:") || key.equals("Processor Tree:")) {
                extractOp(vertexObject.getJSONObject(key));
            } else if (key.equals("Join:")) {
                // this is the case when we have a map-side SMB join
                // one input of the join is treated as a dummy vertex
                JSONArray array = vertexObject.getJSONArray(key);
                for (int index = 0; index < array.length(); index++) {
                    JSONObject mpOpTree = array.getJSONObject(index);
                    Vertex v = new Vertex(null, mpOpTree, parser);
                    v.extractOpTree();
                    v.dummy = true;
                    mergeJoinDummyVertexs.add(v);
                }
            } else if (key.equals("Merge File Operator")) {
                JSONObject opTree = vertexObject.getJSONObject(key);
                if (opTree.has("Map Operator Tree:")) {
                    extractOp(opTree.getJSONArray("Map Operator Tree:").getJSONObject(0));
                } else {
                    throw new Exception("Merge File Operator does not have a Map Operator Tree");
                }
            } else if (key.equals("Execution mode:")) {
                executionMode = " " + vertexObject.getString(key);
            } else if (key.equals("tagToInput:")) {
                JSONObject tagToInput = vertexObject.getJSONObject(key);
                for (String tag : JSONObject.getNames(tagToInput)) {
                    this.tagToInput.put(tag, (String) tagToInput.get(tag));
                }
            } else if (key.equals("tag:")) {
                this.tag = vertexObject.getString(key);
            } else {
                throw new Exception("Unsupported operator tree in vertex " + this.name);
            }
        }
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JSONException(org.json.JSONException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 17 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project hive by apache.

the class Vertex method extractOp.

/**
   * @param operator
   * @param parent
   * @return
   * @throws JSONException
   * @throws JsonParseException
   * @throws JsonMappingException
   * @throws IOException
   * @throws Exception
   *           assumption: each operator only has one parent but may have many
   *           children
   */
Op extractOp(JSONObject operator) throws JSONException, JsonParseException, JsonMappingException, IOException, Exception {
    String[] names = JSONObject.getNames(operator);
    if (names.length != 1) {
        throw new Exception("Expect only one operator in " + operator.toString());
    } else {
        String opName = names[0];
        JSONObject attrObj = (JSONObject) operator.get(opName);
        Map<String, String> attrs = new TreeMap<>();
        List<Op> children = new ArrayList<>();
        String id = null;
        String outputVertexName = null;
        for (String attrName : JSONObject.getNames(attrObj)) {
            if (attrName.equals("children")) {
                Object childrenObj = attrObj.get(attrName);
                if (childrenObj instanceof JSONObject) {
                    if (((JSONObject) childrenObj).length() != 0) {
                        children.add(extractOp((JSONObject) childrenObj));
                    }
                } else if (childrenObj instanceof JSONArray) {
                    if (((JSONArray) childrenObj).length() != 0) {
                        JSONArray array = ((JSONArray) childrenObj);
                        for (int index = 0; index < array.length(); index++) {
                            children.add(extractOp(array.getJSONObject(index)));
                        }
                    }
                } else {
                    throw new Exception("Unsupported operator " + this.name + "'s children operator is neither a jsonobject nor a jsonarray");
                }
            } else {
                if (attrName.equals("OperatorId:")) {
                    id = attrObj.get(attrName).toString();
                } else if (attrName.equals("outputname:")) {
                    outputVertexName = attrObj.get(attrName).toString();
                } else {
                    if (!attrObj.get(attrName).toString().isEmpty()) {
                        attrs.put(attrName, attrObj.get(attrName).toString());
                    }
                }
            }
        }
        Op op = new Op(opName, id, outputVertexName, children, attrs, operator, this, parser);
        if (!children.isEmpty()) {
            for (Op child : children) {
                child.parent = op;
            }
        } else {
            this.rootOps.add(op);
        }
        return op;
    }
}
Also used : JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) JSONObject(org.json.JSONObject) TreeMap(java.util.TreeMap) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JSONException(org.json.JSONException) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 18 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.

the class NewsDao method getMore.

public NewsMoreResponse getMore(String more_url) {
    NewsMoreResponse response;
    try {
        String result = RequestCacheUtil.getRequestContent(mActivity, more_url + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, true);
        response = mObjectMapper.readValue(result, new TypeReference<NewsMoreResponse>() {
        });
        return response;
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return null;
}
Also used : JsonMappingException(org.codehaus.jackson.map.JsonMappingException) TypeReference(org.codehaus.jackson.type.TypeReference) IOException(java.io.IOException) NewsMoreResponse(cn.eoe.app.entity.NewsMoreResponse) JsonParseException(org.codehaus.jackson.JsonParseException)

Example 19 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.

the class NewsDao method mapperJson.

public NewsResponseEntity mapperJson(boolean useCache) {
    // TODO Auto-generated method stub
    NewsJson newsJson;
    try {
        String result = RequestCacheUtil.getRequestContent(mActivity, Urls.NEWS_LIST + Utility.getScreenParams(mActivity), Constants.WebSourceType.Json, Constants.DBContentType.Content_list, useCache);
        newsJson = mObjectMapper.readValue(result, new TypeReference<NewsJson>() {
        });
        if (newsJson == null) {
            return null;
        }
        this._newsResponse = newsJson.getResponse();
        return _newsResponse;
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : NewsJson(cn.eoe.app.entity.NewsJson) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) TypeReference(org.codehaus.jackson.type.TypeReference) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException)

Example 20 with JsonMappingException

use of org.codehaus.jackson.map.JsonMappingException in project android-app by eoecn.

the class SearchDao method mapperJson.

/**
	 * 这里的逻辑判断得优化 目前仅为实现功能编写的代码 不妥
	 * 
	 * @return
	 */
public List<Object> mapperJson() {
    categorys.clear();
    tabs.clear();
    hasChild = false;
    try {
        if (mTag.equals("news")) {
            NewsSearchJson newsSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord + Utility.getScreenParams(mActivity)), new TypeReference<NewsSearchJson>() {
            });
            categorys.add(newsSearchJson.getResponse());
            cate_name = newsSearchJson.getResponse().getName();
            if (newsSearchJson.getResponse().getItems() != null) {
                hasChild = true;
            }
        } else if (mTag.equals("wiki")) {
            WikiSearchJson wikiSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord), new TypeReference<WikiSearchJson>() {
            });
            categorys.add(wikiSearchJson.getResponse());
            cate_name = wikiSearchJson.getResponse().getName();
            if (wikiSearchJson.getResponse().getItems() != null) {
                hasChild = true;
            }
        } else if (mTag.equals("blog")) {
            BlogSearchJson blogSearchJson = mObjectMapper.readValue(HttpUtils.getByHttpClient(mActivity, Urls.BASE_SEARCH_URL + "t=" + mTag + "&w=" + keyWord), new TypeReference<BlogSearchJson>() {
            });
            categorys.add(blogSearchJson.getResponse());
            cate_name = blogSearchJson.getResponse().getName();
            if (blogSearchJson.getResponse().getItems() != null) {
                hasChild = true;
            }
        }
        return categorys;
    } catch (JsonParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : BlogSearchJson(cn.eoe.app.entity.BlogSearchJson) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) NewsSearchJson(cn.eoe.app.entity.NewsSearchJson) TypeReference(org.codehaus.jackson.type.TypeReference) IOException(java.io.IOException) JsonParseException(org.codehaus.jackson.JsonParseException) IOException(java.io.IOException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) JsonParseException(org.codehaus.jackson.JsonParseException) WikiSearchJson(cn.eoe.app.entity.WikiSearchJson)

Aggregations

JsonMappingException (org.codehaus.jackson.map.JsonMappingException)39 IOException (java.io.IOException)31 JsonParseException (org.codehaus.jackson.JsonParseException)30 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)14 TypeReference (org.codehaus.jackson.type.TypeReference)10 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 Map (java.util.Map)4 MeetingBO (org.mifos.application.meeting.business.MeetingBO)3 BlogsMoreResponse (cn.eoe.app.entity.BlogsMoreResponse)2 NewsMoreResponse (cn.eoe.app.entity.NewsMoreResponse)2 WikiMoreResponse (cn.eoe.app.entity.WikiMoreResponse)2 ByteString (com.linkedin.data.ByteString)2 PhysicalSourceConfig (com.linkedin.databus2.relay.config.PhysicalSourceConfig)2 InputStream (java.io.InputStream)2 MessagingException (javax.mail.MessagingException)2 MimeBodyPart (javax.mail.internet.MimeBodyPart)2 MimeMultipart (javax.mail.internet.MimeMultipart)2