• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 19963316244

05 Dec 2025 12:43PM UTC coverage: 15.37% (+0.2%) from 15.197%
19963316244

push

github

tkuhn
Merge branch 'master' of github.com:knowledgepixels/nanodash

593 of 4972 branches covered (11.93%)

Branch coverage included in aggregate %.

1567 of 9081 relevant lines covered (17.26%)

0.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/page/MaintainedResourcePage.java
1
package com.knowledgepixels.nanodash.page;
2

3
import com.knowledgepixels.nanodash.MaintainedResource;
4
import com.knowledgepixels.nanodash.NanodashPageRef;
5
import com.knowledgepixels.nanodash.ProfiledResource;
6
import com.knowledgepixels.nanodash.Space;
7
import com.knowledgepixels.nanodash.component.ButtonList;
8
import com.knowledgepixels.nanodash.component.TitleBar;
9
import com.knowledgepixels.nanodash.component.ViewList;
10
import org.apache.wicket.Component;
11
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
12
import org.apache.wicket.markup.html.basic.Label;
13
import org.apache.wicket.markup.html.link.AbstractLink;
14
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
15
import org.apache.wicket.model.Model;
16
import org.apache.wicket.request.mapper.parameter.PageParameters;
17

18
import java.util.ArrayList;
19
import java.util.List;
20

21
/**
22
 * This class represents a page for a maintained resource.
23
 */
24
public class MaintainedResourcePage extends NanodashPage {
25

26
    /**
27
     * The mount path for this page.
28
     */
29
    public static final String MOUNT_PATH = "/resource";
30

31
    /**
32
     * {@inheritDoc}
33
     */
34
    @Override
35
    public String getMountPath() {
36
        return MOUNT_PATH;
×
37
    }
38

39
    /**
40
     * Maintained resource object with the data shown on this page.
41
     */
42
    private final MaintainedResource resource;
43

44
    public MaintainedResourcePage(final PageParameters parameters) {
45
        super(parameters);
×
46

47
        resource = MaintainedResource.get(parameters.get("id").toString());
×
48
        Space space = resource.getSpace();
×
49

50
        List<ProfiledResource> superSpaces = resource.getAllSuperSpacesUntilRoot();
×
51
        superSpaces.add(resource.getSpace());
×
52
        superSpaces.add(resource);
×
53
        add(new TitleBar("titlebar", this, null,
×
54
                superSpaces.stream().map(ss -> new NanodashPageRef(SpacePage.class, new PageParameters().add("id", ss.getId()), ss.getLabel())).toArray(NanodashPageRef[]::new)
×
55
        ));
56

57
        add(new Label("pagetitle", resource.getLabel() + " (resource) | nanodash"));
×
58
        add(new Label("resourcename", resource.getLabel()));
×
59
        add(new BookmarkablePageLink<Void>("id", ExplorePage.class, parameters.set("label", resource.getLabel())).setBody(Model.of(resource.getId())));
×
60
        add(new BookmarkablePageLink<Void>("np", ExplorePage.class, new PageParameters().set("id", resource.getNanopubId())));
×
61

62
        String namespaceUri = resource.getNamespace() == null ? "" : resource.getNamespace();
×
63
        add(new BookmarkablePageLink<Void>("namespace", ExplorePage.class, new PageParameters().set("id", namespaceUri)).setBody(Model.of(namespaceUri)));
×
64

65
        final List<AbstractLink> viewButtons = new ArrayList<>();
×
66
        AbstractLink addViewButton = new BookmarkablePageLink<NanodashPage>("button", PublishPage.class, new PageParameters()
×
67
                .set("template", "https://w3id.org/np/RAPxKWDTDP4neVtRckQcTqKHqCC_GHWWPrs7DESb2BJjo")
×
68
                .set("template-version", "latest")
×
69
                .set("param_resource", resource.getId())
×
70
                .set("param_appliesToResource", resource.getId())
×
71
                .set("context", resource.getId())
×
72
        );
73
        addViewButton.setBody(Model.of("+ view"));
×
74
        viewButtons.add(addViewButton);
×
75

76
        if (resource.isDataInitialized()) {
×
77
            add(new ViewList("views", resource));
×
78
            add(new ButtonList("view-buttons", space, null, null, viewButtons));
×
79
        } else {
80
            add(new AjaxLazyLoadPanel<Component>("views") {
×
81

82
                @Override
83
                public Component getLazyLoadComponent(String markupId) {
84
                    return new ViewList(markupId, resource);
×
85
                }
86

87
                @Override
88
                protected boolean isContentReady() {
89
                    return resource.isDataInitialized();
×
90
                }
91

92
            });
93
            add(new AjaxLazyLoadPanel<Component>("view-buttons") {
×
94

95
                @Override
96
                public Component getLazyLoadComponent(String markupId) {
97
                    return new ButtonList(markupId, space, null, null, viewButtons);
×
98
                }
99

100
                @Override
101
                protected boolean isContentReady() {
102
                    return resource.isDataInitialized();
×
103
                }
104

105
                public Component getLoadingComponent(String id) {
106
                    return new Label(id).setVisible(false);
×
107
                }
108

109
            });
110
        }
111
    }
×
112

113
    /**
114
     * Checks if auto-refresh is enabled for this page.
115
     *
116
     * @return true if auto-refresh is enabled, false otherwise
117
     */
118
    protected boolean hasAutoRefreshEnabled() {
119
        return true;
×
120
    }
121

122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc