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

knowledgepixels / nanodash / 17611181855

10 Sep 2025 10:40AM UTC coverage: 14.17% (+0.1%) from 14.059%
17611181855

push

github

ashleycaselli
refactor: update API response retrieval using QueryRef

431 of 3880 branches covered (11.11%)

Branch coverage included in aggregate %.

1112 of 7009 relevant lines covered (15.87%)

0.7 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/HomePage.java
1
package com.knowledgepixels.nanodash.page;
2

3
import com.knowledgepixels.nanodash.*;
4
import com.knowledgepixels.nanodash.component.ApiResultComponent;
5
import com.knowledgepixels.nanodash.component.NanopubResults;
6
import com.knowledgepixels.nanodash.component.TitleBar;
7
import org.apache.wicket.Component;
8
import org.apache.wicket.markup.html.basic.Label;
9
import org.apache.wicket.request.mapper.parameter.PageParameters;
10
import org.nanopub.extra.services.ApiResponse;
11

12
/**
13
 * The home page of Nanodash, which shows the most recent nanopublications
14
 * and the latest accepted nanopublications.
15
 */
16
public class HomePage extends NanodashPage {
17

18
    private static final long serialVersionUID = 1L;
19

20
    /**
21
     * The mount path for this page.
22
     */
23
    public static final String MOUNT_PATH = "/";
24

25
    /**
26
     * {@inheritDoc}
27
     */
28
    @Override
29
    public String getMountPath() {
30
        return MOUNT_PATH;
×
31
    }
32

33
    /**
34
     * Constructor for the home page.
35
     *
36
     * @param parameters the page parameters
37
     */
38
    public HomePage(final PageParameters parameters) {
39
        super(parameters);
×
40

41
        add(new TitleBar("titlebar", this, null));
×
42
        final NanodashSession session = NanodashSession.get();
×
43
        String v = WicketApplication.getThisVersion();
×
44
        String lv = WicketApplication.getLatestVersion();
×
45
        if (NanodashPreferences.get().isOrcidLoginMode()) {
×
46
            add(new Label("warning", ""));
×
47
        } else if (v.endsWith("-SNAPSHOT")) {
×
48
            add(new Label("warning", "You are running a temporary snapshot version of Nanodash (" + v + "). The latest public version is " + lv + "."));
×
49
        } else if (lv != null && !v.equals(lv)) {
×
50
            add(new Label("warning", "There is a new version available: " + lv + ". You are currently using " + v + ". " +
×
51
                                     "Run 'update' (Unix/Mac) or 'update-under-windows.bat' (Windows) to update to the latest version, or manually download it " +
52
                                     "<a href=\"" + WicketApplication.LATEST_RELEASE_URL + "\">here</a>.").setEscapeModelStrings(false));
×
53
        } else {
54
            add(new Label("warning", ""));
×
55
        }
56
        if (NanodashPreferences.get().isReadOnlyMode()) {
×
57
            add(new Label("text", "This is a read-only instance, so you cannot publish new nanopublications here."));
×
58
        } else if (NanodashSession.get().isProfileComplete()) {
×
59
            add(new Label("text", ""));
×
60
        } else if (NanodashPreferences.get().isOrcidLoginMode() && session.getUserIri() == null) {
×
61
            String loginUrl = OrcidLoginPage.getOrcidLoginUrl(".");
×
62
            add(new Label("text", "In order to see your own nanopublications and publish new ones, <a href=\"" + loginUrl + "\">login to ORCID</a> first.").setEscapeModelStrings(false));
×
63
        } else {
×
64
            add(new Label("text", "Before you can start, you first need to <a href=\"" + ProfilePage.MOUNT_PATH + "\">complete your profile</a>.").setEscapeModelStrings(false));
×
65
        }
66

67
        setOutputMarkupId(true);
×
68

69
        final QueryRef rQueryRef = new QueryRef("get-most-recent-nanopubs");
×
70
        ApiResponse rResponse = ApiCache.retrieveResponse(rQueryRef);
×
71
        if (rResponse != null) {
×
72
            add(NanopubResults.fromApiResponse("mostrecent", rResponse));
×
73
        } else {
74
            add(new ApiResultComponent("mostrecent", rQueryRef) {
×
75

76
                private static final long serialVersionUID = 1L;
77

78
                @Override
79
                public Component getApiResultComponent(String markupId, ApiResponse response) {
80
                    return NanopubResults.fromApiResponse(markupId, response);
×
81
                }
82
            });
83

84
        }
85

86
        final QueryRef aQueryRef = new QueryRef("get-latest-accepted");
×
87
        ApiResponse aResponse = ApiCache.retrieveResponse(aQueryRef);
×
88
        if (aResponse != null) {
×
89
            add(NanopubResults.fromApiResponse("latestaccepted", aResponse));
×
90
        } else {
91
            add(new ApiResultComponent("latestaccepted", aQueryRef) {
×
92

93
                private static final long serialVersionUID = 1L;
94

95
                @Override
96
                public Component getApiResultComponent(String markupId, ApiResponse response) {
97
                    return NanopubResults.fromApiResponse(markupId, response);
×
98
                }
99
            });
100

101
        }
102

103
    }
×
104

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