Search in sources :

Example 6 with JSONOptions

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());
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) JsonKPI(de.metas.ui.web.dashboard.json.JsonKPI) JsonKPI(de.metas.ui.web.dashboard.json.JsonKPI) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 7 with JSONOptions

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();
}
Also used : JSONNewCardsViewLayout(de.metas.ui.web.board.json.JSONNewCardsViewLayout) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) JSONDocumentFilterDescriptor(de.metas.ui.web.document.filter.json.JSONDocumentFilterDescriptor) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) ApiOperation(io.swagger.annotations.ApiOperation) IView(de.metas.ui.web.view.IView) Map(java.util.Map) ViewRowOverridesHelper(de.metas.ui.web.view.ViewRowOverridesHelper) IViewRowOverrides(de.metas.ui.web.view.IViewRowOverrides) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) JSONBoardCardOrderBy(de.metas.ui.web.board.json.JSONBoardCardOrderBy) ViewResult(de.metas.ui.web.view.ViewResult) PostMapping(org.springframework.web.bind.annotation.PostMapping) Predicate(java.util.function.Predicate) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) JSONBoardCardAddRequest(de.metas.ui.web.board.json.JSONBoardCardAddRequest) UserSession(de.metas.ui.web.session.UserSession) List(java.util.List) IViewsRepository(de.metas.ui.web.view.IViewsRepository) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) BoardCardChangeRequestBuilder(de.metas.ui.web.board.BoardCardChangeRequest.BoardCardChangeRequestBuilder) WebConfig(de.metas.ui.web.config.WebConfig) GuavaCollectors(org.adempiere.util.GuavaCollectors) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) Multimap(com.google.common.collect.Multimap) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) RequestBody(org.springframework.web.bind.annotation.RequestBody) JSONBoardCard(de.metas.ui.web.board.json.JSONBoardCard) ImmutableList(com.google.common.collect.ImmutableList) JSONBoardBuilder(de.metas.ui.web.board.json.JSONBoard.JSONBoardBuilder) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONFilterViewRequest(de.metas.ui.web.view.json.JSONFilterViewRequest) JSONBoard(de.metas.ui.web.board.json.JSONBoard) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) WeakHashMap(java.util.WeakHashMap) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ViewProfileId(de.metas.ui.web.view.ViewProfileId) AdempiereException(org.adempiere.exceptions.AdempiereException) FixedOrderByKeyComparator(org.adempiere.util.comparator.FixedOrderByKeyComparator) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) JSONBoardLane(de.metas.ui.web.board.json.JSONBoardLane) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) Collections(java.util.Collections) ViewId(de.metas.ui.web.view.ViewId) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) JSONNewCardsViewLayout(de.metas.ui.web.board.json.JSONNewCardsViewLayout) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

JSONOptions (de.metas.ui.web.window.datatypes.json.JSONOptions)7 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)2 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)2 JSONDocumentChangedEvent (de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent)2 ImmutableList (com.google.common.collect.ImmutableList)1 Multimap (com.google.common.collect.Multimap)1 BoardCardChangeRequestBuilder (de.metas.ui.web.board.BoardCardChangeRequest.BoardCardChangeRequestBuilder)1 JSONBoard (de.metas.ui.web.board.json.JSONBoard)1 JSONBoardBuilder (de.metas.ui.web.board.json.JSONBoard.JSONBoardBuilder)1 JSONBoardCard (de.metas.ui.web.board.json.JSONBoardCard)1 JSONBoardCardAddRequest (de.metas.ui.web.board.json.JSONBoardCardAddRequest)1 JSONBoardCardOrderBy (de.metas.ui.web.board.json.JSONBoardCardOrderBy)1 JSONBoardLane (de.metas.ui.web.board.json.JSONBoardLane)1 JSONNewCardsViewLayout (de.metas.ui.web.board.json.JSONNewCardsViewLayout)1 WebConfig (de.metas.ui.web.config.WebConfig)1 JsonKPI (de.metas.ui.web.dashboard.json.JsonKPI)1 JSONDocumentFilterDescriptor (de.metas.ui.web.document.filter.json.JSONDocumentFilterDescriptor)1 ASIDocument (de.metas.ui.web.pattribute.ASIDocument)1 ASILayout (de.metas.ui.web.pattribute.ASILayout)1