/**
   * Builds the results model, applying pagination to the results if necessary.
   *
   * @param req The WebScript request
   * @param dataPropertyName The name of the property to use in the model
   * @param results The full set of results
   * @return List of results to return to the callee
   */
  protected Map<String, Object> createResultModel(
      WebScriptRequest req, String dataPropertyName, List<Map<String, Object>> results) {
    // MNT-9074 My Tasks fails to render if tasks quantity is excessive
    int totalItems = 0;
    try {
      totalItems = getCapacity(results);
    } catch (Exception e) {
      totalItems = results.size();
    }

    int maxItems = getIntParameter(req, PARAM_MAX_ITEMS, DEFAULT_MAX_ITEMS);
    int skipCount = getIntParameter(req, PARAM_SKIP_COUNT, DEFAULT_SKIP_COUNT);

    Map<String, Object> model = new HashMap<String, Object>();
    model.put(dataPropertyName, applyPagination(results, maxItems, skipCount));

    if (maxItems != DEFAULT_MAX_ITEMS || skipCount != DEFAULT_SKIP_COUNT) {
      // maxItems or skipCount parameter was provided so we need to include paging into response
      model.put(
          "paging",
          ModelUtil.buildPaging(
              totalItems, maxItems == DEFAULT_MAX_ITEMS ? totalItems : maxItems, skipCount));
    }

    return model;
  }
  /**
   * Make the pagination for given list of objects
   *
   * @param results the initial list of objects for pagination
   * @param maxItems maximum count of elements that should be included in paging result
   * @param skipCount the count of elements that should be skipped
   * @return List of paginated results
   */
  protected List<Map<String, Object>> applyPagination(
      List<Map<String, Object>> results, int maxItems, int skipCount) {
    if (maxItems == DEFAULT_MAX_ITEMS && skipCount == DEFAULT_SKIP_COUNT) {
      // no need to make pagination
      return results;
    }

    // Do the paging
    return ModelUtil.page(results, maxItems, skipCount);
  }
예제 #3
0
  private Map<String, Serializable> buildMailTextModel(
      Map<String, String> properties, NodeRef inviter, NodeRef invitee) {
    // Set the core model parts
    // Note - the user part is skipped, as that's implied via the run-as
    Map<String, Serializable> model = new HashMap<String, Serializable>();
    model.put(TemplateService.KEY_COMPANY_HOME, repository.getCompanyHome());
    model.put(TemplateService.KEY_USER_HOME, repository.getUserHome(repository.getPerson()));
    model.put(TemplateService.KEY_PRODUCT_NAME, ModelUtil.getProductName(repoAdminService));

    // Build up the args for rendering inside the template
    Map<String, String> args = buildArgs(properties, inviter, invitee);
    model.put("args", (Serializable) args);

    // All done
    return model;
  }
예제 #4
0
 private String buildSubject(Map<String, String> properties) {
   return messageService.getMessage(
       "invitation.invitesender.email.subject",
       ModelUtil.getProductName(repoAdminService),
       getSiteName(properties));
 }