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

knowledgepixels / nanodash / 23528008920

25 Mar 2026 06:26AM UTC coverage: 16.386% (+0.004%) from 16.382%
23528008920

push

github

tkuhn
fix: read 'label' URL parameter on ResourcePartPage

The label param was ignored — the page always derived the label from
the resource ID. Now it uses the URL parameter when provided, falling
back to the ID-derived label otherwise.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

751 of 5639 branches covered (13.32%)

Branch coverage included in aggregate %.

1900 of 10539 relevant lines covered (18.03%)

2.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.89
src/main/java/com/knowledgepixels/nanodash/component/ApiResultComponent.java
1
package com.knowledgepixels.nanodash.component;
2

3
import org.apache.wicket.Component;
4
import org.apache.wicket.markup.html.basic.Label;
5
import org.nanopub.extra.services.ApiResponse;
6
import org.nanopub.extra.services.QueryRef;
7
import org.slf4j.Logger;
8
import org.slf4j.LoggerFactory;
9

10
import com.knowledgepixels.nanodash.ApiCache;
11

12
/**
13
 * A component that retrieves and displays the result of an API call.
14
 * It uses AjaxLazyLoadPanel to load the content lazily and shows a loading indicator while waiting for the response.
15
 */
16
public abstract class ApiResultComponent extends ResultComponent {
17

18
    private final QueryRef queryRef;
19
    private ApiResponse response = null;
9✔
20
    private static final Logger logger = LoggerFactory.getLogger(ApiResultComponent.class);
12✔
21

22
    /**
23
     * Constructor for ApiResultComponent using a QueryRef object.
24
     *
25
     * @param id       the component id
26
     * @param queryRef the QueryRef object containing the query name and parameters
27
     */
28
    public ApiResultComponent(String id, QueryRef queryRef) {
29
        super(id);
9✔
30
        this.queryRef = queryRef;
9✔
31
    }
3✔
32

33
    /**
34
     * {@inheritDoc}
35
     */
36
    private static final long LAZY_LOAD_TIMEOUT_MS = 60_000;
37

38
    @Override
39
    public Component getLazyLoadComponent(String markupId) {
40
        long deadline = System.currentTimeMillis() + LAZY_LOAD_TIMEOUT_MS;
12✔
41
        while (System.currentTimeMillis() < deadline) {
12!
42
            if (!ApiCache.isRunning(queryRef)) {
12✔
43
                try {
44
                    response = ApiCache.retrieveResponseAsync(queryRef);
15✔
45
                    if (response != null) break;
12✔
46
                } catch (Exception ex) {
×
47
                    return new Label(markupId, "<span class=\"negative\">API call failed.</span>").setEscapeModelStrings(false);
×
48
                }
3✔
49
            }
50
            try {
51
                Thread.sleep(100);
6✔
52
            } catch (InterruptedException ex) {
×
53
                Thread.currentThread().interrupt();
×
54
                logger.error("Interrupted while waiting for API response", ex);
×
55
                break;
×
56
            }
3✔
57
        }
58
        if (response == null) {
9!
59
            logger.error("Timed out waiting for API response for {}", queryRef);
×
60
            return new Label(markupId, "<span class=\"negative\">Loading timed out. Please reload the page.</span>").setEscapeModelStrings(false);
×
61
        }
62
        return getApiResultComponent(markupId, response);
18✔
63
    }
64

65
    /**
66
     * {@inheritDoc}
67
     */
68
    @Override
69
    protected boolean isContentReady() {
70
        return response != null || !ApiCache.isRunning(queryRef);
18!
71
    }
72

73
    /**
74
     * Abstract method to be implemented by subclasses to provide the component that displays the API result.
75
     *
76
     * @param markupId the markup ID for the component
77
     * @param response the API response to display
78
     * @return a Component that displays the API result
79
     */
80
    // TODO Use lambda instead of abstract method?
81
    public abstract Component getApiResultComponent(String markupId, ApiResponse response);
82

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