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

knowledgepixels / nanodash / 19261021659

11 Nov 2025 09:23AM UTC coverage: 13.77% (-0.004%) from 13.774%
19261021659

push

github

tkuhn
feat: Use latest templates for buttons on space/resource pages

514 of 4714 branches covered (10.9%)

Branch coverage included in aggregate %.

1333 of 8699 relevant lines covered (15.32%)

0.68 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 java.util.ArrayList;
4
import java.util.List;
5

6
import org.apache.wicket.Component;
7
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
8
import org.apache.wicket.markup.html.basic.Label;
9
import org.apache.wicket.markup.html.link.AbstractLink;
10
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
11
import org.apache.wicket.model.Model;
12
import org.apache.wicket.request.mapper.parameter.PageParameters;
13
import org.nanopub.extra.services.FailedApiCallException;
14

15
import com.knowledgepixels.nanodash.MaintainedResource;
16
import com.knowledgepixels.nanodash.Space;
17
import com.knowledgepixels.nanodash.component.ButtonList;
18
import com.knowledgepixels.nanodash.component.TitleBar;
19
import com.knowledgepixels.nanodash.component.ViewList;
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 MaintainedResource resource;
43

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

47
        resource = MaintainedResource.get(parameters.get("id").toString());
×
48

49
        add(new TitleBar("titlebar", this, "connectors"));
×
50

51
        add(new Label("pagetitle", resource.getLabel() + " (resource) | nanodash"));
×
52
        add(new Label("resourcename", resource.getLabel()));
×
53
        add(new BookmarkablePageLink<Void>("id", ExplorePage.class, parameters.set("label", resource.getLabel())).setBody(Model.of(resource.getId())));
×
54
        add(new BookmarkablePageLink<Void>("np", ExplorePage.class, new PageParameters().set("id", resource.getNanopubId())));
×
55

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

59
        Space space = resource.getSpace();
×
60
        add(new BookmarkablePageLink<Void>("space", SpacePage.class, new PageParameters().set("id", space.getId())).setBody(Model.of(space.getLabel())));
×
61

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

72
        if (resource.isDataInitialized()) {
×
73
            add(new ViewList("views", resource));
×
74
            add(new ButtonList("view-buttons", space, null, null, viewButtons));
×
75
        } else {
76
            add(new AjaxLazyLoadPanel<Component>("views") {
×
77
    
78
                @Override
79
                public Component getLazyLoadComponent(String markupId) {
80
                    return new ViewList(markupId, resource);
×
81
                }
82
    
83
                @Override
84
                protected boolean isContentReady() {
85
                    return resource.isDataInitialized();
×
86
                }
87
    
88
            });
89
            add(new AjaxLazyLoadPanel<Component>("view-buttons") {
×
90
    
91
                @Override
92
                public Component getLazyLoadComponent(String markupId) {
93
                    return new ButtonList(markupId, space, null, null, viewButtons);
×
94
                }
95
    
96
                @Override
97
                protected boolean isContentReady() {
98
                    return resource.isDataInitialized();
×
99
                }
100

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

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

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