Ejemplo n.º 1
0
  public PageResponse<StatePageRow> loadRuleListForState(StatePageRequest request)
      throws SerializationException {
    if (request == null) {
      throw new IllegalArgumentException("request cannot be null");
    }
    if (request.getPageSize() != null && request.getPageSize() < 0) {
      throw new IllegalArgumentException("pageSize cannot be less than zero.");
    }

    // Do query
    long start = System.currentTimeMillis();

    // TODO: May need to use a filter for both package and categories
    // NOTE: Filtering is handled in repository.findAssetsByState()
    int numRowsToReturn = (request.getPageSize() == null ? -1 : request.getPageSize());
    AssetItemPageResult result =
        rulesRepository.findAssetsByState(
            request.getStateName(), false, request.getStartRowIndex(), numRowsToReturn);
    log.debug("Search time: " + (System.currentTimeMillis() - start));

    // Populate response
    boolean bHasMoreRows = result.hasNext;

    List<StatePageRow> rowList =
        new StatePageRowBuilder()
            .withPageRequest(request)
            .withContent(result.assets.iterator())
            .build();

    PageResponse<StatePageRow> response =
        new PageResponseBuilder<StatePageRow>()
            .withStartRowIndex(request.getStartRowIndex())
            .withPageRowList(rowList)
            .withLastPage(!bHasMoreRows)
            .buildWithTotalRowCount(-1);

    long methodDuration = System.currentTimeMillis() - start;
    log.debug(
        "Searched for Assest with State ("
            + request.getStateName()
            + ") in "
            + methodDuration
            + " ms.");
    return response;
  }
Ejemplo n.º 2
0
  /** @deprecated in favour of {@link #loadRuleListForState(StatePageRequest)} */
  public TableDataResult loadRuleListForState(
      String stateName, int skip, int numRows, String tableConfig) throws SerializationException {

    AssetItemPageResult result = rulesRepository.findAssetsByState(stateName, false, skip, numRows);
    return new TableDisplayHandler(tableConfig).loadRuleListTable(result);
  }