• 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/QueryResultNanopubSetBuilder.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 QueryResultNanopubSet components.
15
 */
16
public class QueryResultNanopubSetBuilder 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 boolean hasTitle = true;
×
23
    private AbstractResourceWithProfile resourceWithProfile = null;
×
24
    private AbstractResourceWithProfile pageResource = null;
×
25
    private String id = null;
×
26
    private String refRoot = null;
×
27
    private Long itemsPerPage = null;
×
28

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

37
    /**
38
     * Creates a new QueryResultNanopubSetBuilder instance.
39
     *
40
     * @param markupId    the markup ID for the component
41
     * @param queryRef    the query reference
42
     * @param viewDisplay the view display
43
     * @return a new QueryResultNanopubSetBuilder instance
44
     */
45
    public static QueryResultNanopubSetBuilder create(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
46
        return new QueryResultNanopubSetBuilder(markupId, queryRef, viewDisplay);
×
47
    }
48

49
    /**
50
     * Sets the context ID for the QueryResultNanopubSet.
51
     *
52
     * @param contextId the context ID
53
     * @return the current QueryResultNanopubSetBuilder instance
54
     */
55
    public QueryResultNanopubSetBuilder contextId(String contextId) {
56
        this.contextId = contextId;
×
57
        return this;
×
58
    }
59

60
    public QueryResultNanopubSetBuilder pageResource(AbstractResourceWithProfile pageResource) {
61
        this.pageResource = pageResource;
×
62
        return this;
×
63
    }
64

65
    public QueryResultNanopubSetBuilder resourceWithProfile(AbstractResourceWithProfile resourceWithProfile) {
66
        this.resourceWithProfile = resourceWithProfile;
×
67
        return this;
×
68
    }
69

70
    public QueryResultNanopubSetBuilder id(String id) {
71
        this.id = id;
×
72
        return this;
×
73
    }
74

75
    /**
76
     * Pins this set to a specific ref (root definition), so action visibility is gated
77
     * against that claimant's authority rather than the resource's representative ref.
78
     * Null leaves it on the representative ref.
79
     *
80
     * @param refRoot the ref's root nanopub, or null
81
     * @return the current QueryResultNanopubSetBuilder instance
82
     */
83
    public QueryResultNanopubSetBuilder refRoot(String refRoot) {
84
        this.refRoot = refRoot;
×
85
        return this;
×
86
    }
87

88
    public QueryResultNanopubSetBuilder setItemsPerPage(long itemsPerPage) {
89
        this.itemsPerPage = itemsPerPage;
×
90
        return this;
×
91
    }
92

93
    /**
94
     * Removes the title from the QueryResultNanopubSet.
95
     *
96
     * @return the current QueryResultNanopubSetBuilder instance
97
     */
98
    public QueryResultNanopubSetBuilder noTitle() {
99
        this.hasTitle = false;
×
100
        return this;
×
101
    }
102

103
    /**
104
     * Builds the QueryResultNanopubSet component.
105
     *
106
     * @return the QueryResultNanopubSet component
107
     */
108
    public Component build() {
109
        ApiResponse response = ApiCache.retrieveResponseAsync(queryRef);
×
110
        String colClass = " col-" + viewDisplay.getDisplayWidth();
×
111
        long resolvedItemsPerPage = itemsPerPage != null ? itemsPerPage : viewDisplay.getPageSize();
×
112
        if (response != null) {
×
113
            QueryResultNanopubSet queryResultNanopubSet = buildNanopubSet(markupId, response, resolvedItemsPerPage);
×
114
            queryResultNanopubSet.add(new AttributeAppender("class", colClass));
×
115
            return queryResultNanopubSet;
×
116
        } else {
117
            ApiResultComponent comp = new ApiResultComponent(markupId, queryRef) {
×
118
                @Override
119
                public Component getApiResultComponent(String markupId, ApiResponse response) {
120
                    return buildNanopubSet(markupId, response, resolvedItemsPerPage);
×
121
                }
122
            };
123
            comp.add(new AttributeAppender("class", colClass));
×
124
            return comp;
×
125
        }
126
    }
127

128
    private QueryResultNanopubSet buildNanopubSet(String markupId, ApiResponse response, long resolvedItemsPerPage) {
129
        QueryResultNanopubSet queryResultNanopubSet = new QueryResultNanopubSet(markupId, queryRef, response, viewDisplay, resolvedItemsPerPage);
×
130
        queryResultNanopubSet.setContextId(contextId);
×
131
        queryResultNanopubSet.setPageResource(pageResource);
×
132
        queryResultNanopubSet.setResourceWithProfile(resourceWithProfile);
×
133
        queryResultNanopubSet.setRefRoot(refRoot);
×
134
        // Result actions become entries of the view's dropdown menu, which
135
        // populateComponent() builds — so they are added first.
136
        ViewActionMappings.addResultActions(queryResultNanopubSet, viewDisplay, queryRef, id, contextId, resourceWithProfile, refRoot);
×
137
        queryResultNanopubSet.populateComponent();
×
138
        queryResultNanopubSet.setTitleVisible(hasTitle);
×
139
        return queryResultNanopubSet;
×
140
    }
141

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