use of de.metas.ui.web.window.datatypes.json.JSONOptions in project metasfresh-webui-api by metasfresh.
the class DashboardRestController method getKPIsAvailableToAdd.
@GetMapping("/kpis/available")
public List<JsonKPI> getKPIsAvailableToAdd(@RequestParam(name = "firstRow", required = false, defaultValue = "0") final int firstRow, @RequestParam(name = "pageLength", required = false, defaultValue = "0") final int pageLength) {
userSession.assertLoggedIn();
final Collection<KPI> kpis = userDashboardRepo.getKPIsAvailableToAdd();
final JSONOptions jsonOpts = newJSONOpts();
return kpis.stream().map(kpi -> JsonKPI.of(kpi, jsonOpts)).sorted(Comparator.comparing(JsonKPI::getCaption)).skip(firstRow >= 0 ? firstRow : 0).limit(pageLength > 0 ? pageLength : Integer.MAX_VALUE).collect(ImmutableList.toImmutableList());
}
use of de.metas.ui.web.window.datatypes.json.JSONOptions in project metasfresh-webui-api by metasfresh.
the class BoardRestController method getNewCardsViewLayout.
@GetMapping("/{boardId}/newCardsView/layout")
public JSONNewCardsViewLayout getNewCardsViewLayout(@PathVariable("boardId") final int boardId) {
userSession.assertLoggedIn();
final BoardDescriptor boardDescriptor = boardsRepo.getBoardDescriptor(boardId);
final ViewLayout documentsViewLayout = viewsRepo.getViewLayout(boardDescriptor.getDocumentWindowId(), JSONViewDataType.list, ViewProfileId.NULL);
final JSONOptions jsonOpts = newJSONOptions();
final String adLanguage = jsonOpts.getAD_Language();
return JSONNewCardsViewLayout.builder().caption(documentsViewLayout.getCaption(adLanguage)).description(documentsViewLayout.getDescription(adLanguage)).emptyResultHint(documentsViewLayout.getEmptyResultHint(adLanguage)).emptyResultText(documentsViewLayout.getEmptyResultText(adLanguage)).filters(JSONDocumentFilterDescriptor.ofCollection(documentsViewLayout.getFilters(), jsonOpts)).orderBys(boardDescriptor.getCardFields().stream().map(cardField -> JSONBoardCardOrderBy.builder().fieldName(cardField.getFieldName()).caption(cardField.getCaption().translate(adLanguage)).build()).collect(ImmutableList.toImmutableList())).build();
}
Aggregations