Search in sources :

Example 1 with NoMenuNodesFoundException

use of de.metas.ui.web.menu.exception.NoMenuNodesFoundException in project metasfresh-webui-api by metasfresh.

the class MenuRestController method query.

@GetMapping("/queryPaths")
public JSONMenuNode query(@RequestParam(name = PARAM_NameQuery, required = true) final String nameQuery, @RequestParam(name = PARAM_ChildrenLimit, required = false, defaultValue = "0") final int childrenLimit, @RequestParam(name = "childrenInclusive", required = false, defaultValue = "false") @ApiParam("true if groups that were matched shall be populated with it's leafs, even if those leafs are not matching") final boolean includeLeafsIfGroupAccepted) {
    userSession.assertLoggedIn();
    final MenuNode rootFiltered = getMenuTree().filter(nameQuery, includeLeafsIfGroupAccepted);
    if (rootFiltered == null) {
        throw new NoMenuNodesFoundException();
    }
    if (rootFiltered.getChildren().isEmpty()) {
        throw new NoMenuNodesFoundException();
    }
    return JSONMenuNode.builder(rootFiltered).setMaxLeafNodes(childrenLimit).setIsFavoriteProvider(menuTreeRepository).build();
}
Also used : JSONMenuNode(de.metas.ui.web.menu.datatypes.json.JSONMenuNode) NoMenuNodesFoundException(de.metas.ui.web.menu.exception.NoMenuNodesFoundException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

JSONMenuNode (de.metas.ui.web.menu.datatypes.json.JSONMenuNode)1 NoMenuNodesFoundException (de.metas.ui.web.menu.exception.NoMenuNodesFoundException)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1