Search in sources :

Example 1 with JSONViewResult

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());
}
Also used : JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 2 with JSONViewResult

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));
}
Also used : ViewResult(de.metas.ui.web.view.ViewResult) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 3 with JSONViewResult

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);
}
Also used : IViewRowOverrides(de.metas.ui.web.view.IViewRowOverrides) ViewResult(de.metas.ui.web.view.ViewResult) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult)

Example 4 with JSONViewResult

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());
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) JSONCreateViewRequest(de.metas.ui.web.view.json.JSONCreateViewRequest) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

JSONViewResult (de.metas.ui.web.view.json.JSONViewResult)4 ViewResult (de.metas.ui.web.view.ViewResult)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 IViewRowOverrides (de.metas.ui.web.view.IViewRowOverrides)1 JSONCreateViewRequest (de.metas.ui.web.view.json.JSONCreateViewRequest)1 WindowId (de.metas.ui.web.window.datatypes.WindowId)1 DocumentQueryOrderBy (de.metas.ui.web.window.model.DocumentQueryOrderBy)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1