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

knowledgepixels / nanodash / 22618039211

03 Mar 2026 10:05AM UTC coverage: 16.058% (+0.2%) from 15.884%
22618039211

Pull #365

github

web-flow
Merge 1e7e700f0 into a8c4b4a77
Pull Request #365: Refactor of `ResourceWithProfile` and related classes

699 of 5287 branches covered (13.22%)

Branch coverage included in aggregate %.

1721 of 9783 relevant lines covered (17.59%)

2.41 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.NanodashPageRef;
4
import com.knowledgepixels.nanodash.component.*;
5
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
6
import com.knowledgepixels.nanodash.domain.MaintainedResource;
7
import com.knowledgepixels.nanodash.domain.Space;
8
import com.knowledgepixels.nanodash.repository.MaintainedResourceRepository;
9
import org.apache.wicket.Component;
10
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
11
import org.apache.wicket.markup.html.basic.Label;
12
import org.apache.wicket.markup.html.link.AbstractLink;
13
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
14
import org.apache.wicket.model.Model;
15
import org.apache.wicket.request.mapper.parameter.PageParameters;
16
import org.eclipse.rdf4j.model.util.Values;
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 = MaintainedResourceRepository.get().findById(parameters.get("id").toString());
×
48
        Space space = resource.getSpace();
×
49
        resource.triggerDataUpdate();
×
50

51
        List<AbstractResourceWithProfile> 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 JustPublishedMessagePanel("justPublishedMessage", parameters));
×
59

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

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

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

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

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

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

95
                @Override
96
                public Component getLoadingComponent(String id) {
97
                    return new Label(id, "<div class=\"row-section\"><div class=\"col-12\">" + ResultComponent.getWaitIconHtml() + "</div></div>").setEscapeModelStrings(false);
×
98
                }
99

100
            });
101
        }
102
    }
×
103

104
    /**
105
     * Checks if auto-refresh is enabled for this page.
106
     *
107
     * @return true if auto-refresh is enabled, false otherwise
108
     */
109
    protected boolean hasAutoRefreshEnabled() {
110
        return true;
×
111
    }
112

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