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

knowledgepixels / nanodash / 17518110100

06 Sep 2025 06:34PM UTC coverage: 11.955% (-0.1%) from 12.094%
17518110100

push

github

tkuhn
Undo custom AjaxLazyLoadPanel to fix paging navigation

334 of 3876 branches covered (8.62%)

Branch coverage included in aggregate %.

958 of 6931 relevant lines covered (13.82%)

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 java.util.HashMap;
4
import java.util.Map;
5
import java.util.Optional;
6

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
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
17

18
import com.knowledgepixels.nanodash.ApiCache;
19
import com.knowledgepixels.nanodash.Utils;
20
import com.knowledgepixels.nanodash.component.NanopubResults;
21
import com.knowledgepixels.nanodash.component.TitleBar;
22

23
/**
24
 * Page that displays all nanopublications of a specific type.
25
 */
26
public class TypePage extends NanodashPage {
27

28
    private static final long serialVersionUID = 1L;
29

30
    /**
31
     * The mount path for this page.
32
     */
33
    public static final String MOUNT_PATH = "/type";
34

35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    public String getMountPath() {
40
        return MOUNT_PATH;
×
41
    }
42

43
    private IRI typeIri;
44
    private boolean added = false;
×
45
    private static final Logger logger = LoggerFactory.getLogger(TypePage.class);
×
46

47
    /**
48
     * Constructor for the TypePage.
49
     *
50
     * @param parameters Page parameters containing the type IRI.
51
     */
52
    public TypePage(final PageParameters parameters) {
53
        super(parameters);
×
54

55
        if (parameters.get("id") == null) throw new RedirectToUrlException(HomePage.MOUNT_PATH);
×
56
        typeIri = Utils.vf.createIRI(parameters.get("id").toString());
×
57

58
        add(new TitleBar("titlebar", this, null));
×
59

60
        final String displayName = Utils.getTypeLabel(typeIri);
×
61
        add(new Label("pagetitle", displayName + " (type) | nanodash"));
×
62
        add(new Label("type", displayName));
×
63

64
        add(new ExternalLink("urilink", typeIri.stringValue(), typeIri.stringValue()));
×
65

66
        refresh();
×
67
    }
×
68

69
    /**
70
     * <p>hasAutoRefreshEnabled.</p>
71
     *
72
     * @return a boolean
73
     */
74
    protected boolean hasAutoRefreshEnabled() {
75
        return true;
×
76
    }
77

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

92
                private static final long serialVersionUID = 1L;
93

94
                @Override
95
                public NanopubResults getLazyLoadComponent(String markupId) {
96
                    ApiResponse r = null;
×
97
                    while (true) {
98
                        try {
99
                            Thread.sleep(500);
×
100
                        } catch (InterruptedException ex) {
×
101
                            logger.error("Interrupted while waiting for API response", ex);
×
102
                        }
×
103
                        if (!ApiCache.isRunning(queryName, params)) {
×
104
                            r = ApiCache.retrieveResponse(queryName, params);
×
105
                            if (r != null) break;
×
106
                        }
107
                    }
108
                    return NanopubResults.fromApiResponse(markupId, r);
×
109
                }
110

111
                @Override
112
                protected void onContentLoaded(NanopubResults content, Optional<AjaxRequestTarget> target) {
113
                    super.onContentLoaded(content, target);
×
114
                    if (target.isPresent()) {
×
115
                        target.get().appendJavaScript("updateElements();");
×
116
                    }
117
                }
×
118

119
            });
120
        }
121
    }
×
122

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