Search in sources :

Example 1 with JSONCreateViewRequest

use of de.metas.ui.web.view.json.JSONCreateViewRequest 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

JSONCreateViewRequest (de.metas.ui.web.view.json.JSONCreateViewRequest)1 JSONViewResult (de.metas.ui.web.view.json.JSONViewResult)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