use of com.djrapitops.plan.delivery.domain.datatransfer.InputQueryDto in project Plan by plan-player-analytics.
the class QueryJSONResolver method parseInputQueryFromQueryParams.
private InputQueryDto parseInputQueryFromQueryParams(Request request) {
String q = request.getQuery().get("q").orElseThrow(() -> new BadRequestException("'q' parameter not set (expecting json array)"));
try {
String query = URLDecoder.decode(q, "UTF-8");
List<InputFilterDto> queryFilters = InputFilterDto.parse(query, gson);
ViewDto view = request.getQuery().get("view").map(viewJson -> gson.fromJson(viewJson, ViewDto.class)).orElseThrow(() -> new BadRequestException("'view' parameter not set (expecting json object {afterDate, afterTime, beforeDate, beforeTime})"));
return new InputQueryDto(view, queryFilters);
} catch (IOException e) {
throw new BadRequestException("Failed to decode json: '" + q + "', " + e.getMessage());
}
}
use of com.djrapitops.plan.delivery.domain.datatransfer.InputQueryDto in project Plan by plan-player-analytics.
the class QueryJSONResolver method getResponse.
private Response getResponse(Request request) {
Optional<Response> cachedResult = checkForCachedResult(request);
if (cachedResult.isPresent())
return cachedResult.get();
InputQueryDto inputQuery = parseInputQuery(request);
List<InputFilterDto> queries = inputQuery.getFilters();
Filter.Result result = filters.apply(queries);
List<Filter.ResultPath> resultPath = result.getInverseResultPath();
Collections.reverse(resultPath);
return buildAndStoreResponse(inputQuery.getView(), result, resultPath);
}
Aggregations