use of de.metas.ui.web.menu.datatypes.json.JSONPatchMenuNodeRequest in project metasfresh-webui-api by metasfresh.
the class MenuRestController method patchNode.
@PatchMapping("/node/{nodeId}")
public List<JSONMenuNode> patchNode(@PathVariable(PARAM_NodeId) final String nodeId, @RequestBody final List<JSONDocumentChangedEvent> events) {
userSession.assertLoggedIn();
final JSONPatchMenuNodeRequest request = JSONPatchMenuNodeRequest.ofChangeEvents(events);
final MenuTree menuTree = getMenuTree();
final MenuNode node = menuTree.getNodeById(nodeId);
final LinkedHashMap<String, MenuNode> changedMenuNodesById = new LinkedHashMap<>();
if (request.getFavorite() != null) {
menuTreeRepository.setFavorite(node, request.getFavorite());
menuTree.streamNodesByAD_Menu_ID(node.getAD_Menu_ID()).forEach(changedNode -> changedMenuNodesById.put(changedNode.getId(), changedNode));
}
return JSONMenuNode.ofList(changedMenuNodesById.values(), menuTreeRepository);
}
Aggregations