use of de.metas.ui.web.view.json.JSONViewResult in project metasfresh-webui-api by metasfresh.
the class ViewRestController method getViewData.
@GetMapping("/{viewId}")
public JSONViewResult getViewData(//
@PathVariable(PARAM_WindowId) final String windowId, //
@PathVariable("viewId") final String viewIdStr, //
@RequestParam(name = PARAM_FirstRow, required = true) @ApiParam(PARAM_FirstRow_Description) final int firstRow, //
@RequestParam(name = PARAM_PageLength, required = true) final int pageLength, //
@RequestParam(name = PARAM_OrderBy, required = false) @ApiParam(PARAM_OrderBy_Description) final String orderBysListStr) {
userSession.assertLoggedIn();
final ViewId viewId = ViewId.of(windowId, viewIdStr);
final IView view = viewsRepo.getView(viewId);
final ViewResult result = view.getPage(firstRow, pageLength, DocumentQueryOrderBy.parseOrderBysList(orderBysListStr));
final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view);
return JSONViewResult.of(result, rowOverrides, userSession.getAD_Language());
}
use of de.metas.ui.web.view.json.JSONViewResult 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 ViewResult viewResult = viewsRepo.getView(viewIdStr).getPageWithRowIdsOnly(firstRow, pageLength, DocumentQueryOrderBy.parseOrderBysList(orderBysListStr));
final List<Integer> boardCardIds = boardsRepo.retrieveCardIds(boardId);
return toJSONCardsViewResult(boardId, viewResult, // language
userSession.getAD_Language(), // filter out cards which already exist in our board
cardId -> !boardCardIds.contains(cardId));
}
use of de.metas.ui.web.view.json.JSONViewResult in project metasfresh-webui-api by metasfresh.
the class BoardRestController method toJSONCardsViewResult.
private final JSONViewResult toJSONCardsViewResult(final int boardId, final IView view, final String adLanguage) {
final ViewResult viewResult = ViewResult.ofView(view);
final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view);
return JSONViewResult.of(viewResult, rowOverrides, adLanguage);
}
use of de.metas.ui.web.view.json.JSONViewResult in project metasfresh-webui-api by metasfresh.
the class ViewRestController method createView.
@PostMapping
public JSONViewResult createView(//
@PathVariable(PARAM_WindowId) final String windowIdStr, //
@RequestBody final JSONCreateViewRequest jsonRequest) {
userSession.assertLoggedIn();
final WindowId windowId = extractWindowId(windowIdStr, jsonRequest.getWindowId());
final CreateViewRequest request = CreateViewRequest.builder(windowId, jsonRequest.getViewType()).setProfileId(jsonRequest.getProfileId()).setReferencingDocumentPaths(jsonRequest.getReferencingDocumentPaths()).setFiltersFromJSON(jsonRequest.getFilters()).setFilterOnlyIds(jsonRequest.getFilterOnlyIds()).setUseAutoFilters(true).build();
final IView view = viewsRepo.createView(request);
//
// Fetch result if requested
final ViewResult result;
if (jsonRequest.getQueryPageLength() > 0) {
final List<DocumentQueryOrderBy> orderBys = ImmutableList.of();
result = view.getPage(jsonRequest.getQueryFirstRow(), jsonRequest.getQueryPageLength(), orderBys);
} else {
result = ViewResult.ofView(view);
}
final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view);
return JSONViewResult.of(result, rowOverrides, userSession.getAD_Language());
}
Aggregations