Search in sources :

Example 1 with PhasingVote

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

the class GetPhasingPollVotes method processRequest.

@Override
protected JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
    long transactionId = ParameterParser.getUnsignedLong(req, "transaction", true);
    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);
    PhasingPoll phasingPoll = PhasingPoll.getPoll(transactionId);
    if (phasingPoll != null) {
        JSONObject response = new JSONObject();
        JSONArray votesJSON = new JSONArray();
        try (DbIterator<PhasingVote> votes = PhasingVote.getVotes(transactionId, firstIndex, lastIndex)) {
            for (PhasingVote vote : votes) {
                votesJSON.add(JSONData.phasingPollVote(vote));
            }
        }
        response.put("votes", votesJSON);
        return response;
    }
    return JSONResponses.UNKNOWN_TRANSACTION;
}
Also used : PhasingPoll(org.xel.PhasingPoll) JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) PhasingVote(org.xel.PhasingVote)

Example 2 with PhasingVote

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

the class GetPhasingPollVote method processRequest.

@Override
protected JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {
    long transactionId = ParameterParser.getUnsignedLong(req, "transaction", true);
    long accountId = ParameterParser.getAccountId(req, true);
    PhasingVote phasingVote = PhasingVote.getVote(transactionId, accountId);
    if (phasingVote != null) {
        return JSONData.phasingPollVote(phasingVote);
    }
    return JSON.emptyJSON;
}
Also used : PhasingVote(org.xel.PhasingVote)

Aggregations

PhasingVote (org.xel.PhasingVote)2 JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1 PhasingPoll (org.xel.PhasingPoll)1