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

knowledgepixels / nanodash / 28896622329

07 Jul 2026 08:31PM UTC coverage: 28.117% (-0.3%) from 28.465%
28896622329

Pull #543

github

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

1813 of 7315 branches covered (24.78%)

Branch coverage included in aggregate %.

3717 of 12353 relevant lines covered (30.09%)

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

3
import com.knowledgepixels.nanodash.ApiCache;
4
import com.knowledgepixels.nanodash.ViewDisplay;
5
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
6
import org.apache.wicket.Component;
7
import org.apache.wicket.behavior.AttributeAppender;
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 QueryResultTable components with various configurations.
15
 */
16
public class QueryResultTableBuilder implements Serializable {
17

18
    private String markupId;
19
    private boolean plain = false;
×
20
    private ViewDisplay viewDisplay;
21
    private String contextId = null;
×
22
    private QueryRef queryRef;
23
    private AbstractResourceWithProfile resourceWithProfile = null;
×
24
    private String id = null;
×
25
    private String postPublishTab = null;
×
26
    private String refRoot = null;
×
27

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

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

48
    /**
49
     * Sets the resource with profile for the QueryResultTable.
50
     *
51
     * @param resourceWithProfile the ResourceWithProfile object
52
     * @return the current QueryResultTableBuilder instance
53
     */
54
    public QueryResultTableBuilder resourceWithProfile(AbstractResourceWithProfile resourceWithProfile) {
55
        this.resourceWithProfile = resourceWithProfile;
×
56
        return this;
×
57
    }
58

59
    /**
60
     * Sets the ID for the QueryResultTable.
61
     *
62
     * @param id the ID string
63
     * @return the current QueryResultTableBuilder instance
64
     */
65
    public QueryResultTableBuilder id(String id) {
66
        this.id = id;
×
67
        return this;
×
68
    }
69

70
    /**
71
     * Sets whether the table should be plain.
72
     *
73
     * @param plain true for plain table, false otherwise
74
     * @return the current QueryResultTableBuilder instance
75
     */
76
    public QueryResultTableBuilder plain(boolean plain) {
77
        this.plain = plain;
×
78
        return this;
×
79
    }
80

81
    /**
82
     * Sets the context ID for the QueryResultTable.
83
     *
84
     * @param contextId the context ID string
85
     * @return the current QueryResultTableBuilder instance
86
     */
87
    public QueryResultTableBuilder contextId(String contextId) {
88
        this.contextId = contextId;
×
89
        return this;
×
90
    }
91

92
    /**
93
     * Sets the tab to return to after publishing via one of the table's action
94
     * buttons (so the user stays on, e.g., the About tab).
95
     *
96
     * @param postPublishTab the tab name, or null for the default
97
     * @return the current QueryResultTableBuilder instance
98
     */
99
    public QueryResultTableBuilder postPublishTab(String postPublishTab) {
100
        this.postPublishTab = postPublishTab;
×
101
        return this;
×
102
    }
103

104
    /**
105
     * Pins this table to a specific ref (root definition), so action visibility is gated
106
     * against that claimant's authority rather than the resource's representative ref. Used
107
     * on {@code ?root=}-pinned pages. Null leaves it on the representative ref.
108
     *
109
     * @param refRoot the ref's root nanopub, or null
110
     * @return the current QueryResultTableBuilder instance
111
     */
112
    public QueryResultTableBuilder refRoot(String refRoot) {
113
        this.refRoot = refRoot;
×
114
        return this;
×
115
    }
116

117
    /**
118
     * Builds the QueryResultTable component based on the configured parameters.
119
     *
120
     * @return the constructed Component
121
     */
122
    public Component build() {
123
        ApiResponse response = ApiCache.retrieveResponseAsync(queryRef);
×
124
        String colClass = " col-" + viewDisplay.getDisplayWidth();
×
125
        if (resourceWithProfile != null) {
×
126
            if (response != null) {
×
127
                QueryResultTable table = new QueryResultTable(markupId, queryRef, response, viewDisplay, false);
×
128
                table.setContextId(contextId);
×
129
                table.setPostPublishTab(postPublishTab);
×
130
                table.setRefRoot(refRoot);
×
131
                if (id != null && contextId != null && !id.equals(contextId)) {
×
132
                    table.setPartId(id);
×
133
                }
134
                table.setResourceWithProfile(resourceWithProfile);
×
135
                table.setPageResource(resourceWithProfile);
×
136
                ViewActionMappings.addResultActions(table, viewDisplay, queryRef, id, contextId, resourceWithProfile, refRoot);
×
137
                table.add(new AttributeAppender("class", colClass));
×
138
                return table;
×
139
            } else {
140
                ApiResultComponent comp = new ApiResultComponent(markupId, queryRef) {
×
141
                    @Override
142
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
143
                        QueryResultTable table = new QueryResultTable(markupId, queryRef, response, viewDisplay, false);
×
144
                        table.setContextId(contextId);
×
145
                        table.setPostPublishTab(postPublishTab);
×
146
                        table.setRefRoot(refRoot);
×
147
                        if (id != null && contextId != null && !id.equals(contextId)) {
×
148
                            table.setPartId(id);
×
149
                        }
150
                        table.setResourceWithProfile(resourceWithProfile);
×
151
                        table.setPageResource(resourceWithProfile);
×
152
                        ViewActionMappings.addResultActions(table, viewDisplay, queryRef, id, contextId, resourceWithProfile, refRoot);
×
153
                        return table;
×
154
                    }
155
                };
156
                comp.add(new AttributeAppender("class", colClass));
×
157
                return comp;
×
158
            }
159
        } else {
160
            if (response != null) {
×
161
                QueryResultTable table = new QueryResultTable(markupId, queryRef, response, viewDisplay, plain);
×
162
                table.setContextId(contextId);
×
163
                table.setPostPublishTab(postPublishTab);
×
164
                table.setRefRoot(refRoot);
×
165
                ViewActionMappings.addResultActions(table, viewDisplay, queryRef, id, contextId, resourceWithProfile, refRoot);
×
166
                table.add(new AttributeAppender("class", colClass));
×
167
                return table;
×
168
            } else {
169
                ApiResultComponent comp = new ApiResultComponent(markupId, queryRef) {
×
170
                    @Override
171
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
172
                        QueryResultTable table = new QueryResultTable(markupId, queryRef, response, viewDisplay, plain);
×
173
                        table.setContextId(contextId);
×
174
                        table.setPostPublishTab(postPublishTab);
×
175
                        table.setRefRoot(refRoot);
×
176
                        ViewActionMappings.addResultActions(table, viewDisplay, queryRef, id, contextId, resourceWithProfile, refRoot);
×
177
                        return table;
×
178
                    }
179
                };
180
                comp.add(new AttributeAppender("class", colClass));
×
181
                return comp;
×
182
            }
183
        }
184
    }
185

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