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

knowledgepixels / nanodash / 28899187612

07 Jul 2026 09:14PM UTC coverage: 28.105% (-0.4%) from 28.465%
28899187612

Pull #543

github

web-flow
Merge 39c9ede0f into f1a7efda7
Pull Request #543: feat: query-form views (gen:QueryFormView) with view-results page

1813 of 7309 branches covered (24.81%)

Branch coverage included in aggregate %.

3717 of 12367 relevant lines covered (30.06%)

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

3
import com.knowledgepixels.nanodash.ApiCache;
4
import com.knowledgepixels.nanodash.ViewDisplay;
5
import org.apache.wicket.behavior.AttributeAppender;
6
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
7
import org.apache.wicket.Component;
8
import org.nanopub.extra.services.ApiResponse;
9
import org.nanopub.extra.services.QueryRef;
10

11
import java.io.Serializable;
12

13
/**
14
 * Builder class for creating QueryResultItemList components.
15
 */
16
public class QueryResultItemListBuilder implements Serializable {
17

18
    private final String markupId;
19
    private final ViewDisplay viewDisplay;
20
    private String contextId = null;
×
21
    private final QueryRef queryRef;
22
    private AbstractResourceWithProfile resourceWithProfile = null;
×
23
    private AbstractResourceWithProfile pageResource = null;
×
24
    private String id = null;
×
25
    private String refRoot = null;
×
26

27
    private QueryResultItemListBuilder(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
×
28
        this.markupId = markupId;
×
29
        // Bind session-derived "magic" query parameters here on the request thread
30
        // (ApiCache fetches on background threads where the session is absent).
31
        this.queryRef = com.knowledgepixels.nanodash.MagicQueryParams.augment(queryRef);
×
32
        this.viewDisplay = viewDisplay;
×
33
    }
×
34

35
    public static QueryResultItemListBuilder create(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
36
        return new QueryResultItemListBuilder(markupId, queryRef, viewDisplay);
×
37
    }
38

39
    public QueryResultItemListBuilder contextId(String contextId) {
40
        this.contextId = contextId;
×
41
        return this;
×
42
    }
43

44
    public QueryResultItemListBuilder resourceWithProfile(AbstractResourceWithProfile resourceWithProfile) {
45
        this.resourceWithProfile = resourceWithProfile;
×
46
        return this;
×
47
    }
48

49
    public QueryResultItemListBuilder id(String id) {
50
        this.id = id;
×
51
        return this;
×
52
    }
53

54
    public QueryResultItemListBuilder pageResource(AbstractResourceWithProfile pageResource) {
55
        this.pageResource = pageResource;
×
56
        return this;
×
57
    }
58

59
    /**
60
     * Pins this list to a specific ref (root definition), so action visibility is gated
61
     * against that claimant's authority rather than the resource's representative ref.
62
     * Null leaves it on the representative ref.
63
     *
64
     * @param refRoot the ref's root nanopub, or null
65
     * @return the current QueryResultItemListBuilder instance
66
     */
67
    public QueryResultItemListBuilder refRoot(String refRoot) {
68
        this.refRoot = refRoot;
×
69
        return this;
×
70
    }
71

72
    public Component build() {
73
        ApiResponse response = ApiCache.retrieveResponseAsync(queryRef);
×
74
        String colClass = " col-" + viewDisplay.getDisplayWidth();
×
75
        if (response != null) {
×
76
            Component result = buildItemList(markupId, response);
×
77
            result.add(new AttributeAppender("class", colClass));
×
78
            return result;
×
79
        } else {
80
            ApiResultComponent comp = new ApiResultComponent(markupId, queryRef) {
×
81
                @Override
82
                public Component getApiResultComponent(String id, ApiResponse r) {
83
                    return buildItemList(id, r);
×
84
                }
85
            };
86
            comp.add(new AttributeAppender("class", colClass));
×
87
            return comp;
×
88
        }
89
    }
90

91
    private QueryResultItemList buildItemList(String markupId, ApiResponse response) {
92
        QueryResultItemList result = new QueryResultItemList(markupId, queryRef, response, viewDisplay);
×
93
        result.setContextId(contextId);
×
94
        result.setPageResource(pageResource);
×
95
        result.setResourceWithProfile(resourceWithProfile);
×
96
        result.setRefRoot(refRoot);
×
97
        ViewActionMappings.addResultActions(result, viewDisplay, queryRef, id, contextId, resourceWithProfile, refRoot);
×
98
        return result;
×
99
    }
100
}
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