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());
}
Aggregations