Skip to content

Package: DefaultMenuViewController

DefaultMenuViewController

nameinstructionbranchcomplexitylinemethod
DefaultMenuViewController(MenuView, SiteNode)
M: 0 C: 17
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$renderView$0(Site, ResourcePath)
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$renderView$1(Site, String)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
lambda$renderView$2(Site, SiteNode)
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
renderView(RenderContext)
M: 0 C: 50
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.frontend.ui.component.menu;
28:
29: import javax.annotation.Nonnull;
30: import org.springframework.context.annotation.Scope;
31: import it.tidalwave.northernwind.core.model.SiteNode;
32: import it.tidalwave.northernwind.frontend.ui.RenderContext;
33: import lombok.RequiredArgsConstructor;
34: import lombok.extern.slf4j.Slf4j;
35: import static java.util.Collections.emptyList;
36: import static it.tidalwave.northernwind.core.model.Content.P_TITLE;
37: import static it.tidalwave.northernwind.core.model.SiteNode.*;
38: import static it.tidalwave.northernwind.frontend.ui.component.Properties.P_TEMPLATE_PATH;
39:
40: /***********************************************************************************************************************
41: *
42: * The default implementation of {@link MenuViewController}.
43: *
44: * @author Fabrizio Giudici
45: *
46: **********************************************************************************************************************/
47: @RequiredArgsConstructor @Scope("session") @Slf4j
48: public class DefaultMenuViewController implements MenuViewController
49: {
50: @Nonnull
51: protected final MenuView view;
52:
53: @Nonnull
54: protected final SiteNode siteNode;
55:
56: /*******************************************************************************************************************
57: *
58: * {@inheritDoc}
59: *
60: ******************************************************************************************************************/
61: @Override
62: public void renderView (@Nonnull final RenderContext context)
63: {
64: final var site = siteNode.getSite();
65: final var viewProperties = siteNode.getPropertyGroup(view.getId());
66: viewProperties.getProperty(P_TITLE).ifPresent(view::setTitle);
67: viewProperties.getProperty(P_TEMPLATE_PATH).flatMap(p -> site.getTemplate(getClass(), p))
68: .ifPresent(view::setTemplate);
69:
70: viewProperties.getProperty(P_LINKS).orElse(emptyList())
71: .stream()
72: .flatMap(path -> site.find(_SiteNode_).withRelativePath(path).stream())
73: .forEach(node -> view.addLink(node.getProperty(P_NAVIGATION_LABEL).orElse("no nav. label"), // FIXME
74: site.createLink(node.getRelativeUri())));
75: }
76: }