Skip to content

Commit

Permalink
Provide Endpoint w/ entry selections for given Breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Jun 22, 2017
1 parent 18dbcf0 commit 6fa6d63
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/main/java/de/metas/ui/web/menu/MenuRestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.google.common.collect.ImmutableList;

import de.metas.ui.web.config.WebConfig;
import de.metas.ui.web.menu.datatypes.json.JSONMenuNode;
import de.metas.ui.web.menu.datatypes.json.JSONMenuNodeType;
import de.metas.ui.web.menu.datatypes.json.JSONPatchMenuNodeRequest;
import de.metas.ui.web.menu.exception.NoMenuNodesFoundException;
import de.metas.ui.web.session.UserSession;
import de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/*
Expand Down Expand Up @@ -123,17 +126,6 @@ public JSONMenuNode getNode(
.build();
}

@GetMapping("/node")
@Deprecated
public JSONMenuNode getNode_OLD(
@RequestParam(name = PARAM_NodeId, required = true) final String nodeId //
, @RequestParam(name = PARAM_Depth, required = false, defaultValue = "1") final int depth //
, @RequestParam(name = PARAM_ChildrenLimit, required = false, defaultValue = "0") final int childrenLimit //
)
{
return getNode(nodeId, depth, childrenLimit);
}

@PatchMapping("/node/{nodeId}")
public List<JSONMenuNode> patchNode(@PathVariable(PARAM_NodeId) final String nodeId, @RequestBody List<JSONDocumentChangedEvent> events)
{
Expand All @@ -156,6 +148,7 @@ public List<JSONMenuNode> patchNode(@PathVariable(PARAM_NodeId) final String nod
return JSONMenuNode.ofList(changedMenuNodesById.values(), menuTreeRepository);
}

@ApiOperation("Gets node's path (from root node) ")
@GetMapping("/node/{nodeId}/path")
public JSONMenuNode getPath(
@PathVariable(PARAM_NodeId) final String nodeId,
Expand All @@ -171,14 +164,19 @@ public JSONMenuNode getPath(
return JSONMenuNode.ofPath(path, skipRootNode, includeLastNode, menuTreeRepository);
}

@GetMapping("/path")
@Deprecated
public JSONMenuNode getPath_OLD(
@RequestParam(name = PARAM_NodeId, required = true) final String nodeId //
, @RequestParam(name = PARAM_IncludeLastNode, required = false, defaultValue = "false") @ApiParam("Shall we include the last node") final boolean includeLastNode //
)
@ApiOperation("Gets breadcrumb menu to be displayed when user clicks on that node in the breadcrumb")
@GetMapping("/node/{nodeId}/breadcrumbMenu")
public List<JSONMenuNode> getNodeBreadcrumbMenu(@PathVariable(PARAM_NodeId) final String nodeId)
{
return getPath(nodeId, includeLastNode);
userSession.assertLoggedIn();

final List<MenuNode> children = getMenuTree().getNodeById(nodeId)
.getChildren()
.stream()
.filter(child -> child.isEffectiveLeafNode())
.collect(ImmutableList.toImmutableList());

return JSONMenuNode.ofList(children, menuTreeRepository);
}

@GetMapping("/elementPath")
Expand Down

0 comments on commit 6fa6d63

Please sign in to comment.