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

knowledgepixels / nanodash / 19232563835

10 Nov 2025 01:03PM UTC coverage: 14.137% (+0.2%) from 13.973%
19232563835

push

github

tkuhn
feat(ResourceView): Support for hasPageSize

519 of 4646 branches covered (11.17%)

Branch coverage included in aggregate %.

1354 of 8603 relevant lines covered (15.74%)

0.7 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.*;
4
import com.knowledgepixels.nanodash.page.PublishPage;
5
import com.knowledgepixels.nanodash.template.Template;
6
import org.apache.wicket.Component;
7
import org.apache.wicket.request.mapper.parameter.PageParameters;
8
import org.eclipse.rdf4j.model.IRI;
9
import org.nanopub.extra.services.ApiResponse;
10
import org.nanopub.extra.services.QueryRef;
11

12
import java.io.Serializable;
13

14
/**
15
 * Builder class for creating QueryResultTable components with various configurations.
16
 */
17
public class QueryResultTableBuilder implements Serializable {
18

19
    private String markupId;
20
    private boolean plain = false;
×
21
    private ViewDisplay viewDisplay = null;
×
22
    private String contextId = null;
×
23
    private QueryRef queryRef;
24
    private Space space = null;
×
25
    private String id = null;
×
26

27
    private QueryResultTableBuilder(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
×
28
        this.markupId = markupId;
×
29
        this.queryRef = queryRef;
×
30
        this.viewDisplay = viewDisplay;
×
31
    }
×
32

33
    /**
34
     * Creates a new QueryResultTableBuilder instance.
35
     *
36
     * @param markupId    the markup ID for the component
37
     * @param queryRef    the query reference
38
     * @param rowsPerPage the number of rows per page
39
     * @return a new QueryResultTableBuilder instance
40
     */
41
    public static QueryResultTableBuilder create(String markupId, QueryRef queryRef, ViewDisplay viewDisplay) {
42
        return new QueryResultTableBuilder(markupId, queryRef, viewDisplay);
×
43
    }
44

45
    /**
46
     * Sets the space for the QueryResultTable.
47
     *
48
     * @param space the Space object
49
     * @return the current QueryResultTableBuilder instance
50
     */
51
    public QueryResultTableBuilder space(Space space) {
52
        this.space = space;
×
53
        return this;
×
54
    }
55

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

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

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

89
    /**
90
     * Builds the QueryResultTable component based on the configured parameters.
91
     *
92
     * @return the constructed Component
93
     */
94
    public Component build() {
95
        final GrlcQuery grlcQuery = GrlcQuery.get(queryRef);
×
96
        ApiResponse response = ApiCache.retrieveResponse(queryRef);
×
97
        if (space == null) {
×
98
            if (response != null) {
×
99
                ResourceView view = viewDisplay.getView();
×
100
                QueryResultTable table = new QueryResultTable(markupId, grlcQuery, response, false, viewDisplay, contextId);
×
101
                table.setContext(contextId, space);
×
102
                for (IRI actionIri : view.getActionList()) {
×
103
                    Template t = view.getTemplateForAction(actionIri);
×
104
                    if (t == null) continue;
×
105
                    String targetField = view.getTemplateTargetFieldForAction(actionIri);
×
106
                    if (targetField == null) targetField = "resource";
×
107
                    String label = view.getLabelForAction(actionIri);
×
108
                    if (label == null) label = "action...";
×
109
                    PageParameters params = new PageParameters().set("template", t.getId()).set("param_" + targetField, id).set("context", contextId);
×
110
                    String partField = view.getTemplatePartFieldForAction(actionIri);
×
111
                    if (partField != null) {
×
112
                        // TODO Find a better way to pass the MaintainedResource object to this method:
113
                        MaintainedResource r = MaintainedResource.get(contextId);
×
114
                        if (r != null && r.getNamespace() != null) {
×
115
                            params.set("param_" + partField, r.getNamespace() + "<SET-SUFFIX>");
×
116
                        }
117
                    }
118
                    table.addButton(label, PublishPage.class, params);
×
119
                }
×
120
                return table;
×
121
            } else {
122
                return new ApiResultComponent(markupId, queryRef) {
×
123
                    @Override
124
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
125
                        ResourceView view = viewDisplay.getView();
×
126
                        QueryResultTable table = new QueryResultTable(markupId, grlcQuery, response, false, viewDisplay, contextId);
×
127
                        table.setContext(contextId, space);
×
128
                        for (IRI actionIri : view.getActionList()) {
×
129
                            Template t = view.getTemplateForAction(actionIri);
×
130
                            if (t == null) continue;
×
131
                            String targetField = view.getTemplateTargetFieldForAction(actionIri);
×
132
                            if (targetField == null) targetField = "resource";
×
133
                            String label = view.getLabelForAction(actionIri);
×
134
                            if (label == null) label = "action...";
×
135
                            PageParameters params = new PageParameters().set("template", t.getId()).set("param_" + targetField, id).set("context", contextId);
×
136
                            String partField = view.getTemplatePartFieldForAction(actionIri);
×
137
                            if (partField != null) {
×
138
                                // TODO Find a better way to pass the MaintainedResource object to this method:
139
                                MaintainedResource r = MaintainedResource.get(contextId);
×
140
                                if (r != null && r.getNamespace() != null) {
×
141
                                    params.set("param_" + partField, r.getNamespace() + "<SET-SUFFIX>");
×
142
                                }
143
                            }
144
                            table.addButton(label, PublishPage.class, params);
×
145
                        }
×
146
                        return table;
×
147
                    }
148
                };
149
            }
150
        } else {
151
            if (response != null) {
×
152
                return new QueryResultTable(markupId, grlcQuery, response, plain, viewDisplay, contextId);
×
153
            } else {
154
                return new ApiResultComponent(markupId, queryRef) {
×
155
                    @Override
156
                    public Component getApiResultComponent(String markupId, ApiResponse response) {
157
                        return new QueryResultTable(markupId, grlcQuery, response, plain, viewDisplay, contextId);
×
158
                    }
159
                };
160
            }
161
        }
162
    }
163

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