@Override
  public Page<AccountTransferData> retrieveAll(final SearchParameters searchParameters) {

    final StringBuilder sqlBuilder = new StringBuilder(200);
    sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
    sqlBuilder.append(this.accountTransfersMapper.schema());

    if (searchParameters.isOrderByRequested()) {
      sqlBuilder.append(" order by ").append(searchParameters.getOrderBy());

      if (searchParameters.isSortOrderProvided()) {
        sqlBuilder.append(' ').append(searchParameters.getSortOrder());
      }
    }

    if (searchParameters.isLimited()) {
      sqlBuilder.append(" limit ").append(searchParameters.getLimit());
      if (searchParameters.isOffset()) {
        sqlBuilder.append(" offset ").append(searchParameters.getOffset());
      }
    }

    final Object[] objectArray = new Object[2];
    final int arrayPos = 0;
    final Object[] finalObjectArray = Arrays.copyOf(objectArray, arrayPos);
    final String sqlCountRows = "SELECT FOUND_ROWS()";
    return this.paginationHelper.fetchPage(
        this.jdbcTemplate,
        sqlCountRows,
        sqlBuilder.toString(),
        finalObjectArray,
        this.accountTransfersMapper);
  }
Ejemplo n.º 2
0
  @GET
  @Consumes({MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_JSON})
  public String retrieveAll(
      @Context final UriInfo uriInfo,
      @QueryParam("sqlSearch") final String sqlSearch,
      @QueryParam("officeId") final Long officeId,
      @QueryParam("externalId") final String externalId,
      @QueryParam("name") final String name,
      @QueryParam("underHierarchy") final String hierarchy,
      @QueryParam("offset") final Integer offset,
      @QueryParam("limit") final Integer limit,
      @QueryParam("orderBy") final String orderBy,
      @QueryParam("sortOrder") final String sortOrder) {

    this.context
        .authenticatedUser()
        .validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME);

    final SearchParameters searchParameters =
        SearchParameters.forGroups(
            sqlSearch, officeId, externalId, name, hierarchy, offset, limit, orderBy, sortOrder);
    final Page<GroupGeneralData> groups =
        this.groupReadPlatformService.retrieveAll(searchParameters);

    final ApiRequestJsonSerializationSettings settings =
        this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
    return this.toApiJsonSerializer.serialize(
        settings, groups, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS);
  }