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

knowledgepixels / nanodash / 17320701451

29 Aug 2025 09:55AM UTC coverage: 12.02% (+0.01%) from 12.007%
17320701451

push

github

ashleycaselli
refactor: minor code style update

330 of 3842 branches covered (8.59%)

Branch coverage included in aggregate %.

950 of 6807 relevant lines covered (13.96%)

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

3
import com.knowledgepixels.nanodash.ApiCache;
4
import com.knowledgepixels.nanodash.Utils;
5
import com.knowledgepixels.nanodash.component.NanopubResults;
6
import com.knowledgepixels.nanodash.component.TitleBar;
7
import org.apache.wicket.ajax.AjaxRequestTarget;
8
import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
9
import org.apache.wicket.markup.html.basic.Label;
10
import org.apache.wicket.markup.html.link.ExternalLink;
11
import org.apache.wicket.request.flow.RedirectToUrlException;
12
import org.apache.wicket.request.mapper.parameter.PageParameters;
13
import org.eclipse.rdf4j.model.IRI;
14
import org.nanopub.extra.services.ApiResponse;
15

16
import java.util.HashMap;
17
import java.util.Map;
18
import java.util.Optional;
19

20
/**
21
 * Page that displays all nanopublications of a specific type.
22
 */
23
public class TypePage extends NanodashPage {
24

25
    private static final long serialVersionUID = 1L;
26

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

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

40
    private IRI typeIri;
41
    private boolean added = false;
×
42

43
    /**
44
     * Constructor for the TypePage.
45
     *
46
     * @param parameters Page parameters containing the type IRI.
47
     */
48
    public TypePage(final PageParameters parameters) {
49
        super(parameters);
×
50

51
        if (parameters.get("id") == null) throw new RedirectToUrlException(HomePage.MOUNT_PATH);
×
52
        typeIri = Utils.vf.createIRI(parameters.get("id").toString());
×
53

54
        add(new TitleBar("titlebar", this, null));
×
55

56
        final String displayName = Utils.getTypeLabel(typeIri);
×
57
        add(new Label("pagetitle", displayName + " (type) | nanodash"));
×
58
        add(new Label("type", displayName));
×
59

60
        add(new ExternalLink("urilink", typeIri.stringValue(), typeIri.stringValue()));
×
61

62
        refresh();
×
63
    }
×
64

65
    /**
66
     * <p>hasAutoRefreshEnabled.</p>
67
     *
68
     * @return a boolean
69
     */
70
    protected boolean hasAutoRefreshEnabled() {
71
        return true;
×
72
    }
73

74
    private synchronized void refresh() {
75
        if (added) {
×
76
            remove("nanopubs");
×
77
        }
78
        added = true;
×
79
        final Map<String, String> params = new HashMap<>();
×
80
        params.put("type", typeIri.stringValue());
×
81
        final String queryName = "get-latest-nanopubs-by-type";
×
82
        ApiResponse cachedResponse = ApiCache.retrieveResponse(queryName, params);
×
83
        if (cachedResponse != null) {
×
84
            add(NanopubResults.fromApiResponse("nanopubs", cachedResponse));
×
85
        } else {
86
            add(new AjaxLazyLoadPanel<NanopubResults>("nanopubs") {
×
87

88
                private static final long serialVersionUID = 1L;
89

90
                @Override
91
                public NanopubResults getLazyLoadComponent(String markupId) {
92
                    ApiResponse r = null;
×
93
                    while (true) {
94
                        try {
95
                            Thread.sleep(500);
×
96
                        } catch (InterruptedException ex) {
×
97
                            ex.printStackTrace();
×
98
                        }
×
99
                        if (!ApiCache.isRunning(queryName, params)) {
×
100
                            r = ApiCache.retrieveResponse(queryName, params);
×
101
                            if (r != null) break;
×
102
                        }
103
                    }
104
                    return NanopubResults.fromApiResponse(markupId, r);
×
105
                }
106

107
                @Override
108
                protected void onContentLoaded(NanopubResults content, Optional<AjaxRequestTarget> target) {
109
                    super.onContentLoaded(content, target);
×
110
                    if (target.isPresent()) {
×
111
                        target.get().appendJavaScript("updateElements();");
×
112
                    }
113
                }
×
114

115
            });
116
        }
117
    }
×
118

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