예제 #1
0
  /** --- Internal --- */
  private BaseResponse getUpdatesDuring(LocalDateTime from, LocalDateTime to, WebRequest request) {
    // Fetch params
    LimitOffset limOff = getLimitOffset(request, 50);
    Range<LocalDateTime> updateRange = getClosedOpenRange(from, to, "from", "to");
    boolean detail = getBooleanParam(request, "detail", false);
    boolean summary = getBooleanParam(request, "summary", false);
    SortOrder sortOrder = getSortOrder(request, SortOrder.ASC);
    String filter = request.getParameter("filter");
    UpdateType updateType = getUpdateTypeFromParam(request);
    BillUpdateField fieldFilter = getUpdateFieldFromParam(filter);

    if (!detail) {
      PaginatedList<UpdateToken<BaseBillId>> updateTokens =
          billUpdatesDao.getUpdates(updateRange, updateType, fieldFilter, sortOrder, limOff);
      return DateRangeListViewResponse.of(
          updateTokens
              .getResults()
              .stream()
              .map(
                  token ->
                      (!summary)
                          ? new UpdateTokenView(token, new BaseBillIdView(token.getId()))
                          : new UpdateTokenModelView(
                              token,
                              new BaseBillIdView(token.getId()),
                              new SimpleBillInfoView(billData.getBillInfo(token.getId()))))
              .collect(toList()),
          updateRange,
          updateTokens.getTotal(),
          limOff);
    } else {
      PaginatedList<UpdateDigest<BaseBillId>> updateDigests =
          billUpdatesDao.getDetailedUpdates(
              updateRange, updateType, fieldFilter, sortOrder, limOff);
      return DateRangeListViewResponse.of(
          updateDigests
              .getResults()
              .stream()
              .map(
                  digest ->
                      (!summary)
                          ? new UpdateDigestView(digest, new BaseBillIdView(digest.getId()))
                          : new UpdateDigestModelView(
                              digest,
                              new BaseBillIdView(digest.getId()),
                              new SimpleBillInfoView(billData.getBillInfo(digest.getId()))))
              .collect(toList()),
          updateRange,
          updateDigests.getTotal(),
          limOff);
    }
  }
예제 #2
0
 private BaseResponse getUpdatesForBillDuring(
     int sessionYear, String printNo, LocalDateTime from, LocalDateTime to, WebRequest request) {
   BillUpdateField filterField = getUpdateFieldFromParam(request.getParameter("filter"));
   SortOrder sortOrder = getSortOrder(request, SortOrder.ASC);
   LimitOffset limOff = getLimitOffset(request, 50);
   Range<LocalDateTime> updateRange = getClosedOpenRange(from, to, "from", "to");
   UpdateType updateType = getUpdateTypeFromParam(request);
   PaginatedList<UpdateDigest<BaseBillId>> digests =
       billUpdatesDao.getDetailedUpdatesForBill(
           getBaseBillId(printNo, sessionYear, "printNo"),
           updateRange,
           updateType,
           filterField,
           sortOrder,
           limOff);
   return DateRangeListViewResponse.of(
       digests
           .getResults()
           .stream()
           .map(digest -> new UpdateDigestView(digest, new BaseBillIdView(digest.getId())))
           .collect(toList()),
       updateRange,
       digests.getTotal(),
       limOff);
 }