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

knowledgepixels / nanodash / 17837235071

18 Sep 2025 05:58PM UTC coverage: 13.87%. Remained the same
17837235071

push

github

tkuhn
chore: Remove serialVersionUIDs

443 of 4022 branches covered (11.01%)

Branch coverage included in aggregate %.

1133 of 7341 relevant lines covered (15.43%)

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/component/StatusLine.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.github.jsonldjava.shaded.com.google.common.base.Charsets;
4
import net.trustyuri.TrustyUriUtils;
5
import org.apache.wicket.Component;
6
import org.apache.wicket.markup.html.basic.Label;
7
import org.apache.wicket.markup.html.panel.Panel;
8
import org.nanopub.extra.services.ApiResponse;
9
import org.nanopub.extra.services.ApiResponseEntry;
10

11
import java.net.URLEncoder;
12
import java.util.ArrayList;
13
import java.util.List;
14

15
/**
16
 * A component that displays the status of a nanopublication.
17
 */
18
public class StatusLine extends Panel {
19

20
    /**
21
     * Creates a new StatusLine component.
22
     *
23
     * @param markupId the Wicket markup ID for this component
24
     * @param npId     the nanopublication ID to check for newer versions
25
     * @return a new StatusLine component
26
     */
27
    public static Component createComponent(String markupId, String npId) {
28
        // TODO Use the query cache here but with quicker refresh interval?
29
        ApiResultComponent c = new ApiResultComponent("statusline", "get-newer-versions-of-np", "np", npId) {
×
30

31
            @Override
32
            public Component getApiResultComponent(String markupId, ApiResponse response) {
33
                return new StatusLine(markupId, npId, response);
×
34
            }
35

36
        };
37
        c.setWaitComponentHtml("<h4>Status</h4><div>" + ApiResultComponent.getWaitIconHtml() + "</div>");
×
38
        return c;
×
39
    }
40

41
    /**
42
     * Constructs a StatusLine component with the given markup ID, nanopublication ID, and API response.
43
     *
44
     * @param markupId the Wicket markup ID for this component
45
     * @param npId     the nanopublication ID to check for newer versions
46
     * @param response the API response containing data about newer versions or retractions
47
     */
48
    public StatusLine(String markupId, String npId, ApiResponse response) {
49
        super(markupId);
×
50
        List<String> latest = new ArrayList<>();
×
51
        List<String> retractions = new ArrayList<>();
×
52
        for (ApiResponseEntry e : response.getData()) {
×
53
            String newerVersion = e.get("newerVersion");
×
54
            String retractedBy = e.get("retractedBy");
×
55
            String supersededBy = e.get("supersededBy");
×
56
            if (retractedBy.isEmpty() && supersededBy.isEmpty()) {
×
57
                latest.add(newerVersion);
×
58
            } else if (!retractedBy.isEmpty() && supersededBy.isEmpty()) {
×
59
                retractions.add(retractedBy);
×
60
            }
61
        }
×
62
        String text = null;
×
63
        // TODO Improve HTML/link generation below (do it with Wicket Java code):
64
        if (latest.isEmpty() && retractions.isEmpty()) {
×
65
            text = "<em>This nanopublication doesn't seem to be properly published (yet). This can take a minute or two for new nanopublications.</em>";
×
66
        } else if (latest.size() == 1) {
×
67
            String l = latest.getFirst();
×
68
            if (l.equals(npId)) {
×
69
                text = "This is the latest version.";
×
70
            } else {
71
                text = "This nanopublication has a <strong>newer version</strong>: " + getLink(l);
×
72
            }
73
        } else if (latest.size() > 1) {
×
74
            text = "This nanopublication has <strong>newer versions</strong>:";
×
75
            for (String l : latest) {
×
76
                text += " " + getLink(l);
×
77
            }
×
78
        } else {
79
            text = "This nanopublication has been <strong>retracted</strong>:";
×
80
            for (String r : retractions) {
×
81
                text += " " + getLink(r);
×
82
            }
×
83
        }
84
        add(new Label("statusline", text).setEscapeModelStrings(false));
×
85
    }
×
86

87
    private static String getLink(String npId) {
88
        String shortLabel = TrustyUriUtils.getArtifactCode(npId).substring(0, 10);
×
89
        String encodedLink = URLEncoder.encode(npId, Charsets.UTF_8);
×
90
        return "<a href=\"/explore?id=" + encodedLink + "\">" + shortLabel + "</a>";
×
91
    }
92

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