Search in sources :

Example 6 with TaggedData

use of org.xel.TaggedData in project elastic-core-maven by OrdinaryDude.

the class GetAllTaggedData method processRequest.

@Override
protected JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);
    boolean includeData = "true".equalsIgnoreCase(req.getParameter("includeData"));
    JSONObject response = new JSONObject();
    JSONArray jsonArray = new JSONArray();
    response.put("data", jsonArray);
    try (DbIterator<TaggedData> data = TaggedData.getAll(firstIndex, lastIndex)) {
        while (data.hasNext()) {
            jsonArray.add(JSONData.taggedData(data.next(), includeData));
        }
    }
    return response;
}
Also used : JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) TaggedData(org.xel.TaggedData)

Example 7 with TaggedData

use of org.xel.TaggedData in project elastic-core-maven by OrdinaryDude.

the class SearchTaggedData method processRequest.

@Override
protected JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
    long accountId = ParameterParser.getAccountId(req, "account", false);
    String query = ParameterParser.getSearchQuery(req);
    String channel = Convert.emptyToNull(req.getParameter("channel"));
    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);
    boolean includeData = "true".equalsIgnoreCase(req.getParameter("includeData"));
    JSONObject response = new JSONObject();
    JSONArray jsonArray = new JSONArray();
    response.put("data", jsonArray);
    try (DbIterator<TaggedData> data = TaggedData.searchData(query, channel, accountId, firstIndex, lastIndex)) {
        while (data.hasNext()) {
            jsonArray.add(JSONData.taggedData(data.next(), includeData));
        }
    }
    return response;
}
Also used : JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) TaggedData(org.xel.TaggedData)

Aggregations

TaggedData (org.xel.TaggedData)7 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Account (org.xel.Account)1 Attachment (org.xel.Attachment)1 Transaction (org.xel.Transaction)1