Esempio n. 1
0
  @Override
  public void onRefreshSummary() {
    cancelPendingSummaryRequest();
    String uri = resourceRequestBuilder.getResource();
    uri = removeQueryParam(uri, "limit");

    Map<String, String> args = Maps.newHashMap();
    args.put("resetCache", "true");
    limit = Math.max(getView().getLimit().intValue(), Math.min(MIN_LIMIT, entitiesCount));

    if (limit < entitiesCount) {
      args.put("limit", String.valueOf(limit));
    }

    String target = updateQueryParams(uri, args);
    resourceRequestBuilder.forResource(target);
    if (target.contains("_transient")) {
      // for script evaluation, we must use post so the script/categories are passed in the form,
      // otherwise the summary is incorrect
      resourceRequestBuilder.post();
    } else {
      resourceRequestBuilder.get();
    }

    onReset();
  }
Esempio n. 2
0
  @Override
  public void onFullSummary() {
    getView().setLimit(entitiesCount);
    cancelPendingSummaryRequest();
    String uri = resourceRequestBuilder.getResource();
    uri = removeQueryParam(uri, "limit");
    Map<String, String> args = Maps.newHashMap();
    args.put("resetCache", "true");
    uri = updateQueryParams(uri, args);

    if (uri.contains("_transient")) {
      // for script evaluation, we must use post so the script/categories are passed in the form,
      // otherwise the summary is incorrect
      resourceRequestBuilder.forResource(uri).post();
    } else {
      resourceRequestBuilder.forResource(uri).get();
    }

    limit = entitiesCount;
    onReset();
  }
Esempio n. 3
0
  private void requestSummary() {
    if (resourceRequestBuilder == null) return;
    if (blockSummaryRequests()) return;

    getView().requestingSummary(limit, entitiesCount);

    summaryRequest =
        resourceRequestBuilder //
            .withCallback(
                new ResourceCallback<SummaryStatisticsDto>() {
                  @Override
                  public void onResource(Response response, SummaryStatisticsDto dto) {
                    summary = dto;
                    getView().renderSummary(dto);
                    getView()
                        .renderSummaryLimit(
                            dto.hasLimit() ? dto.getLimit() : entitiesCount, entitiesCount);
                    getEventBus()
                        .fireEvent(
                            new SummaryReceivedEvent(resourceRequestBuilder.getResource(), dto));
                  }
                }) //
            .withCallback(
                Response.SC_BAD_REQUEST,
                new ResponseCodeCallback() {
                  @Override
                  public void onResponseCode(Request request, Response response) {
                    getView().renderNoSummary();
                    ClientErrorDto error = JsonUtils.unsafeEval(response.getText());
                    checkMessageFlooding(error);
                    NotificationEvent event;
                    if (blockSummaryRequests()) {
                      onCancelSummary();
                      event =
                          NotificationEvent.newBuilder()
                              .error(translations.tooManyRepeatedErrorsLabel())
                              .build();
                    } else {
                      event = new JSErrorNotificationEventBuilder().build(error);
                    }
                    getEventBus().fireEvent(event);
                  }
                }) //
            .send();
  }