use of de.metas.ui.web.view.ViewRowsOrderBy in project metasfresh-webui-api by metasfresh.
the class BoardRestController method getNewCardsView.
@GetMapping("/{boardId}/newCardsView/{viewId}")
public JSONViewResult getNewCardsView(@PathVariable("boardId") final int boardId, @PathVariable("viewId") final String viewIdStr, @RequestParam("firstRow") final int firstRow, @RequestParam("pageLength") final int pageLength, @RequestParam(name = "orderBy", required = false) final String orderBysListStr) {
userSession.assertLoggedIn();
final JSONOptions jsonOpts = newJSONOptions();
final ViewRowsOrderBy orderBys = ViewRowsOrderBy.parseString(orderBysListStr, jsonOpts);
final ViewResult viewResult = viewsRepo.getView(viewIdStr).getPageWithRowIdsOnly(firstRow, pageLength, orderBys);
final List<Integer> boardCardIds = boardsRepo.retrieveCardIds(boardId);
return toJSONCardsViewResult(boardId, viewResult, jsonOpts, // filter out cards which already exist in our board
cardId -> !boardCardIds.contains(cardId));
}
use of de.metas.ui.web.view.ViewRowsOrderBy in project metasfresh-webui-api by metasfresh.
the class AbstractCustomView method getPage.
/**
* Simple in-memory implementation with paging and ordering.
*/
@Override
public final ViewResult getPage(final int firstRow, final int pageLength, @NonNull final ViewRowsOrderBy orderBys) {
final ViewRowsOrderBy orderBysEffective = !orderBys.isEmpty() ? orderBys : orderBys.withOrderBys(getDefaultOrderBys());
final List<IViewRow> pageRows = getRows().stream().sorted(orderBysEffective.toComparator()).skip(firstRow >= 0 ? firstRow : 0).limit(pageLength > 0 ? pageLength : 30).collect(ImmutableList.toImmutableList());
return ViewResult.ofViewAndPage(this, firstRow, pageLength, orderBysEffective.toDocumentQueryOrderByList(), pageRows);
}
use of de.metas.ui.web.view.ViewRowsOrderBy in project metasfresh-webui-api by metasfresh.
the class HUEditorViewBuffer_FullyCached method streamPage.
@Override
public Stream<HUEditorRow> streamPage(final int firstRow, final int pageLength, @NonNull final HUEditorRowFilter filter, @NonNull final ViewRowsOrderBy orderBys) {
final ViewRowsOrderBy orderBysEffective = !orderBys.isEmpty() ? orderBys : orderBys.withOrderBys(defaultOrderBys);
Stream<HUEditorRow> stream = getRows().stream().skip(firstRow).limit(pageLength).filter(HUEditorRowFilters.toPredicate(filter));
final Comparator<HUEditorRow> comparator = orderBysEffective.toComparatorOrNull();
if (comparator != null) {
stream = stream.sorted(comparator);
}
return stream;
}
use of de.metas.ui.web.view.ViewRowsOrderBy in project metasfresh-webui-api by metasfresh.
the class HUEditorViewBuffer_HighVolume method streamAllRecursive.
@Override
public Stream<HUEditorRow> streamAllRecursive(@NonNull final HUEditorRowFilter filter) throws UnsupportedOperationException {
final ViewRowIdsOrderedSelection defaultSelection = getDefaultSelection();
if (defaultSelection.getSize() > STREAM_ALL_MAX_SIZE_ALLOWED) {
throw new UnsupportedOperationException("Streaming all rows when selection is bigger than " + STREAM_ALL_MAX_SIZE_ALLOWED + " is not allowed");
}
final JSONOptions jsonOpts = JSONOptions.newInstance();
final ViewRowsOrderBy orderBys = ViewRowsOrderBy.of(defaultSelection.getOrderBys(), jsonOpts);
return streamPage(0, STREAM_ALL_MAX_SIZE_ALLOWED, filter, orderBys).flatMap(HUEditorRow::streamRecursive).map(HUEditorRow::cast).filter(HUEditorRowFilters.toPredicate(filter));
}
use of de.metas.ui.web.view.ViewRowsOrderBy in project metasfresh-webui-api by metasfresh.
the class ViewGeoLocationsRestController method getAll.
@GetMapping
public JsonViewGeoLocationsResult getAll(@PathVariable(PARAM_WindowId) final String windowIdStr, @PathVariable(PARAM_ViewId) final String viewIdStr, @RequestParam(value = "limit", required = false, defaultValue = "0") final int limit) {
userSession.assertLoggedIn();
final ViewId viewId = ViewId.of(windowIdStr, viewIdStr);
final int limitEffective = limit > 0 ? limit : DEFAULT_LIMIT;
final IView view = viewsRepo.getView(viewId);
final ImmutableSet<String> viewFieldNames = getViewFieldNames(view);
final GeoLocationDocumentDescriptor geoLocationDescriptor = geoLocationDocumentService.getGeoLocationDocumentDescriptor(viewFieldNames);
final ViewRowsOrderBy orderBy = ViewRowsOrderBy.of(view.getDefaultOrderBys(), newJsonOpts());
final ViewResult rows = view.getPage(0, limitEffective, orderBy);
final List<JsonViewRowGeoLocation> geoLocations = retrieveGeoLocations(rows, geoLocationDescriptor);
return JsonViewGeoLocationsResult.builder().viewId(viewId.toJson()).locations(geoLocations).build();
}
Aggregations