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

knowledgepixels / nanodash / 25725007728

12 May 2026 09:12AM UTC coverage: 20.478% (-0.03%) from 20.512%
25725007728

push

github

web-flow
Merge pull request #457 from knowledgepixels/fix-f5-form-state-singleton-ldm

fix: restore F5 form-state preservation via singleton LDMs (#456)

1013 of 6240 branches covered (16.23%)

Branch coverage included in aggregate %.

2591 of 11359 relevant lines covered (22.81%)

3.28 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.SpaceMemberRole;
5
import com.knowledgepixels.nanodash.component.*;
6
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
7
import com.knowledgepixels.nanodash.domain.MaintainedResource;
8
import com.knowledgepixels.nanodash.domain.Space;
9
import com.knowledgepixels.nanodash.repository.MaintainedResourceRepository;
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.BookmarkablePageLink;
14
import org.apache.wicket.model.IModel;
15
import org.apache.wicket.model.LoadableDetachableModel;
16
import org.apache.wicket.model.Model;
17
import org.apache.wicket.request.mapper.parameter.PageParameters;
18
import org.eclipse.rdf4j.model.util.Values;
19

20
import java.util.List;
21

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

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

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

40
    /**
41
     * Id of the maintained resource shown on this page. Only the id is held in
42
     * the page state; the {@link MaintainedResource} itself is re-fetched from
43
     * the repository on every render via {@link #resourceModel}, so the page
44
     * tree never carries a serialized snapshot of singleton data.
45
     */
46
    private final String resourceId;
47

48
    /**
49
     * LDM that resolves {@link #resourceId} to the live {@link MaintainedResource} singleton.
50
     */
51
    private final IModel<MaintainedResource> resourceModel;
52

53
    public MaintainedResourcePage(final PageParameters parameters) {
54
        super(parameters);
×
55

56
        MaintainedResource resource = MaintainedResourceRepository.get().findById(parameters.get("id").toString());
×
57
        resourceId = resource.getId();
×
58
        resourceModel = new LoadableDetachableModel<MaintainedResource>() {
×
59
            @Override
60
            protected MaintainedResource load() {
61
                return MaintainedResourceRepository.get().findById(resourceId);
×
62
            }
63
        };
64
        Space space = resource.getSpace();
×
65
        resource.triggerDataUpdate();
×
66

67
        List<AbstractResourceWithProfile> superSpaces = resource.getAllSuperSpacesUntilRoot();
×
68
        superSpaces.add(resource.getSpace());
×
69
        superSpaces.add(resource);
×
70
        add(new TitleBar("titlebar", this, null,
×
71
                superSpaces.stream().map(ss -> new NanodashPageRef(SpacePage.class, new PageParameters().add("id", ss.getId()), ss.getLabel())).toArray(NanodashPageRef[]::new)
×
72
        ));
73

74
        add(new JustPublishedMessagePanel("justPublishedMessage", parameters));
×
75

76
        add(new Label("pagetitle", resource.getLabel() + " (resource) | nanodash"));
×
77
        add(new Label("resourcename", resource.getLabel()));
×
78
        add(new ExternalLinkWithActionsPanel("id", Model.of(resource.getId()), Model.of(resource.getLabel()), Values.iri(resource.getNanopubId())));
×
79

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

83
        boolean isAdmin = SpaceMemberRole.isCurrentUserAdmin(space);
×
84
        add(new AddViewDisplayButton("addviewdisplay",
×
85
                "https://w3id.org/np/RAe0zantvnJlVWIC2LueG1IAMktXGFIqCdWliok1rOrmU",
86
                "latest",
87
                resource.getId(),
×
88
                resource.getId(),
×
89
                new PageParameters()
90
                        .set("param_appliesToResource", resource.getId())
×
91
                        .set("refresh-upon-publish", resource.getId())
×
92
        ).setVisible(isAdmin));
×
93
        add(new DownloadRdfLinks("download-rdf", "resource", resource.getId()));
×
94

95
        if (resource.isDataInitialized()) {
×
96
            add(new ViewList("views", resource));
×
97
        } else {
98
            add(new AjaxLazyLoadPanel<Component>("views") {
×
99

100
                @Override
101
                public Component getLazyLoadComponent(String markupId) {
102
                    return new ViewList(markupId, resourceModel.getObject());
×
103
                }
104

105
                @Override
106
                protected boolean isContentReady() {
107
                    return resourceModel.getObject().isDataInitialized();
×
108
                }
109

110
                @Override
111
                public Component getLoadingComponent(String id) {
112
                    return new Label(id, "<div class=\"row-section\"><div class=\"col-12\">" + ResultComponent.getWaitIconHtml() + "</div></div>").setEscapeModelStrings(false);
×
113
                }
114

115
            });
116
        }
117
    }
×
118

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

128
    /**
129
     * {@inheritDoc}
130
     */
131
    @Override
132
    protected void onDetach() {
133
        resourceModel.detach();
×
134
        super.onDetach();
×
135
    }
×
136

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