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

knowledgepixels / nanodash / 20332936699

18 Dec 2025 09:53AM UTC coverage: 15.293% (+0.9%) from 14.405%
20332936699

push

github

tkuhn
fix(Space): Leaking Space objects fixed

592 of 5002 branches covered (11.84%)

Branch coverage included in aggregate %.

1577 of 9181 relevant lines covered (17.18%)

2.23 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
        resource.triggerDataUpdate();
×
50

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

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

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

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

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

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

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

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

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

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

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

111
            });
112
        }
113
    }
×
114

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

124
}
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